From 0b9ffc2dd482681629a5429da3aeca029edf3ecb Mon Sep 17 00:00:00 2001 From: Polina Bungina Date: Tue, 15 Oct 2024 12:39:09 +0200 Subject: [PATCH 1/2] Skip major upgrade for standby clusters with warning --- pkg/cluster/majorversionupgrade.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/pkg/cluster/majorversionupgrade.go b/pkg/cluster/majorversionupgrade.go index e8876dc49..93825839d 100644 --- a/pkg/cluster/majorversionupgrade.go +++ b/pkg/cluster/majorversionupgrade.go @@ -145,6 +145,11 @@ func (c *Cluster) majorVersionUpgrade() error { for i, pod := range pods { ps, _ := c.patroni.GetMemberData(&pod) + if ps.Role == "standby_leader" { + c.logger.Errorf("skipping major version upgrade for %s/%s standby cluster. Re-deploy standby cluster with the required Postgres version specified", c.Namespace, c.Name) + return nil + } + if ps.State != "running" { allRunning = false c.logger.Infof("identified non running pod, potentially skipping major version upgrade") From 4c79f9f06bd181da96417969e9f9b9382ac59502 Mon Sep 17 00:00:00 2001 From: Polina Bungina Date: Tue, 15 Oct 2024 13:12:19 +0200 Subject: [PATCH 2/2] Check when no master in the cluster as well --- pkg/cluster/majorversionupgrade.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/pkg/cluster/majorversionupgrade.go b/pkg/cluster/majorversionupgrade.go index 93825839d..ad431acc4 100644 --- a/pkg/cluster/majorversionupgrade.go +++ b/pkg/cluster/majorversionupgrade.go @@ -161,6 +161,11 @@ func (c *Cluster) majorVersionUpgrade() error { } } + if masterPod == nil { + c.logger.Infof("no master in the cluster, skipping major version upgrade") + return nil + } + // Recheck version with newest data from Patroni if c.currentMajorVersion >= desiredVersion { if _, exists := c.ObjectMeta.Annotations[majorVersionUpgradeFailureAnnotation]; exists { // if failure annotation exists, remove it