@@ -21,6 +21,7 @@ import (
2121 "github.com/crunchydata/postgres-operator/internal/feature"
2222 "github.com/crunchydata/postgres-operator/internal/initialize"
2323 "github.com/crunchydata/postgres-operator/internal/naming"
24+ "github.com/crunchydata/postgres-operator/internal/postgres"
2425 "github.com/crunchydata/postgres-operator/internal/shell"
2526 "github.com/crunchydata/postgres-operator/pkg/apis/postgres-operator.crunchydata.com/v1beta1"
2627)
@@ -80,11 +81,14 @@ func upgradeCommand(spec *v1beta1.PGUpgradeSettings, fetchKeyCommand string) []s
8081 // - https://cwrap.org/nss_wrapper.html
8182 `export LD_PRELOAD='libnss_wrapper.so' NSS_WRAPPER_GROUP NSS_WRAPPER_PASSWD` ,
8283
83- // Expect Postgres executables at the Red Hat paths.
84+ // Find directories that contain the desired Postgres executables.
85+ `old_bin=$(` + postgres .ShellPath (oldVersion ) + ` && command -v postgres)` ,
86+ `old_bin="${old_bin%/postgres}"` ,
87+ `new_bin=$(` + postgres .ShellPath (newVersion ) + ` && command -v initdb)` ,
88+ `new_bin="${new_bin%/initdb}"` ,
89+
8490 `old_data="${data_volume}/pg${old_version}"` ,
8591 `new_data="${data_volume}/pg${new_version}"` ,
86- `old_bin="/usr/pgsql-${old_version}/bin"` ,
87- `new_bin="/usr/pgsql-${new_version}/bin"` ,
8892
8993 // Below is the pg_upgrade script used to upgrade a PostgresCluster from
9094 // one major version to another. Additional information concerning the
@@ -243,7 +247,7 @@ func removeDataCommand(upgrade *v1beta1.PGUpgrade) []string {
243247 `delete() (set -x && rm -rf -- "$@")` ,
244248
245249 `old_data="${data_volume}/pg${old_version}"` ,
246- `control=$(LC_ALL=C /usr/pgsql-${old_version}/bin/ pg_controldata "${old_data}")` ,
250+ `control=$(` + postgres . ShellPath ( oldVersion ) + ` && LC_ALL=C pg_controldata "${old_data}")` ,
247251 `read -r state <<< "${control##*cluster state:}"` ,
248252
249253 // We expect exactly one state for a replica that has been stopped.
0 commit comments