Postgres upgrade fails when installed on different directory
Description
Postgres upgrade fails when Postgres has been relocated to a different directory.
This particular case had another issue at https://gitlab.com/gitlab-org/omnibus-gitlab/issues/1929 in case its directly related.
Error output
root@aml00238 [/etc/gitlab] # gitlab-ctl pg-upgrade
Checking for an omnibus managed postgresql: OK
Checking version of running PostgreSQL: OK
Checking for a newer version of PostgreSQL to install: OK
Upgrading PostgreSQL to 9.6.1
Checking if existing PostgreSQL instances needs to be upgraded: OK
Checking if the PostgreSQL directory has been symlinked elsewhere: OK
Checking if PostgreSQL bin files are symlinked to the expected location: OK
Toggling deploy page:cp /opt/gitlab/embedded/service/gitlab-rails/public/deploy.html /opt/gitlab/embedded/service/gitlab-rails/public/index.html
Toggling deploy page: OK
Toggling servicesok down: logrotate: 1s, normally up
ok: down: sidekiq: 1s, normally up
Toggling services: OK
Waiting 30 seconds to ensure tasks complete before PostgreSQL upgrade
Please hit Ctrl-C now if you want to cancel the upgrade
Stopping the databaseok down: postgresql: 0s, normally up
Stopping the database: OK
Update the symlinks: OK
Creating temporary data directory: OK
Initializing the new database: OK
Upgrading the data:Could not run: /opt/gitlab/embedded/bin/pg_upgrade -b /opt/gitlab/embedded/postgresql/9.2.18/bin -d /var/opt/gitlab/postgresql/data -D /var/opt/gitlab/postgresql/data.9.6.1 -B /opt/gitlab/embedded/bin
STDOUT:
check for "/var/opt/gitlab/postgresql/data" failed: No such file or directory
Failure, exiting
STDERR:
== Fatal error ==
Please check the output and try again
== Reverting ==
ok: down: postgresql: 3s, normally up
ok: run: postgresql: (pid 12184) 1s
== Reverted ==
== Reverted to 9.2.18. Please check output for what went wrong ==
Toggling deploy page:rm -f /opt/gitlab/embedded/service/gitlab-rails/public/index.html
Toggling deploy page: OK
Toggling servicesok run: logrotate: (pid 12196) 0s
ok: run: sidekiq: (pid 12202) 0s
Toggling services: OK
/cc @ibaum