From 983cf7e0ad2b891cdd4b1e1f1dbafb789a38cd4f Mon Sep 17 00:00:00 2001 From: Gianluca Mardente Date: Sat, 10 Oct 2026 15:33:53 +0200 Subject: [PATCH] chore: Update libsveltos so clusters with connection down are skipped libsveltos now treats a SveltosCluster whose connection is down as not ready to be configured (Status.Ready stays true while the connection is down, so it was not caught before) and reconciles when the connection is back. Pull mode is unaffected: its connection status mirrors the agent heartbeat, which is already verified separately. addon-controller already uses IsClusterReadyToBeConfigured to decide whether to process a cluster, so with this bump it no longer tries to collect ResourceSummaries from, or upgrade drift-detection-manager in, a cluster that cannot be reached. That removes the repeated "failed to collect ResourceSummaries: compatibility checks failed" and i/o timeout logs for a down cluster. Add a unit test so skipCollecting keeps skipping such a cluster. --- controllers/export_test.go | 1 + .../resourcesummary_collection_test.go | 39 +++++++++++++++++++ go.mod | 2 +- go.sum | 4 +- 4 files changed, 43 insertions(+), 3 deletions(-) diff --git a/controllers/export_test.go b/controllers/export_test.go index b49214cb..599241fa 100644 --- a/controllers/export_test.go +++ b/controllers/export_test.go @@ -252,6 +252,7 @@ var ( CollectResourceSummariesFromCluster = collectResourceSummariesFromCluster CollectAndProcessAllResourceSummaries = collectAndProcessAllResourceSummaries IsResourceSummaryInstalledCached = isResourceSummaryInstalledCached + SkipCollecting = skipCollecting ResetResourceSummaryInstalledCache = func() { resourceSummaryInstalledCacheMu.Lock() resourceSummaryInstalledCache = make(map[corev1.ObjectReference]bool) diff --git a/controllers/resourcesummary_collection_test.go b/controllers/resourcesummary_collection_test.go index 159bad78..c0112ec8 100644 --- a/controllers/resourcesummary_collection_test.go +++ b/controllers/resourcesummary_collection_test.go @@ -594,6 +594,45 @@ var _ = Describe("ResourceSummary Collection", func() { return currentSveltosRS.Status.HelmResourcesChanged }, "2s", pollingInterval).Should(BeTrue()) }) + + It("skipCollecting skips a SveltosCluster whose connection is down, even when it is marked ready", func() { + logger := textlogger.NewLogger(textlogger.NewConfig()) + + sveltosCluster := &libsveltosv1beta1.SveltosCluster{ + ObjectMeta: metav1.ObjectMeta{ + Namespace: randomString(), + Name: randomString(), + }, + Status: libsveltosv1beta1.SveltosClusterStatus{ + Ready: true, + ConnectionStatus: libsveltosv1beta1.ConnectionDown, + }, + } + c := fake.NewClientBuilder().WithScheme(scheme).WithObjects(sveltosCluster).Build() + + clusterRef := &corev1.ObjectReference{ + Namespace: sveltosCluster.Namespace, + Name: sveltosCluster.Name, + Kind: libsveltosv1beta1.SveltosClusterKind, + APIVersion: libsveltosv1beta1.GroupVersion.String(), + } + + skip, err := controllers.SkipCollecting(context.TODO(), c, clusterRef, logger) + Expect(err).To(BeNil()) + Expect(skip).To(BeTrue()) + + // Once the connection is back, collection is not skipped anymore + currentSveltosCluster := &libsveltosv1beta1.SveltosCluster{} + Expect(c.Get(context.TODO(), + types.NamespacedName{Namespace: sveltosCluster.Namespace, Name: sveltosCluster.Name}, + currentSveltosCluster)).To(Succeed()) + currentSveltosCluster.Status.ConnectionStatus = libsveltosv1beta1.ConnectionHealthy + Expect(c.Update(context.TODO(), currentSveltosCluster)).To(Succeed()) + + skip, err = controllers.SkipCollecting(context.TODO(), c, clusterRef, logger) + Expect(err).To(BeNil()) + Expect(skip).To(BeFalse()) + }) }) // getResourceSummary returns a bare ResourceSummary. None of the tests in this file need it diff --git a/go.mod b/go.mod index f961ffa0..dd85b9a3 100644 --- a/go.mod +++ b/go.mod @@ -20,7 +20,7 @@ require ( github.com/onsi/gomega v1.44.0 github.com/opencontainers/image-spec v1.1.1 github.com/pkg/errors v0.9.1 - github.com/projectsveltos/libsveltos v1.16.1-0.20261007133830-d623a1556939 + github.com/projectsveltos/libsveltos v1.16.1-0.20261010130719-c6f30f77e62f github.com/prometheus/client_golang v1.25.0 github.com/sigstore/cosign/v3 v3.1.3 github.com/sigstore/sigstore v1.11.0 diff --git a/go.sum b/go.sum index 00d966cb..b6b78274 100644 --- a/go.sum +++ b/go.sum @@ -643,8 +643,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.16.1-0.20261007133830-d623a1556939 h1:yQuZm4uT19ZkdCPSU3hkheRszZOCXBEY4TILNudAm58= -github.com/projectsveltos/libsveltos v1.16.1-0.20261007133830-d623a1556939/go.mod h1:wup25BAf1SHuG6FsY8D+tnm1U3/3NiuzcKec/In/fB4= +github.com/projectsveltos/libsveltos v1.16.1-0.20261010130719-c6f30f77e62f h1:4+dAshhv+rdzFIlo6q5+3/8mSmxwiqxN1gxl5czeeF8= +github.com/projectsveltos/libsveltos v1.16.1-0.20261010130719-c6f30f77e62f/go.mod h1:wup25BAf1SHuG6FsY8D+tnm1U3/3NiuzcKec/In/fB4= 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=