From abaa34eec35302f8a72417111cc380e9d6bae7b6 Mon Sep 17 00:00:00 2001 From: Gianluca Mardente <52940363+gianlucam76@users.noreply.github.com> Date: Thu, 11 Jun 2026 11:32:05 +0200 Subject: [PATCH 1/2] (bug) Deleting profiles (#1828) This PR fixes a bug in addon-controller where deleting ClusterProfiles got stuck because `allMatchingProfilesProcessed` didn't skip other profiles already being deleted. --- controllers/handlers_helm.go | 6 ++++++ controllers/handlers_helm_test.go | 35 +++++++++++++++++++++++++++++++ 2 files changed, 41 insertions(+) diff --git a/controllers/handlers_helm.go b/controllers/handlers_helm.go index ee2a49c4..8c42c56f 100644 --- a/controllers/handlers_helm.go +++ b/controllers/handlers_helm.go @@ -794,6 +794,9 @@ func isClusterProfileProcessed(ctx context.Context, c client.Client, if cp.Name == ownerName || len(cp.Spec.HelmCharts) == 0 { return true, nil } + if cp.DeletionTimestamp != nil && !cp.DeletionTimestamp.IsZero() { + return true, nil + } if hasDeletionTimestamp && cp.CreationTimestamp.After(deletionTime) { return true, nil } @@ -822,6 +825,9 @@ func isProfileProcessed(ctx context.Context, c client.Client, if p.Name == ownerName || len(p.Spec.HelmCharts) == 0 { return true, nil } + if p.DeletionTimestamp != nil && !p.DeletionTimestamp.IsZero() { + return true, nil + } if hasDeletionTimestamp && p.CreationTimestamp.After(deletionTime) { return true, nil } diff --git a/controllers/handlers_helm_test.go b/controllers/handlers_helm_test.go index e0ee4c2a..8c00913a 100644 --- a/controllers/handlers_helm_test.go +++ b/controllers/handlers_helm_test.go @@ -2026,4 +2026,39 @@ var _ = Describe("allMatchingProfilesProcessed", func() { Expect(err).To(BeNil()) Expect(processed).To(BeTrue()) }) + + It("returns true when a matching ClusterProfile is being deleted and its ClusterSummary is gone", func() { + s, err := setupScheme() + Expect(err).To(BeNil()) + + // cpB matches the cluster and has HelmCharts, but is being deleted — its + // ClusterSummary was already cleaned up as part of the deletion flow. + now := metav1.Now() + cpB := &configv1beta1.ClusterProfile{ + ObjectMeta: metav1.ObjectMeta{ + Name: randomString(), + DeletionTimestamp: &now, + Finalizers: []string{"test-finalizer"}, + }, + Spec: configv1beta1.Spec{ + ClusterSelector: libsveltosv1beta1.Selector{ + LabelSelector: metav1.LabelSelector{ + MatchLabels: map[string]string{testEnvLabelKey: testProductionValue}, + }, + }, + HelmCharts: []configv1beta1.HelmChart{ + {ReleaseName: randomString(), ReleaseNamespace: randomString(), + RepositoryURL: randomString(), ChartName: randomString(), ChartVersion: randomString()}, + }, + }, + } + + // no ClusterSummary for cpB — it was already deleted during profile cleanup + c := fake.NewClientBuilder().WithScheme(s).WithObjects(cluster, cpB).Build() + + processed, err := controllers.AllMatchingProfilesProcessed(context.TODO(), c, + clusterSummary, textlogger.NewLogger(textlogger.NewConfig())) + Expect(err).To(BeNil()) + Expect(processed).To(BeTrue()) + }) }) From f17f958acf1e9f7473526ed4e5125054e51a1085 Mon Sep 17 00:00:00 2001 From: Gianluca Mardente Date: Thu, 11 Jun 2026 16:09:42 +0200 Subject: [PATCH 2/2] (chore) Prepare for release v1.11.1 --- Makefile | 2 +- config/default/manager_auth_proxy_patch.yaml | 2 +- config/default/manager_image_patch.yaml | 4 ++-- go.mod | 2 +- go.sum | 4 ++-- manifest/deployment-agentless.yaml | 6 +++--- manifest/deployment-shard.yaml | 6 +++--- manifest/manifest.yaml | 6 +++--- .../drift-detection-manager-in-mgmt-cluster.go | 4 ++-- .../drift-detection-manager-in-mgmt-cluster.yaml | 4 ++-- pkg/drift-detection/drift-detection-manager.go | 4 ++-- pkg/drift-detection/drift-detection-manager.yaml | 4 ++-- test/pullmode-sveltosapplier.yaml | 2 +- 13 files changed, 25 insertions(+), 25 deletions(-) diff --git a/Makefile b/Makefile index 4b4e7dbd..15e477a0 100644 --- a/Makefile +++ b/Makefile @@ -34,7 +34,7 @@ OS ?= $(shell uname -s) OS := $(shell echo $(OS) | tr '[:upper:]' '[:lower:]') K8S_LATEST_VER ?= $(shell curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt) export CONTROLLER_IMG ?= $(REGISTRY)/$(IMAGE_NAME) -TAG ?= v1.11.0 +TAG ?= v1.11.1 .PHONY: all all: build diff --git a/config/default/manager_auth_proxy_patch.yaml b/config/default/manager_auth_proxy_patch.yaml index 8d22fd04..a54b06f8 100644 --- a/config/default/manager_auth_proxy_patch.yaml +++ b/config/default/manager_auth_proxy_patch.yaml @@ -35,7 +35,7 @@ spec: - --shard-key= - --capi-onboard-annotation= - "--v=5" - - "--version=v1.11.0" + - "--version=v1.11.1" - "--agent-in-mgmt-cluster=false" env: - name: GOMEMLIMIT diff --git a/config/default/manager_image_patch.yaml b/config/default/manager_image_patch.yaml index 65f14ebd..c5614f94 100644 --- a/config/default/manager_image_patch.yaml +++ b/config/default/manager_image_patch.yaml @@ -7,8 +7,8 @@ spec: template: spec: initContainers: - - image: docker.io/projectsveltos/addon-controller:v1.11.0 + - image: docker.io/projectsveltos/addon-controller:v1.11.1 name: initialization containers: - - image: docker.io/projectsveltos/addon-controller:v1.11.0 + - image: docker.io/projectsveltos/addon-controller:v1.11.1 name: controller diff --git a/go.mod b/go.mod index ec6eb699..0a3bdc5a 100644 --- a/go.mod +++ b/go.mod @@ -18,7 +18,7 @@ require ( github.com/onsi/ginkgo/v2 v2.29.0 github.com/onsi/gomega v1.41.0 github.com/pkg/errors v0.9.1 - github.com/projectsveltos/libsveltos v1.11.0 + github.com/projectsveltos/libsveltos v1.11.1 github.com/prometheus/client_golang v1.23.2 github.com/robfig/cron v1.2.0 github.com/spf13/pflag v1.0.10 diff --git a/go.sum b/go.sum index 4d110aa3..98c40786 100644 --- a/go.sum +++ b/go.sum @@ -273,8 +273,8 @@ github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 h1:Jamvg5psRI github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/poy/onpar v1.1.2 h1:QaNrNiZx0+Nar5dLgTVp5mXkyoVFIbepjyEoGSnhbAY= github.com/poy/onpar v1.1.2/go.mod h1:6X8FLNoxyr9kkmnlqpK6LSoiOtrO6MICtWwEuWkLjzg= -github.com/projectsveltos/libsveltos v1.11.0 h1:E67QyQMj2VNTGisBQJI0AYenR9OFKUK3v1OSFu/9jCc= -github.com/projectsveltos/libsveltos v1.11.0/go.mod h1:B9tm32CB/AKIqmy/J02NmIUiwatec3NR1RcW5W/v0UM= +github.com/projectsveltos/libsveltos v1.11.1 h1:7Hjs7+6MEYgPzLjeYZkaRFZVPg1hJqOxml477Q6n23o= +github.com/projectsveltos/libsveltos v1.11.1/go.mod h1:B9tm32CB/AKIqmy/J02NmIUiwatec3NR1RcW5W/v0UM= github.com/projectsveltos/lua-utils/glua-json v0.0.0-20251212200258-2b3cdcb7c0f5 h1:khnc+994UszxZYu69J+R5FKiLA/Nk1JQj0EYAkwTWz0= github.com/projectsveltos/lua-utils/glua-json v0.0.0-20251212200258-2b3cdcb7c0f5/go.mod h1:yVL8KQFa9tmcxgwl9nwIMtKgtmIVC1zaFRSCfOwYvPY= github.com/projectsveltos/lua-utils/glua-runes v0.0.0-20251212200258-2b3cdcb7c0f5 h1:YbsebwRwTRhV8QacvEAdFqxcxHdeu7JTVtsBovbkgos= diff --git a/manifest/deployment-agentless.yaml b/manifest/deployment-agentless.yaml index 4ec2aad9..bfc1877f 100644 --- a/manifest/deployment-agentless.yaml +++ b/manifest/deployment-agentless.yaml @@ -26,7 +26,7 @@ spec: - --shard-key= - --capi-onboard-annotation= - --v=5 - - --version=v1.11.0 + - --version=v1.11.1 - --agent-in-mgmt-cluster=true command: - /manager @@ -43,7 +43,7 @@ spec: valueFrom: fieldRef: fieldPath: metadata.namespace - image: docker.io/projectsveltos/addon-controller:v1.11.0 + image: docker.io/projectsveltos/addon-controller:v1.11.1 livenessProbe: failureThreshold: 3 httpGet: @@ -101,7 +101,7 @@ spec: fieldPath: metadata.namespace - name: IS_INITIALIZATION value: "true" - image: docker.io/projectsveltos/addon-controller:v1.11.0 + image: docker.io/projectsveltos/addon-controller:v1.11.1 name: initialization securityContext: allowPrivilegeEscalation: false diff --git a/manifest/deployment-shard.yaml b/manifest/deployment-shard.yaml index 7437d710..52c0c5a8 100644 --- a/manifest/deployment-shard.yaml +++ b/manifest/deployment-shard.yaml @@ -26,7 +26,7 @@ spec: - --shard-key={{.SHARD}} - --capi-onboard-annotation= - --v=5 - - --version=v1.11.0 + - --version=v1.11.1 - --agent-in-mgmt-cluster=false command: - /manager @@ -43,7 +43,7 @@ spec: valueFrom: fieldRef: fieldPath: metadata.namespace - image: docker.io/projectsveltos/addon-controller:v1.11.0 + image: docker.io/projectsveltos/addon-controller:v1.11.1 livenessProbe: failureThreshold: 3 httpGet: @@ -101,7 +101,7 @@ spec: fieldPath: metadata.namespace - name: IS_INITIALIZATION value: "true" - image: docker.io/projectsveltos/addon-controller:v1.11.0 + image: docker.io/projectsveltos/addon-controller:v1.11.1 name: initialization securityContext: allowPrivilegeEscalation: false diff --git a/manifest/manifest.yaml b/manifest/manifest.yaml index 3098a054..c654f915 100644 --- a/manifest/manifest.yaml +++ b/manifest/manifest.yaml @@ -10162,7 +10162,7 @@ spec: - --shard-key= - --capi-onboard-annotation= - --v=5 - - --version=v1.11.0 + - --version=v1.11.1 - --agent-in-mgmt-cluster=false command: - /manager @@ -10179,7 +10179,7 @@ spec: valueFrom: fieldRef: fieldPath: metadata.namespace - image: docker.io/projectsveltos/addon-controller:v1.11.0 + image: docker.io/projectsveltos/addon-controller:v1.11.1 livenessProbe: failureThreshold: 3 httpGet: @@ -10237,7 +10237,7 @@ spec: fieldPath: metadata.namespace - name: IS_INITIALIZATION value: "true" - image: docker.io/projectsveltos/addon-controller:v1.11.0 + image: docker.io/projectsveltos/addon-controller:v1.11.1 name: initialization securityContext: allowPrivilegeEscalation: false diff --git a/pkg/drift-detection/drift-detection-manager-in-mgmt-cluster.go b/pkg/drift-detection/drift-detection-manager-in-mgmt-cluster.go index c47d7816..e4f03f77 100644 --- a/pkg/drift-detection/drift-detection-manager-in-mgmt-cluster.go +++ b/pkg/drift-detection/drift-detection-manager-in-mgmt-cluster.go @@ -44,7 +44,7 @@ spec: - --cluster-type= - --current-cluster=management-cluster - --run-mode=do-not-send-updates - - --version=v1.11.0 + - --version=v1.11.1 command: - /manager env: @@ -60,7 +60,7 @@ spec: valueFrom: fieldRef: fieldPath: metadata.namespace - image: docker.io/projectsveltos/drift-detection-manager@sha256:3fc2ea2b3814de27923d90c4a6b68e05afddd6e84b344d8b8d6866cb6815965d + image: docker.io/projectsveltos/drift-detection-manager@sha256:30ab12facf0242bad79dff03e95a70977b83d5671035e423f134a1b9d66fbb4e livenessProbe: failureThreshold: 3 httpGet: diff --git a/pkg/drift-detection/drift-detection-manager-in-mgmt-cluster.yaml b/pkg/drift-detection/drift-detection-manager-in-mgmt-cluster.yaml index dd558c60..983de62c 100644 --- a/pkg/drift-detection/drift-detection-manager-in-mgmt-cluster.yaml +++ b/pkg/drift-detection/drift-detection-manager-in-mgmt-cluster.yaml @@ -26,7 +26,7 @@ spec: - --cluster-type= - --current-cluster=management-cluster - --run-mode=do-not-send-updates - - --version=v1.11.0 + - --version=v1.11.1 command: - /manager env: @@ -42,7 +42,7 @@ spec: valueFrom: fieldRef: fieldPath: metadata.namespace - image: docker.io/projectsveltos/drift-detection-manager@sha256:3fc2ea2b3814de27923d90c4a6b68e05afddd6e84b344d8b8d6866cb6815965d + image: docker.io/projectsveltos/drift-detection-manager@sha256:30ab12facf0242bad79dff03e95a70977b83d5671035e423f134a1b9d66fbb4e livenessProbe: failureThreshold: 3 httpGet: diff --git a/pkg/drift-detection/drift-detection-manager.go b/pkg/drift-detection/drift-detection-manager.go index 1ddb82ff..19342ece 100644 --- a/pkg/drift-detection/drift-detection-manager.go +++ b/pkg/drift-detection/drift-detection-manager.go @@ -146,7 +146,7 @@ spec: - --cluster-type= - --current-cluster=managed-cluster - --run-mode=do-not-send-updates - - --version=v1.11.0 + - --version=v1.11.1 command: - /manager env: @@ -162,7 +162,7 @@ spec: valueFrom: fieldRef: fieldPath: metadata.namespace - image: docker.io/projectsveltos/drift-detection-manager@sha256:3fc2ea2b3814de27923d90c4a6b68e05afddd6e84b344d8b8d6866cb6815965d + image: docker.io/projectsveltos/drift-detection-manager@sha256:30ab12facf0242bad79dff03e95a70977b83d5671035e423f134a1b9d66fbb4e livenessProbe: failureThreshold: 3 httpGet: diff --git a/pkg/drift-detection/drift-detection-manager.yaml b/pkg/drift-detection/drift-detection-manager.yaml index 1d087c48..4ff3d6a3 100644 --- a/pkg/drift-detection/drift-detection-manager.yaml +++ b/pkg/drift-detection/drift-detection-manager.yaml @@ -128,7 +128,7 @@ spec: - --cluster-type= - --current-cluster=managed-cluster - --run-mode=do-not-send-updates - - --version=v1.11.0 + - --version=v1.11.1 command: - /manager env: @@ -144,7 +144,7 @@ spec: valueFrom: fieldRef: fieldPath: metadata.namespace - image: docker.io/projectsveltos/drift-detection-manager@sha256:3fc2ea2b3814de27923d90c4a6b68e05afddd6e84b344d8b8d6866cb6815965d + image: docker.io/projectsveltos/drift-detection-manager@sha256:30ab12facf0242bad79dff03e95a70977b83d5671035e423f134a1b9d66fbb4e livenessProbe: failureThreshold: 3 httpGet: diff --git a/test/pullmode-sveltosapplier.yaml b/test/pullmode-sveltosapplier.yaml index a72f262e..5d64b4df 100644 --- a/test/pullmode-sveltosapplier.yaml +++ b/test/pullmode-sveltosapplier.yaml @@ -99,7 +99,7 @@ spec: valueFrom: fieldRef: fieldPath: metadata.namespace - image: docker.io/projectsveltos/sveltos-applier@sha256:81a0fdff0ba38ba2ecfa9c48c35e4d4167c21e603315d77cfdebe5630e532a92 + image: docker.io/projectsveltos/sveltos-applier@sha256:46c46c8c4617a7a20c96cec5bce66d3ee1cf494123a07bf86574782e66d1c80e livenessProbe: failureThreshold: 3 httpGet: