gitops-operator
gitops-operator copied to clipboard
Fix bug where ArgoCD removes nodePlacement stanza from configuration
What type of PR is this? /kind bug
JIRA - https://issues.redhat.com/browse/GITOPS-4185
We were not able to patch the NodePlacement directly through ArgoCD CR, if we do, it removes the nodePlacement from ArgoCD CR while reconciling because of this https://github.com/redhat-developer/gitops-operator/blob/master/controllers/gitopsservice_controller.go#L475 here defaultArgoCDInstance.Spec.NodePlacement
is nil as it not getting updated anywhere else in code, defaultArgoCDInstance.Spec.NodePlacement
is only getting updated if we update it through GitOpsService CR or else it update existingArgoCD.Spec.NodePlacement
as nil because of the reason I have mentioned above , but if a user wants to add custom nodePlacement he/she should patch nodePlacement through GitOpsService CR and it is working as expected I see no bug in code and code is valid https://github.com/redhat-developer/gitops-operator/blob/01251d23020555e3a28d4a69e30718e9d5f0eb4d/controllers/gitopsservice_controller.go#L392
I have updated the code here - https://github.com/redhat-developer/gitops-operator/blob/01251d23020555e3a28d4a69e30718e9d5f0eb4d/controllers/gitopsservice_controller.go#L475
which is checking for nil , the logic mentioned in the PR states that , it will check for defaultArgoCDInstance.Spec.NodePlacement
not equal to nil (it means nodePlacePlacement is updated through GitOps service CR and the values got updated here in if condition) else it will not enter the if condition to check if defaultArgoCDInstance.Spec.NodePlacement
is nil (it means nodePlacePlacement is updated through ArgoCD by user and it should not replace the existingArgoCD with nil value, that is the changes made by user will not get reverted back as mentioned in the bug when it reconciles)
This is what I have came up with for the bug mentioned above, please do let me know your suggestions, thank you