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

The Bitnami patch #66

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open

The Bitnami patch #66

wants to merge 3 commits into from

Conversation

andyundso
Copy link
Member

From what I read at #21, it is currently not possible to use pgautoupgrade when using a Bitnami container before, as:

  1. postgresql.conf and pg_hba.conf files are missing.
  2. If using "one shot" mode, the file permissions are incorrect after pgautoupgrade ran.

The first issue was trivial fix: Provide default files for this case in the container (sadly the Postgres installation does only contain incomplete sample files).

The second one was more difficult: The default entrypoint script downgrades itself from root to the postgres. Part of it is a security concern, but also postgres commands without password cannot be executed when running as root user.

I did not want to mess with the entrypoint script too much, so I instead opted to create a new entrypoint script, which keeps track of the two files mentioned earlier, as well as the existing permissions on the Postgres data directory. This script keeps its root permissions, so re-applying the permissions should be possible. Then it invokes the previous entrypoint script. Once the container terminates and "one shot" mode is enabled, the previous permissions are re-applied.

I also added some additional documentation about this behaviour in the README, as well as an additional test that booting up an empty pgautoupgrade container works, since starting an empty container takes quite a different path in the entrypoint script, and I wanted to make sure that this still works.

@andyundso andyundso force-pushed the fix-with-bitnami-image branch from 03f543d to 4d84608 Compare November 14, 2024 16:22
Comment on lines +150 to +154
# Copy default configuration in case the original container does not provide it (Bitnami ...)
RUN mkdir -p /opt/pgautoupgrade && \
chmod 660 /opt/pgautoupgrade && \
chown 999:999 /opt/pgautoupgrade
COPY --chown=999 postgresql.conf pg_hba.conf /opt/pgautoupgrade/
Copy link
Member Author

Choose a reason for hiding this comment

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

as an alternative to the copy process, we could also invoke pg_setup_hba_conf() in the entrypoint.sh to generate a valid pg_hba.conf. postgresql.conf I am not sure ...

@andyundso
Copy link
Member Author

Hi @justinclift, you mentioned you have quite a lot of work on your table. not sure if that is still the case, otherwise I would appreciate a review on this PR.

Copy link
Member

@spwoodcock spwoodcock left a comment

Choose a reason for hiding this comment

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

Nice PR 😄

This looks good to me on reviewing the code, but I'm not in a position to test currently! I can hopefully test in a few days to verify the upgrade works as intended.

But it's a small change & you have a test included, so I'm pretty confident this should be fine!

@justinclift
Copy link
Member

not sure if that is still the case

Unfortunately yeah. Life is quite challenging at the moment. 😦

In theory, I should start having a bit of free time next week though. Should be able to start
catching up on stuff like this then. 😄

@justinclift
Copy link
Member

justinclift commented Dec 14, 2024

Sorry for the lack of response. Should actually have time late next week, as I'm finishing up some unrelated stuff this week.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants