From dc43263deb04c0709246d95fda3f5662fb1a4375 Mon Sep 17 00:00:00 2001 From: Adam Janikowski <12255597+ajanikow@users.noreply.github.com> Date: Thu, 7 Mar 2024 15:10:53 +0100 Subject: [PATCH] [Bugfix] Fix AF Mode (#1611) --- CHANGELOG.md | 1 + pkg/deployment/deployment_inspector.go | 14 ++++++++------ pkg/util/affinity/affinity.go | 2 +- 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 930144301..a7f37cd3a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,7 @@ - (Feature) Deployment & Members Condition metrics - (Maintenance) Update Go to 1.21.8 & Dependencies - (Feature) (ArangoBackup) Propagate message during retries +- (Bugfix) Fix ActiveFailover Mode ## [1.2.38](https://github.com/arangodb/kube-arangodb/tree/1.2.38) (2024-02-22) - (Feature) Extract GRPC Server diff --git a/pkg/deployment/deployment_inspector.go b/pkg/deployment/deployment_inspector.go index ce69feee7..c3a50a5d1 100644 --- a/pkg/deployment/deployment_inspector.go +++ b/pkg/deployment/deployment_inspector.go @@ -384,7 +384,7 @@ func (d *Deployment) inspectDeploymentWithError(ctx context.Context, lastInterva return minInspectionInterval, nil } else { - isUpToDate, reason := d.isUpToDateStatus(status) + isUpToDate, reason := d.isUpToDateStatus(currentSpec.GetMode(), status) if !isUpToDate && status.Conditions.IsTrue(api.ConditionTypeUpToDate) { if err = d.updateConditionWithHash(ctx, api.ConditionTypeUpToDate, false, reason, "There are pending operations in plan or members are in restart process", *v); err != nil { @@ -451,7 +451,7 @@ func (d *Deployment) sendCIUpdate() { } } -func (d *Deployment) isUpToDateStatus(status api.DeploymentStatus) (upToDate bool, reason string) { +func (d *Deployment) isUpToDateStatus(mode api.DeploymentMode, status api.DeploymentStatus) (upToDate bool, reason string) { if status.NonInternalActions() > 0 { return false, "Plan is not empty" } @@ -494,10 +494,12 @@ func (d *Deployment) isUpToDateStatus(status api.DeploymentStatus) (upToDate boo reason = "PVC is resizing" return } - if !member.Conditions.IsTrue(api.ConditionTypeReady) { - upToDate = false - reason = "Not all members are ready" - return + if mode != api.DeploymentModeActiveFailover { + if !member.Conditions.IsTrue(api.ConditionTypeReady) { + upToDate = false + reason = "Not all members are ready" + return + } } } diff --git a/pkg/util/affinity/affinity.go b/pkg/util/affinity/affinity.go index 2b40fc264..b5a84a80b 100644 --- a/pkg/util/affinity/affinity.go +++ b/pkg/util/affinity/affinity.go @@ -182,7 +182,7 @@ func MergeNodeSelector(a, b *core.NodeSelector) *core.NodeSelector { sa.MatchExpressions = append(sa.MatchExpressions, sb.MatchExpressions...) sa.MatchFields = append(sa.MatchFields, sb.MatchFields...) - if len(sa.MatchExpressions) == 0 || len(sa.MatchFields) == 0 { + if len(sa.MatchExpressions) == 0 && len(sa.MatchFields) == 0 { continue }