diff --git a/internal/dash0/startup/auto_operator_configuration_handler.go b/internal/dash0/startup/auto_operator_configuration_handler.go index cc929c0..f30af51 100644 --- a/internal/dash0/startup/auto_operator_configuration_handler.go +++ b/internal/dash0/startup/auto_operator_configuration_handler.go @@ -211,6 +211,17 @@ func (r *AutoOperatorConfigurationResourceHandler) createOperatorConfigurationRe operatorConfigurationResource := dash0v1alpha1.Dash0OperatorConfiguration{ ObjectMeta: metav1.ObjectMeta{ Name: operatorConfigurationAutoResourceName, + Annotations: map[string]string{ + // For clusters managed by ArgoCD, we need to prevent ArgoCD to prune resources that are not created + // directly via the Helm chart and that have no owner reference. These are all cluster-scoped resources + // not created via Helm, like cluster roles & cluster role bindings. See also: + // * https://github.com/argoproj/argo-cd/issues/4764#issuecomment-722661940 -- this is where they say + // that only top level resources are pruned (that is basically the same as resources without an owner + // reference). + // * The docs for preventing this on a resource level are here: + // https://argo-cd.readthedocs.io/en/stable/user-guide/sync-options/#no-prune-resources + "argocd.argoproj.io/sync-options": "Prune=false", + }, }, Spec: dash0v1alpha1.Dash0OperatorConfigurationSpec{ SelfMonitoring: dash0v1alpha1.SelfMonitoring{ diff --git a/internal/dash0/startup/auto_operator_configuration_handler_test.go b/internal/dash0/startup/auto_operator_configuration_handler_test.go index e85d1b5..eb26b41 100644 --- a/internal/dash0/startup/auto_operator_configuration_handler_test.go +++ b/internal/dash0/startup/auto_operator_configuration_handler_test.go @@ -104,8 +104,11 @@ var _ = Describe("Create an operator configuration resource at startup", Ordered err := k8sClient.Get(ctx, types.NamespacedName{ Name: operatorConfigurationAutoResourceName, }, &operatorConfiguration) - g.Expect(err).ToNot(HaveOccurred()) + + g.Expect(operatorConfiguration.Annotations).To(HaveLen(1)) + g.Expect(operatorConfiguration.Annotations["argocd.argoproj.io/sync-options"]).To(Equal("Prune=false")) + export := operatorConfiguration.Spec.Export g.Expect(export).ToNot(BeNil()) dash0Export := export.Dash0 @@ -129,8 +132,11 @@ var _ = Describe("Create an operator configuration resource at startup", Ordered err := k8sClient.Get(ctx, types.NamespacedName{ Name: operatorConfigurationAutoResourceName, }, &operatorConfiguration) - g.Expect(err).ToNot(HaveOccurred()) + + g.Expect(operatorConfiguration.Annotations).To(HaveLen(1)) + g.Expect(operatorConfiguration.Annotations["argocd.argoproj.io/sync-options"]).To(Equal("Prune=false")) + export := operatorConfiguration.Spec.Export g.Expect(export).ToNot(BeNil()) dash0Export := export.Dash0