Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade flow for images RHEL/CentOS 8+ #562

Merged
merged 2 commits into from
Jun 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 14 additions & 5 deletions 10/root/usr/share/container-scripts/postgresql/common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@ function wait_for_postgresql_master() {
run_pgupgrade ()
(
# Remove .pid file if the file persists after ugly shut down
if [ -f "$PGDATA/postmaster.pid" ] && ! pgrep -f "postgres" > /dev/null; then
if [ -f "$PGDATA/postmaster.pid" ] && ! pg_isready > /dev/null; then
rm -rf "$PGDATA/postmaster.pid"
fi

Expand All @@ -311,8 +311,17 @@ run_pgupgrade ()
old_collection=rh-postgresql$old_raw_version
fi

old_pgengine=/opt/rh/$old_collection/root/usr/bin
new_pgengine=/opt/rh/rh-postgresql${new_raw_version}/root/usr/bin
# Backward compatibility for RHEL/CentOS 7
source /etc/os-release

if [[ $VERSION_ID -lt 8 ]]; then
old_pgengine=/opt/rh/$old_collection/root/usr/bin
new_pgengine=/opt/rh/rh-postgresql${new_raw_version}/root/usr/bin
else
old_pgengine=/usr/lib64/pgsql/postgresql-$old_raw_version/bin
new_pgengine=/usr/bin
fi

PGDATA_new="${PGDATA}-new"

printf >&2 "\n========== \$PGDATA upgrade: %s -> %s ==========\n\n" \
Expand Down Expand Up @@ -350,9 +359,9 @@ run_pgupgrade ()
# boot up data directory with old postgres once again to make sure
# it was shut down properly, otherwise the upgrade process fails
info_msg "Starting old postgresql once again for a clean shutdown..."
"${old_pgengine}/pg_ctl" start -w --timeout 86400 -o "-h ''"
"${old_pgengine}/pg_ctl" start -w --timeout 86400 -o "-h 127.0.0.1''"
info_msg "Waiting for postgresql to be ready for shutdown again..."
"${old_pgengine}/pg_isready"
"${old_pgengine}/pg_isready" -h 127.0.0.1
info_msg "Shutting down old postgresql cleanly..."
"${old_pgengine}/pg_ctl" stop

Expand Down
4 changes: 2 additions & 2 deletions 12/Dockerfile.fedora
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ COPY root/usr/libexec/fix-permissions /usr/libexec/fix-permissions
# This image must forever use UID 26 for postgres user so our volumes are
# safe in the future. This should *never* change, the last test is there
# to make sure of that.
RUN INSTALL_PKGS="rsync tar gettext bind-utils postgresql-server postgresql-contrib nss_wrapper " && \
INSTALL_PKGS+="findutils xz" && \
RUN INSTALL_PKGS="rsync tar gettext bind-utils postgresql-server postgresql-contrib nss_wrapper postgresql-upgrade procps-ng util-linux" && \
INSTALL_PKGS+=" findutils xz" && \
INSTALL_PKGS+=" pgaudit" && \
dnf -y module enable postgresql:12 && \
dnf -y --setopt=tsflags=nodocs install $INSTALL_PKGS && \
Expand Down
1 change: 1 addition & 0 deletions 12/Dockerfile.rhel8
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ COPY root/usr/libexec/fix-permissions /usr/libexec/fix-permissions
RUN yum -y module enable postgresql:12 && \
INSTALL_PKGS="rsync tar gettext bind-utils nss_wrapper postgresql-server postgresql-contrib" && \
INSTALL_PKGS="$INSTALL_PKGS pgaudit" && \
INSTALL_PKGS="$INSTALL_PKGS procps-ng util-linux postgresql-upgrade" && \
yum -y --setopt=tsflags=nodocs install $INSTALL_PKGS && \
rpm -V $INSTALL_PKGS && \
postgres -V | grep -qe "$POSTGRESQL_VERSION\." && echo "Found VERSION $POSTGRESQL_VERSION" && \
Expand Down
19 changes: 14 additions & 5 deletions 12/root/usr/share/container-scripts/postgresql/common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@ function wait_for_postgresql_master() {
run_pgupgrade ()
(
# Remove .pid file if the file persists after ugly shut down
if [ -f "$PGDATA/postmaster.pid" ] && ! pgrep -f "postgres" > /dev/null; then
if [ -f "$PGDATA/postmaster.pid" ] && ! pg_isready > /dev/null; then
rm -rf "$PGDATA/postmaster.pid"
fi

Expand All @@ -311,8 +311,17 @@ run_pgupgrade ()
old_collection=rh-postgresql$old_raw_version
fi

old_pgengine=/opt/rh/$old_collection/root/usr/bin
new_pgengine=/opt/rh/rh-postgresql${new_raw_version}/root/usr/bin
# Backward compatibility for RHEL/CentOS 7
source /etc/os-release

if [[ $VERSION_ID -lt 8 ]]; then
old_pgengine=/opt/rh/$old_collection/root/usr/bin
new_pgengine=/opt/rh/rh-postgresql${new_raw_version}/root/usr/bin
else
old_pgengine=/usr/lib64/pgsql/postgresql-$old_raw_version/bin
new_pgengine=/usr/bin
fi

PGDATA_new="${PGDATA}-new"

printf >&2 "\n========== \$PGDATA upgrade: %s -> %s ==========\n\n" \
Expand Down Expand Up @@ -350,9 +359,9 @@ run_pgupgrade ()
# boot up data directory with old postgres once again to make sure
# it was shut down properly, otherwise the upgrade process fails
info_msg "Starting old postgresql once again for a clean shutdown..."
"${old_pgengine}/pg_ctl" start -w --timeout 86400 -o "-h ''"
"${old_pgengine}/pg_ctl" start -w --timeout 86400 -o "-h 127.0.0.1''"
info_msg "Waiting for postgresql to be ready for shutdown again..."
"${old_pgengine}/pg_isready"
"${old_pgengine}/pg_isready" -h 127.0.0.1
info_msg "Shutting down old postgresql cleanly..."
"${old_pgengine}/pg_ctl" stop

Expand Down
1 change: 1 addition & 0 deletions 13/Dockerfile.c9s
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ COPY root/usr/libexec/fix-permissions /usr/libexec/fix-permissions
RUN { yum -y module enable postgresql:13 || :; } && \
INSTALL_PKGS="rsync tar gettext bind-utils nss_wrapper postgresql-server postgresql-contrib" && \
INSTALL_PKGS="$INSTALL_PKGS pgaudit" && \
INSTALL_PKGS="$INSTALL_PKGS procps-ng util-linux postgresql-upgrade" && \
yum -y --setopt=tsflags=nodocs install $INSTALL_PKGS && \
rpm -V $INSTALL_PKGS && \
postgres -V | grep -qe "$POSTGRESQL_VERSION\." && echo "Found VERSION $POSTGRESQL_VERSION" && \
Expand Down
4 changes: 2 additions & 2 deletions 13/Dockerfile.fedora
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ COPY root/usr/libexec/fix-permissions /usr/libexec/fix-permissions
# This image must forever use UID 26 for postgres user so our volumes are
# safe in the future. This should *never* change, the last test is there
# to make sure of that.
RUN INSTALL_PKGS="rsync tar gettext bind-utils postgresql-server postgresql-contrib nss_wrapper " && \
INSTALL_PKGS+="findutils xz" && \
RUN INSTALL_PKGS="rsync tar gettext bind-utils postgresql-server postgresql-contrib nss_wrapper postgresql-upgrade procps-ng util-linux" && \
INSTALL_PKGS+=" findutils xz" && \
INSTALL_PKGS+=" pgaudit" && \
dnf -y module enable postgresql:13 && \
dnf -y --setopt=tsflags=nodocs install $INSTALL_PKGS && \
Expand Down
1 change: 1 addition & 0 deletions 13/Dockerfile.rhel8
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ COPY root/usr/libexec/fix-permissions /usr/libexec/fix-permissions
RUN yum -y module enable postgresql:13 && \
INSTALL_PKGS="rsync tar gettext bind-utils nss_wrapper postgresql-server postgresql-contrib" && \
INSTALL_PKGS="$INSTALL_PKGS pgaudit" && \
INSTALL_PKGS="$INSTALL_PKGS procps-ng util-linux postgresql-upgrade" && \
yum -y --setopt=tsflags=nodocs install $INSTALL_PKGS && \
rpm -V $INSTALL_PKGS && \
postgres -V | grep -qe "$POSTGRESQL_VERSION\." && echo "Found VERSION $POSTGRESQL_VERSION" && \
Expand Down
1 change: 1 addition & 0 deletions 13/Dockerfile.rhel9
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ COPY root/usr/libexec/fix-permissions /usr/libexec/fix-permissions
RUN { yum -y module enable postgresql:13 || :; } && \
INSTALL_PKGS="rsync tar gettext bind-utils nss_wrapper postgresql-server postgresql-contrib" && \
INSTALL_PKGS="$INSTALL_PKGS pgaudit" && \
INSTALL_PKGS="$INSTALL_PKGS procps-ng util-linux postgresql-upgrade" && \
yum -y --setopt=tsflags=nodocs install $INSTALL_PKGS && \
rpm -V $INSTALL_PKGS && \
postgres -V | grep -qe "$POSTGRESQL_VERSION\." && echo "Found VERSION $POSTGRESQL_VERSION" && \
Expand Down
19 changes: 14 additions & 5 deletions 13/root/usr/share/container-scripts/postgresql/common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@ function wait_for_postgresql_master() {
run_pgupgrade ()
(
# Remove .pid file if the file persists after ugly shut down
if [ -f "$PGDATA/postmaster.pid" ] && ! pgrep -f "postgres" > /dev/null; then
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are you removing the condition? We do not want to remove .pid file of the running process

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So I removed it because I had some issues when I was testing the upgrade. I will look into it deeper.
we should check if the PID is up first

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so this is from a running container I added a stop before the line
seem that the service is not running, also there isn't any open socket

I'm assuming the it is partially match run-postgresql

bash-4.4$ pgrep -f "postgres" 
1
17

 ps -ef
UID          PID    PPID  C STIME TTY          TIME CMD
postgres       1       0  0 12:18 pts/0    00:00:00 /bin/bash /usr/bin/run-postgresql
postgres      17       1  0 12:18 pts/0    00:00:00 /bin/bash /usr/bin/run-postgresql
postgres      18      17  0 12:18 pts/0    00:00:00 /usr/bin/coreutils --coreutils-prog-shebang
postgres      19       0  0 12:19 pts/1    00:00:00 bash
postgres      27      19  0 12:22 pts/1    00:00:00 ps -ef

how about

Suggested change
if [ -f "$PGDATA/postmaster.pid" ] && ! pgrep -f "postgres" > /dev/null; then
if [ -f "$PGDATA/postmaster.pid" ] && ! pg_isready > /dev/null; then

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

changed

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

makes sense +1

if [ -f "$PGDATA/postmaster.pid" ] && ! pg_isready > /dev/null; then
rm -rf "$PGDATA/postmaster.pid"
fi

Expand All @@ -311,8 +311,17 @@ run_pgupgrade ()
old_collection=rh-postgresql$old_raw_version
fi

old_pgengine=/opt/rh/$old_collection/root/usr/bin
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This could be changed only for RHEL8+ images. The general change would cause problems in rhel7/centos7 containers. Condition needed in distgen source files.

new_pgengine=/opt/rh/rh-postgresql${new_raw_version}/root/usr/bin
# Backward compatibility for RHEL/CentOS 7
source /etc/os-release

if [[ $VERSION_ID -lt 8 ]]; then
old_pgengine=/opt/rh/$old_collection/root/usr/bin
new_pgengine=/opt/rh/rh-postgresql${new_raw_version}/root/usr/bin
else
old_pgengine=/usr/lib64/pgsql/postgresql-$old_raw_version/bin
new_pgengine=/usr/bin
fi

PGDATA_new="${PGDATA}-new"

printf >&2 "\n========== \$PGDATA upgrade: %s -> %s ==========\n\n" \
Expand Down Expand Up @@ -350,9 +359,9 @@ run_pgupgrade ()
# boot up data directory with old postgres once again to make sure
# it was shut down properly, otherwise the upgrade process fails
info_msg "Starting old postgresql once again for a clean shutdown..."
"${old_pgengine}/pg_ctl" start -w --timeout 86400 -o "-h ''"
"${old_pgengine}/pg_ctl" start -w --timeout 86400 -o "-h 127.0.0.1''"
info_msg "Waiting for postgresql to be ready for shutdown again..."
"${old_pgengine}/pg_isready"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are you removing this safety procedure?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On my testing it returned exit code 2 - I did manual checks the socket was up and running but the pg_isready wasn't catching it.
On the above line we use -w which is waiting for the DB to be ready. I thought maybe we don't need to double check it unless there is another reason for it?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

after some searching, It seems we start the server as local only -- which mean it doesn't create a TCP port instead it creates a Linux socket.

the 'pg_isready' tries the port and fails

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1

"${old_pgengine}/pg_isready" -h 127.0.0.1
info_msg "Shutting down old postgresql cleanly..."
"${old_pgengine}/pg_ctl" stop

Expand Down
4 changes: 2 additions & 2 deletions 14/Dockerfile.fedora
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ COPY root/usr/libexec/fix-permissions /usr/libexec/fix-permissions
# This image must forever use UID 26 for postgres user so our volumes are
# safe in the future. This should *never* change, the last test is there
# to make sure of that.
RUN INSTALL_PKGS="rsync tar gettext bind-utils postgresql-server postgresql-contrib nss_wrapper " && \
INSTALL_PKGS+="findutils xz" && \
RUN INSTALL_PKGS="rsync tar gettext bind-utils postgresql-server postgresql-contrib nss_wrapper postgresql-upgrade procps-ng util-linux" && \
INSTALL_PKGS+=" findutils xz" && \
INSTALL_PKGS+=" pgaudit" && \
dnf -y module enable postgresql:14 && \
dnf -y --setopt=tsflags=nodocs install $INSTALL_PKGS && \
Expand Down
19 changes: 14 additions & 5 deletions 14/root/usr/share/container-scripts/postgresql/common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@ function wait_for_postgresql_master() {
run_pgupgrade ()
(
# Remove .pid file if the file persists after ugly shut down
if [ -f "$PGDATA/postmaster.pid" ] && ! pgrep -f "postgres" > /dev/null; then
if [ -f "$PGDATA/postmaster.pid" ] && ! pg_isready > /dev/null; then
rm -rf "$PGDATA/postmaster.pid"
fi

Expand All @@ -311,8 +311,17 @@ run_pgupgrade ()
old_collection=rh-postgresql$old_raw_version
fi

old_pgengine=/opt/rh/$old_collection/root/usr/bin
new_pgengine=/opt/rh/rh-postgresql${new_raw_version}/root/usr/bin
# Backward compatibility for RHEL/CentOS 7
source /etc/os-release

if [[ $VERSION_ID -lt 8 ]]; then
old_pgengine=/opt/rh/$old_collection/root/usr/bin
new_pgengine=/opt/rh/rh-postgresql${new_raw_version}/root/usr/bin
else
old_pgengine=/usr/lib64/pgsql/postgresql-$old_raw_version/bin
new_pgengine=/usr/bin
fi

PGDATA_new="${PGDATA}-new"

printf >&2 "\n========== \$PGDATA upgrade: %s -> %s ==========\n\n" \
Expand Down Expand Up @@ -350,9 +359,9 @@ run_pgupgrade ()
# boot up data directory with old postgres once again to make sure
# it was shut down properly, otherwise the upgrade process fails
info_msg "Starting old postgresql once again for a clean shutdown..."
"${old_pgengine}/pg_ctl" start -w --timeout 86400 -o "-h ''"
"${old_pgengine}/pg_ctl" start -w --timeout 86400 -o "-h 127.0.0.1''"
info_msg "Waiting for postgresql to be ready for shutdown again..."
"${old_pgengine}/pg_isready"
"${old_pgengine}/pg_isready" -h 127.0.0.1
info_msg "Shutting down old postgresql cleanly..."
"${old_pgengine}/pg_ctl" stop

Expand Down
1 change: 1 addition & 0 deletions 15/Dockerfile.c9s
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ COPY root/usr/libexec/fix-permissions /usr/libexec/fix-permissions
RUN { yum -y module enable postgresql:15 || :; } && \
INSTALL_PKGS="rsync tar gettext bind-utils nss_wrapper postgresql-server postgresql-contrib" && \
INSTALL_PKGS="$INSTALL_PKGS pgaudit" && \
INSTALL_PKGS="$INSTALL_PKGS procps-ng util-linux postgresql-upgrade" && \
yum -y --setopt=tsflags=nodocs install $INSTALL_PKGS && \
rpm -V $INSTALL_PKGS && \
postgres -V | grep -qe "$POSTGRESQL_VERSION\." && echo "Found VERSION $POSTGRESQL_VERSION" && \
Expand Down
4 changes: 2 additions & 2 deletions 15/Dockerfile.fedora
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ COPY root/usr/libexec/fix-permissions /usr/libexec/fix-permissions
# This image must forever use UID 26 for postgres user so our volumes are
# safe in the future. This should *never* change, the last test is there
# to make sure of that.
RUN INSTALL_PKGS="rsync tar gettext bind-utils postgresql-server postgresql-contrib nss_wrapper " && \
INSTALL_PKGS+="findutils xz" && \
RUN INSTALL_PKGS="rsync tar gettext bind-utils postgresql-server postgresql-contrib nss_wrapper postgresql-upgrade procps-ng util-linux" && \
INSTALL_PKGS+=" findutils xz" && \
INSTALL_PKGS+=" pgaudit" && \
dnf -y module enable postgresql:15 && \
dnf -y --setopt=tsflags=nodocs install $INSTALL_PKGS && \
Expand Down
1 change: 1 addition & 0 deletions 15/Dockerfile.rhel8
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ COPY root/usr/libexec/fix-permissions /usr/libexec/fix-permissions
RUN yum -y module enable postgresql:15 && \
INSTALL_PKGS="rsync tar gettext bind-utils nss_wrapper postgresql-server postgresql-contrib" && \
INSTALL_PKGS="$INSTALL_PKGS pgaudit" && \
INSTALL_PKGS="$INSTALL_PKGS procps-ng util-linux postgresql-upgrade" && \
yum -y --setopt=tsflags=nodocs install $INSTALL_PKGS && \
rpm -V $INSTALL_PKGS && \
postgres -V | grep -qe "$POSTGRESQL_VERSION\." && echo "Found VERSION $POSTGRESQL_VERSION" && \
Expand Down
1 change: 1 addition & 0 deletions 15/Dockerfile.rhel9
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ COPY root/usr/libexec/fix-permissions /usr/libexec/fix-permissions
RUN { yum -y module enable postgresql:15 || :; } && \
INSTALL_PKGS="rsync tar gettext bind-utils nss_wrapper postgresql-server postgresql-contrib" && \
INSTALL_PKGS="$INSTALL_PKGS pgaudit" && \
INSTALL_PKGS="$INSTALL_PKGS procps-ng util-linux postgresql-upgrade" && \
yum -y --setopt=tsflags=nodocs install $INSTALL_PKGS && \
rpm -V $INSTALL_PKGS && \
postgres -V | grep -qe "$POSTGRESQL_VERSION\." && echo "Found VERSION $POSTGRESQL_VERSION" && \
Expand Down
19 changes: 14 additions & 5 deletions 15/root/usr/share/container-scripts/postgresql/common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@ function wait_for_postgresql_master() {
run_pgupgrade ()
(
# Remove .pid file if the file persists after ugly shut down
if [ -f "$PGDATA/postmaster.pid" ] && ! pgrep -f "postgres" > /dev/null; then
if [ -f "$PGDATA/postmaster.pid" ] && ! pg_isready > /dev/null; then
rm -rf "$PGDATA/postmaster.pid"
fi

Expand All @@ -311,8 +311,17 @@ run_pgupgrade ()
old_collection=rh-postgresql$old_raw_version
fi

old_pgengine=/opt/rh/$old_collection/root/usr/bin
new_pgengine=/opt/rh/rh-postgresql${new_raw_version}/root/usr/bin
# Backward compatibility for RHEL/CentOS 7
source /etc/os-release

if [[ $VERSION_ID -lt 8 ]]; then
old_pgengine=/opt/rh/$old_collection/root/usr/bin
new_pgengine=/opt/rh/rh-postgresql${new_raw_version}/root/usr/bin
else
old_pgengine=/usr/lib64/pgsql/postgresql-$old_raw_version/bin
new_pgengine=/usr/bin
fi

PGDATA_new="${PGDATA}-new"

printf >&2 "\n========== \$PGDATA upgrade: %s -> %s ==========\n\n" \
Expand Down Expand Up @@ -350,9 +359,9 @@ run_pgupgrade ()
# boot up data directory with old postgres once again to make sure
# it was shut down properly, otherwise the upgrade process fails
info_msg "Starting old postgresql once again for a clean shutdown..."
"${old_pgengine}/pg_ctl" start -w --timeout 86400 -o "-h ''"
"${old_pgengine}/pg_ctl" start -w --timeout 86400 -o "-h 127.0.0.1''"
info_msg "Waiting for postgresql to be ready for shutdown again..."
"${old_pgengine}/pg_isready"
"${old_pgengine}/pg_isready" -h 127.0.0.1
info_msg "Shutting down old postgresql cleanly..."
"${old_pgengine}/pg_ctl" stop

Expand Down
1 change: 1 addition & 0 deletions 16/Dockerfile.c9s
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ COPY root/usr/libexec/fix-permissions /usr/libexec/fix-permissions
RUN { yum -y module enable postgresql:16 || :; } && \
INSTALL_PKGS="rsync tar gettext bind-utils nss_wrapper postgresql-server postgresql-contrib" && \
INSTALL_PKGS="$INSTALL_PKGS pgaudit" && \
INSTALL_PKGS="$INSTALL_PKGS procps-ng util-linux postgresql-upgrade" && \
yum -y --setopt=tsflags=nodocs install $INSTALL_PKGS && \
rpm -V $INSTALL_PKGS && \
postgres -V | grep -qe "$POSTGRESQL_VERSION\." && echo "Found VERSION $POSTGRESQL_VERSION" && \
Expand Down
3 changes: 2 additions & 1 deletion 16/Dockerfile.fedora
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@ COPY root/usr/libexec/fix-permissions /usr/libexec/fix-permissions
# safe in the future. This should *never* change, the last test is there
# to make sure of that.
RUN INSTALL_PKGS="rsync tar gettext bind-utils postgresql16-server postgresql16-contrib nss_wrapper " && \
INSTALL_PKGS+="findutils xz" && \
INSTALL_PKGS+=" procps-ng util-linux postgresql16-upgrade" && \
INSTALL_PKGS+=" findutils xz" && \
INSTALL_PKGS+=" postgresql16-pgaudit" && \
dnf -y --setopt=tsflags=nodocs install $INSTALL_PKGS && \
rpm -V $INSTALL_PKGS && \
Expand Down
1 change: 1 addition & 0 deletions 16/Dockerfile.rhel8
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ COPY root/usr/libexec/fix-permissions /usr/libexec/fix-permissions
RUN yum -y module enable postgresql:16 && \
INSTALL_PKGS="rsync tar gettext bind-utils nss_wrapper postgresql-server postgresql-contrib" && \
INSTALL_PKGS="$INSTALL_PKGS pgaudit" && \
INSTALL_PKGS="$INSTALL_PKGS procps-ng util-linux postgresql-upgrade" && \
yum -y --setopt=tsflags=nodocs install $INSTALL_PKGS && \
rpm -V $INSTALL_PKGS && \
postgres -V | grep -qe "$POSTGRESQL_VERSION\." && echo "Found VERSION $POSTGRESQL_VERSION" && \
Expand Down
1 change: 1 addition & 0 deletions 16/Dockerfile.rhel9
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ COPY root/usr/libexec/fix-permissions /usr/libexec/fix-permissions
RUN { yum -y module enable postgresql:16 || :; } && \
INSTALL_PKGS="rsync tar gettext bind-utils nss_wrapper postgresql-server postgresql-contrib" && \
INSTALL_PKGS="$INSTALL_PKGS pgaudit" && \
INSTALL_PKGS="$INSTALL_PKGS procps-ng util-linux postgresql-upgrade" && \
yum -y --setopt=tsflags=nodocs install $INSTALL_PKGS && \
rpm -V $INSTALL_PKGS && \
postgres -V | grep -qe "$POSTGRESQL_VERSION\." && echo "Found VERSION $POSTGRESQL_VERSION" && \
Expand Down
19 changes: 14 additions & 5 deletions 16/root/usr/share/container-scripts/postgresql/common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@ function wait_for_postgresql_master() {
run_pgupgrade ()
(
# Remove .pid file if the file persists after ugly shut down
if [ -f "$PGDATA/postmaster.pid" ] && ! pgrep -f "postgres" > /dev/null; then
if [ -f "$PGDATA/postmaster.pid" ] && ! pg_isready > /dev/null; then
rm -rf "$PGDATA/postmaster.pid"
fi

Expand All @@ -311,8 +311,17 @@ run_pgupgrade ()
old_collection=rh-postgresql$old_raw_version
fi

old_pgengine=/opt/rh/$old_collection/root/usr/bin
new_pgengine=/opt/rh/rh-postgresql${new_raw_version}/root/usr/bin
# Backward compatibility for RHEL/CentOS 7
source /etc/os-release

if [[ $VERSION_ID -lt 8 ]]; then
old_pgengine=/opt/rh/$old_collection/root/usr/bin
new_pgengine=/opt/rh/rh-postgresql${new_raw_version}/root/usr/bin
else
old_pgengine=/usr/lib64/pgsql/postgresql-$old_raw_version/bin
new_pgengine=/usr/bin
fi

PGDATA_new="${PGDATA}-new"

printf >&2 "\n========== \$PGDATA upgrade: %s -> %s ==========\n\n" \
Expand Down Expand Up @@ -350,9 +359,9 @@ run_pgupgrade ()
# boot up data directory with old postgres once again to make sure
# it was shut down properly, otherwise the upgrade process fails
info_msg "Starting old postgresql once again for a clean shutdown..."
"${old_pgengine}/pg_ctl" start -w --timeout 86400 -o "-h ''"
"${old_pgengine}/pg_ctl" start -w --timeout 86400 -o "-h 127.0.0.1''"
info_msg "Waiting for postgresql to be ready for shutdown again..."
"${old_pgengine}/pg_isready"
"${old_pgengine}/pg_isready" -h 127.0.0.1
info_msg "Shutting down old postgresql cleanly..."
"${old_pgengine}/pg_ctl" stop

Expand Down
1 change: 1 addition & 0 deletions src/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ RUN {{ spec.environment_setup }}
INSTALL_PKGS="$INSTALL_PKGS rh-postgresql{{ spec.short }}-pgaudit" && \
{% elif spec.prod == 'rhel8' or spec.prod == 'rhel9' or spec.prod == 'c9s' %}
INSTALL_PKGS="$INSTALL_PKGS pgaudit" && \
INSTALL_PKGS="$INSTALL_PKGS procps-ng util-linux postgresql-upgrade" && \
{% endif %}
{% endif %}
yum -y --setopt=tsflags=nodocs install $INSTALL_PKGS && \
Expand Down
Loading