Skip to content

Commit

Permalink
fix(startup): add ArgoCD no pruning annotation to operator configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
basti1302 committed Oct 7, 2024
1 parent 6e07f25 commit 742d74f
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
11 changes: 11 additions & 0 deletions internal/dash0/startup/auto_operator_configuration_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down

0 comments on commit 742d74f

Please sign in to comment.