From 24673fde0de22051b65f6ea73bc828dca08492c3 Mon Sep 17 00:00:00 2001 From: Gianluca Mardente Date: Sat, 31 Jan 2026 13:54:36 +0100 Subject: [PATCH] Advance libsveltos If a request for the same key is already in the dirty queue, discard the current result. This prevents the requester from receiving an outdated result when a newer request is already pending. --- controllers/handlers_helm.go | 18 ++++++++++++------ go.mod | 2 +- go.sum | 4 ++-- 3 files changed, 15 insertions(+), 9 deletions(-) diff --git a/controllers/handlers_helm.go b/controllers/handlers_helm.go index 6a9be665..434d6c10 100644 --- a/controllers/handlers_helm.go +++ b/controllers/handlers_helm.go @@ -979,7 +979,7 @@ func walkChartsAndDeploy(ctx context.Context, c client.Client, clusterSummary *c return releaseReports, chartDeployed, err } - err = updateValueHashOnHelmChartSummary(ctx, instantiatedChart, clusterSummary, mgmtResources, logger) + valueHash, err := updateValueHashOnHelmChartSummary(ctx, instantiatedChart, clusterSummary, mgmtResources, logger) if err != nil { return releaseReports, chartDeployed, err } @@ -987,8 +987,14 @@ func walkChartsAndDeploy(ctx context.Context, c client.Client, clusterSummary *c releaseReports = append(releaseReports, *report) if currentRelease != nil { - logger.V(logs.LogInfo).Info(fmt.Sprintf("release %s/%s (version %s) status: %s", - currentRelease.ReleaseNamespace, currentRelease.ReleaseName, currentRelease.ChartVersion, currentRelease.Status)) + if valueHash != nil { + logger.V(logs.LogInfo).Info(fmt.Sprintf("release %s/%s (version %s) (value hash %x) status: %s", + currentRelease.ReleaseNamespace, currentRelease.ReleaseName, currentRelease.ChartVersion, + valueHash, currentRelease.Status)) + } else { + logger.V(logs.LogInfo).Info(fmt.Sprintf("release %s/%s (version %s) status: %s", + currentRelease.ReleaseNamespace, currentRelease.ReleaseName, currentRelease.ChartVersion, currentRelease.Status)) + } if currentRelease.Status == release.StatusDeployed.String() { // Deployed chart is used for updating ClusterConfiguration. There is no ClusterConfiguration for mgmt cluster chartDeployed = append(chartDeployed, configv1beta1.Chart{ @@ -3573,13 +3579,13 @@ func getHelmChartValuesHash(ctx context.Context, c client.Client, instantiatedCh func updateValueHashOnHelmChartSummary(ctx context.Context, requestedChart *configv1beta1.HelmChart, clusterSummary *configv1beta1.ClusterSummary, mgmtResources map[string]*unstructured.Unstructured, - logger logr.Logger) error { + logger logr.Logger) ([]byte, error) { c := getManagementClusterClient() helmChartValuesHash, err := getHelmChartValuesHash(ctx, c, requestedChart, clusterSummary, mgmtResources, logger) if err != nil { - return err + return nil, err } err = retry.RetryOnConflict(retry.DefaultRetry, func() error { @@ -3602,7 +3608,7 @@ func updateValueHashOnHelmChartSummary(ctx context.Context, requestedChart *conf return c.Status().Update(ctx, currentClusterSummary) }) - return err + return helmChartValuesHash, err } // getValueHashFromHelmChartSummary returns the valueHash stored for this chart diff --git a/go.mod b/go.mod index f8dd8e26..bfaf12fd 100644 --- a/go.mod +++ b/go.mod @@ -18,7 +18,7 @@ require ( github.com/onsi/ginkgo/v2 v2.28.1 github.com/onsi/gomega v1.39.1 github.com/pkg/errors v0.9.1 - github.com/projectsveltos/libsveltos v1.4.1-0.20260130204733-fe2b5557bc98 + github.com/projectsveltos/libsveltos v1.4.1-0.20260131124754-dd6ff263bbb9 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 c04c42fa..4d43bbc8 100644 --- a/go.sum +++ b/go.sum @@ -279,8 +279,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.4.1-0.20260130204733-fe2b5557bc98 h1:EWYha0rddaGcVbAgVrAltyBsq4EHkMDaK8zPYzaJZCo= -github.com/projectsveltos/libsveltos v1.4.1-0.20260130204733-fe2b5557bc98/go.mod h1:Zr20iLkXujukoB9x1zjmYVULonScKUu1d7XIMU3Z5tU= +github.com/projectsveltos/libsveltos v1.4.1-0.20260131124754-dd6ff263bbb9 h1:5ldqgGt5IAg/HNZlzom6/WCugQfUIRheCdxjwmpq6ds= +github.com/projectsveltos/libsveltos v1.4.1-0.20260131124754-dd6ff263bbb9/go.mod h1:Zr20iLkXujukoB9x1zjmYVULonScKUu1d7XIMU3Z5tU= 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=