From 2b100a119143d113abdde6a48d09c4debd6b3bc3 Mon Sep 17 00:00:00 2001 From: Rizwana777 Date: Wed, 3 Jul 2024 16:43:01 +0530 Subject: [PATCH] Fix bug where ArgoCD removes nodePlacement stanza from configuration Signed-off-by: Rizwana777 --- controllers/gitopsservice_controller.go | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/controllers/gitopsservice_controller.go b/controllers/gitopsservice_controller.go index 33840081c..83ed6b960 100644 --- a/controllers/gitopsservice_controller.go +++ b/controllers/gitopsservice_controller.go @@ -472,9 +472,15 @@ func (r *ReconcileGitopsService) reconcileDefaultArgoCDInstance(instance *pipeli changed = true } - if !reflect.DeepEqual(existingArgoCD.Spec.NodePlacement, defaultArgoCDInstance.Spec.NodePlacement) { - existingArgoCD.Spec.NodePlacement = defaultArgoCDInstance.Spec.NodePlacement - changed = true + // Checking if default nodePlacement is nil to verify whether the patch is done using GitopService CR or ArgoCD CR + // if user is patching nodePlacement through GitopsService CR, then the above written logic for GitopsService will add custom values to defaultArgoCDInstance's nodePlacement, + // if user is patching nodePlacement through ArgoCD CR, defaultArgoCDInstance's nodePlacement will be nil and it will + // enter the if condition below and update the existing nodePlacement as nil which is a bug. + if defaultArgoCDInstance.Spec.NodePlacement != nil { + if !reflect.DeepEqual(existingArgoCD.Spec.NodePlacement, defaultArgoCDInstance.Spec.NodePlacement) { + existingArgoCD.Spec.NodePlacement = defaultArgoCDInstance.Spec.NodePlacement + changed = true + } } if changed {