From e8a9c009d4d9c35d42a9a25f890eeafc8cf6b301 Mon Sep 17 00:00:00 2001 From: Yury Kovalev Date: Mon, 2 Dec 2024 15:02:35 +0100 Subject: [PATCH] Fix addon backoff --- internal/dinosaur/pkg/services/addon.go | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/internal/dinosaur/pkg/services/addon.go b/internal/dinosaur/pkg/services/addon.go index 846e8f911..616773345 100644 --- a/internal/dinosaur/pkg/services/addon.go +++ b/internal/dinosaur/pkg/services/addon.go @@ -96,7 +96,7 @@ func (p *AddonProvisioner) Provision(cluster api.Cluster, dataplaneClusterConfig for _, installedAddon := range installedAddons { // addon is installed on the cluster but not present in gitops config - uninstall it errs = append(errs, p.uninstallAddon(cluster.ClusterID, installedAddon.ID)) - p.updateAddonStatusMetric(installedAddon.ID, dataplaneClusterConfig.ClusterName, metrics.AddonHealthy) + p.updateAddonStatus(installedAddon.ID, dataplaneClusterConfig.ClusterName, metrics.AddonHealthy) } return errors.Join(errs...) @@ -113,7 +113,7 @@ func (p *AddonProvisioner) provisionAddon(dataplaneClusterConfig gitops.DataPlan if provisionError != nil { status = metrics.AddonUnhealthy } - p.updateAddonStatusMetric(expectedConfig.ID, dataplaneClusterConfig.ClusterName, status) + p.updateAddonStatus(expectedConfig.ID, dataplaneClusterConfig.ClusterName, status) }() if addonErr != nil { @@ -251,7 +251,7 @@ func (p *AddonProvisioner) updateAddon(clusterID string, config gitops.AddonConf } func (p *AddonProvisioner) backoffUpgradeRequest() bool { - return p.lastStatus == metrics.AddonUpgrade && time.Since(p.lastUpgradeRequestTime) < addonUpgradeBackoff + return p.lastStatus != metrics.AddonHealthy && time.Since(p.lastUpgradeRequestTime) < addonUpgradeBackoff } func (p *AddonProvisioner) uninstallAddon(clusterID string, addonID string) error { @@ -262,10 +262,11 @@ func (p *AddonProvisioner) uninstallAddon(clusterID string, addonID string) erro return nil } -func (p *AddonProvisioner) updateAddonStatusMetric(addonID string, clusterName string, status metrics.AddonStatus) { +func (p *AddonProvisioner) updateAddonStatus(addonID string, clusterName string, status metrics.AddonStatus) { if p.updateAddonStatusMetricFunc != nil { p.updateAddonStatusMetricFunc(addonID, clusterName, status) } + p.lastStatus = status } func isFinalState(state clustersmgmtv1.AddOnInstallationState) bool {