From c25dc57b9614df4a89e08c9c766b6f6ee64fb41f Mon Sep 17 00:00:00 2001 From: Ida Novindasari Date: Tue, 10 Sep 2024 10:32:56 +0200 Subject: [PATCH] only skip upgrade if failed before after recheck version (#2755) --- pkg/cluster/majorversionupgrade.go | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/pkg/cluster/majorversionupgrade.go b/pkg/cluster/majorversionupgrade.go index f51e42415..1c5a670eb 100644 --- a/pkg/cluster/majorversionupgrade.go +++ b/pkg/cluster/majorversionupgrade.go @@ -127,11 +127,6 @@ func (c *Cluster) majorVersionUpgrade() error { return nil } - if _, exists := c.ObjectMeta.Annotations[majorVersionUpgradeFailureAnnotation]; exists { - c.logger.Infof("last major upgrade failed, skipping upgrade") - return nil - } - if !isInMainternanceWindow(c.Spec.MaintenanceWindows) { c.logger.Infof("skipping major version upgrade, not in maintenance window") return nil @@ -162,10 +157,19 @@ func (c *Cluster) majorVersionUpgrade() error { // Recheck version with newest data from Patroni if c.currentMajorVersion >= desiredVersion { + if _, exists := c.ObjectMeta.Annotations[majorVersionUpgradeFailureAnnotation]; exists { // if failure annotation exists, remove it + c.removeFailuresAnnotation() + c.logger.Infof("removing failure annotation as the cluster is already up to date") + } c.logger.Infof("recheck cluster version is already up to date. current: %d, min desired: %d", c.currentMajorVersion, desiredVersion) return nil } + if _, exists := c.ObjectMeta.Annotations[majorVersionUpgradeFailureAnnotation]; exists { + c.logger.Infof("last major upgrade failed, skipping upgrade") + return nil + } + isUpgradeSuccess := true numberOfPods := len(pods) if allRunning && masterPod != nil {