Skip to content

Commit acb3ffd

Browse files
authored
Fix upgrade command (zalando#2075)
Upgrade run using postgres user used to be broken by an invalid option. Move -o pipefail directly to upgradeCommand. + minor formatting corrections
1 parent a85023f commit acb3ffd

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

pkg/cluster/majorversionupgrade.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -57,10 +57,10 @@ func (c *Cluster) isUpgradeAllowedForTeam(owningTeam string) bool {
5757
}
5858

5959
/*
60-
Execute upgrade when mode is set to manual or full or when the owning team is allowed for upgrade (and mode is "off").
60+
Execute upgrade when mode is set to manual or full or when the owning team is allowed for upgrade (and mode is "off").
6161
62-
Manual upgrade means, it is triggered by the user via manifest version change
63-
Full upgrade means, operator also determines the minimal version used accross all clusters and upgrades violators.
62+
Manual upgrade means, it is triggered by the user via manifest version change
63+
Full upgrade means, operator also determines the minimal version used accross all clusters and upgrades violators.
6464
*/
6565
func (c *Cluster) majorVersionUpgrade() error {
6666

@@ -105,8 +105,8 @@ func (c *Cluster) majorVersionUpgrade() error {
105105
podName := &spec.NamespacedName{Namespace: masterPod.Namespace, Name: masterPod.Name}
106106
c.logger.Infof("triggering major version upgrade on pod %s of %d pods", masterPod.Name, numberOfPods)
107107
c.eventRecorder.Eventf(c.GetReference(), v1.EventTypeNormal, "Major Version Upgrade", "Starting major version upgrade on pod %s of %d pods", masterPod.Name, numberOfPods)
108-
upgradeCommand := fmt.Sprintf("/usr/bin/python3 /scripts/inplace_upgrade.py %d 2>&1 | tee last_upgrade.log", numberOfPods)
109-
108+
upgradeCommand := fmt.Sprintf("set -o pipefail && /usr/bin/python3 /scripts/inplace_upgrade.py %d 2>&1 | tee last_upgrade.log", numberOfPods)
109+
110110
c.logger.Debugf("checking if the spilo image runs with root or non-root (check for user id=0)")
111111
resultIdCheck, errIdCheck := c.ExecCommand(podName, "/bin/bash", "-c", "/usr/bin/id -u")
112112
if errIdCheck != nil {
@@ -117,10 +117,10 @@ func (c *Cluster) majorVersionUpgrade() error {
117117
var result string
118118
if resultIdCheck != "0" {
119119
c.logger.Infof("User id was identified as: %s, hence default user is non-root already", resultIdCheck)
120-
result, err = c.ExecCommand(podName, "/bin/bash", "-o", "pipefail", "-c", upgradeCommand)
120+
result, err = c.ExecCommand(podName, "/bin/bash", "-c", upgradeCommand)
121121
} else {
122122
c.logger.Infof("User id was identified as: %s, using su to reach the postgres user", resultIdCheck)
123-
result, err = c.ExecCommand(podName, "/bin/su", "postgres", "-o", "pipefail", "-c", upgradeCommand)
123+
result, err = c.ExecCommand(podName, "/bin/su", "postgres", "-c", upgradeCommand)
124124
}
125125
if err != nil {
126126
c.eventRecorder.Eventf(c.GetReference(), v1.EventTypeWarning, "Major Version Upgrade", "Upgrade from %d to %d FAILED: %v", c.currentMajorVersion, desiredVersion, err)

0 commit comments

Comments
 (0)