From dad2c2d347f0012a3e02af466be76f94afa9f66d Mon Sep 17 00:00:00 2001 From: Adam Janikowski <12255597+ajanikow@users.noreply.github.com> Date: Wed, 17 Jul 2024 13:07:36 +0200 Subject: [PATCH] [Bugfix] Remove Condition Check (#1681) --- CHANGELOG.md | 1 + pkg/deployment/reconcile/helper_shutdown.go | 10 +++++----- pkg/deployment/reconcile/plan_builder_scale.go | 12 +++++++----- 3 files changed, 13 insertions(+), 10 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a66d58be8..98b64f0fd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ - (Feature) Fix CRD Schema types - (Bugfix) Adjust Prometheus Monitor labels - (Feature) Expose HTTP Client Config +- (Bugfix) MarkedToRemove Condition Check ## [1.2.41](https://github.com/arangodb/kube-arangodb/tree/1.2.41) (2024-05-24) - (Maintenance) Bump Prometheus API Version diff --git a/pkg/deployment/reconcile/helper_shutdown.go b/pkg/deployment/reconcile/helper_shutdown.go index 87125d23b..fa2c9d550 100644 --- a/pkg/deployment/reconcile/helper_shutdown.go +++ b/pkg/deployment/reconcile/helper_shutdown.go @@ -61,11 +61,6 @@ func getShutdownHelper(a actionImpl) (ActionCore, api.MemberStatus, bool) { return nil, api.MemberStatus{}, false } - if ifPodUIDMismatch(m, a.action, cache) { - a.log.Error("Member UID is changed") - return NewActionSuccess(), m, true - } - pod, ok := cache.Pod().V1().GetSimple(m.Pod.GetName()) if !ok { a.log.Str("pod-name", m.Pod.GetName()).Warn("pod is already gone") @@ -73,6 +68,11 @@ func getShutdownHelper(a actionImpl) (ActionCore, api.MemberStatus, bool) { return NewActionSuccess(), m, true } + if ifPodUIDMismatch(m, a.action, cache) { + a.log.Error("Member UID is changed") + return NewActionSuccess(), m, true + } + if _, ok := pod.GetAnnotations()[deployment.ArangoDeploymentPodDeleteNow]; ok { // The pod contains annotation, so pod must be deleted immediately. return shutdownNow{actionImpl: a, memberStatus: m}, m, true diff --git a/pkg/deployment/reconcile/plan_builder_scale.go b/pkg/deployment/reconcile/plan_builder_scale.go index 6097bd853..86110481f 100644 --- a/pkg/deployment/reconcile/plan_builder_scale.go +++ b/pkg/deployment/reconcile/plan_builder_scale.go @@ -1,7 +1,7 @@ // // DISCLAIMER // -// Copyright 2016-2023 ArangoDB GmbH, Cologne, Germany +// Copyright 2016-2024 ArangoDB GmbH, Cologne, Germany // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -140,10 +140,12 @@ func (r *Reconciler) createReplaceMemberPlan(ctx context.Context, apiObject k8su switch group { case api.ServerGroupDBServers: - plan = append(plan, actions.NewAction(api.ActionTypeAddMember, group, sharedReconcile.WithPredefinedMember(""))) - r.planLogger. - Str("role", group.AsRole()). - Debug("Creating replacement plan") + if len(status.Members.DBServers) <= spec.DBServers.GetCount() { + plan = append(plan, actions.NewAction(api.ActionTypeAddMember, group, sharedReconcile.WithPredefinedMember(""))) + r.planLogger. + Str("role", group.AsRole()). + Debug("Creating replacement plan") + } case api.ServerGroupCoordinators: plan = append(plan, cleanOutMember(group, member)...) r.planLogger.