-
Notifications
You must be signed in to change notification settings - Fork 217
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
Source to image #208
Source to image #208
Conversation
f57438e
to
1b2f764
Compare
latest/root/usr/bin/run-postgresql
Outdated
@@ -22,12 +22,17 @@ else | |||
try_pgupgrade | |||
fi | |||
|
|||
process_extending_files ${APP_DATA}/src/pre-init ${CONTAINER_SCRIPTS_PATH}/pre-init |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This call should also be added to run-postgresql-slave
|
||
##### `postgresql-config/` | ||
|
||
when running `run-service` command contained |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would restate a bit differently since right now it seems a bit confusing. Something along the lines of:
The postgresql.conf
configuration file contained in this folder is used instead of the default configuration when postgresql
is started
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This sounds bad to me. Shouldn't we again rather only "include" (additional?) configuration file into the default postgresql.conf?
@praiskup Please take a look as well |
I wonder... Would this work for the Fedora version out of the box as well? |
|
||
|
||
``` | ||
$ s2i build --assemble-user root ~/image-configuration/ postgresql new-postgresql |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is --asemble-user root
realistically useable in openshift? Shouldn't we rather avoid root user at all?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
User root is in this solution is used only for building the image using s2i. When the built container is run, it is under postgre user who is only in group postgre.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So is this really commonly enabled feature in OpenShift, so we can make it a "general" requirement? It seems to be pretty dangerous to get root access, even during the build..
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Other possibility is to add postgres user to root group (as is done e.g in mysql https://github.com/sclorg/mysql-container/blob/master/root-common/usr/libexec/container-setup#L58) but I can't help, it doesn't feel right. I think this issue deserves more discussion. @praiskup @hhorak what do you think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To better understand, what exactly is the 'root' needed for?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually, that is really good question! The problem with missing write permission (that caused failed s2i builds) on /opt/app-root/src is now managed in Dockerfiles with https://github.com/sclorg/postgresql-container/pull/208/files#diff-4040b6e79b7069db62e62fee9e5c3532R72. fix-permissions might fail, but the build finishes successfully. Thank you for making this comment and standing your ground! :)
# ----------------------------- | ||
# PostgreSQL configuration file | ||
# ----------------------------- | ||
# |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This example configuration file should be few-lines long only (this file is actually generated at postgresql build-time, and as such it would get staled very soon) and do something real.. and be included into the maint postgresql.conf
file, or possibly transitively included through the configuration generated by our scripts...
@pkubatrh yes, it should also work with fedora, but I ran into a problem with python2 package: Steps to reproduce:
Do you know something about this? Could you, please, help me resolve this so I can rebase and apply s2i also to fedora image? |
@dhodovsk What exactly is the issue? Python 2.7 is installed, only the package is not named python2, just python (old style naming). In any case the postgresql image should not be based on s2i-base at all. It is an oversight that is already fixed in master. It should be based on s2i-core, which is unfortunately not yet built. (sclorg/s2i-base-container#144) |
@pkubatrh the issue occurred while verifying INSTALED_PKGS - https://github.com/sclorg/postgresql-container/blob/master/latest/Dockerfile.fedora#L51. It works with registry.fedoraproject.org/fedora:26 but not with registry.fedoraproject.org/f25/s2i-base:latest bash. I don't know the python background in fedora but it seemed interesting. Anyway I built fedora s2i-core locally and used it in fedora image with s2i here and it went ok. |
bd05c52
to
f58b86e
Compare
latest/s2i/bin/run
Outdated
@@ -0,0 +1,3 @@ | |||
#!/bin/bash | |||
|
|||
/usr/bin/run-postgresql |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can this be symlink to /usr/bin/run-postgresql
?
@praiskup please review discussed changes, there is another example of handling permissions for ${APP_DATA} here: https://github.com/sclorg/varnish-container/blob/master/4/Dockerfile#L46 |
#!/bin/bash | ||
|
||
# postgresql image encrypts user passwords at service start | ||
# the functionality can be disabled by providing this file (start-hook/set_passwords.sh) in s2i build |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing newline.
latest/root/usr/bin/run-postgresql
Outdated
pg_ctl -w start -o "-h ''" | ||
if $PG_INITIALIZED ; then | ||
process_extending_files ${APP_DATA}/src/init-hook ${CONTAINER_SCRIPTS_PATH}/init-hook |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could we name it init
only, or init-hooks
?
latest/Dockerfile
Outdated
@@ -67,6 +69,8 @@ ENV BASH_ENV=${CONTAINER_SCRIPTS_PATH}/scl_enable \ | |||
|
|||
VOLUME ["/var/lib/pgsql/data"] | |||
|
|||
# {APP_DATA} needs to be accessed by postgres user while s2i assembling | |||
RUN chown -R 26:0 ${APP_DATA} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
chmod -R og+rwx
should be probably used too
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I meant chmod -R ug+rwx
.
latest/Dockerfile.rhel7
Outdated
@@ -1,4 +1,4 @@ | |||
FROM rhel7 | |||
FROM rhscl/s2i-core-rhel7:1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
typo :1
suffix
wait_for_postgresql_master | ||
export MASTER_FQDN=$(postgresql_master_addr) | ||
initialize_replica | ||
|
||
process_extending_files ${APP_DATA}/src/init ${CONTAINER_SCRIPTS_PATH}/init |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should slave call these hooks?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I asked for it to be added because I thought even slaves want to have their configuration files extendible. But looking at pg_basebackup documentation it seems that the slaves will get the master's configurations files along with everything else, so it might not be needed after all.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
More it seems to me that the password change method is newly called for slave, too.
|
||
if [ -v POSTGRESQL_ADMIN_PASSWORD ]; then | ||
psql --command "ALTER USER \"postgres\" WITH ENCRYPTED PASSWORD '${POSTGRESQL_ADMIN_PASSWORD}';" | ||
fi |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably editor mis-config (missing newline).
|
||
extending_cfg_dir="${APP_DATA}/src/postgresql-config" | ||
|
||
for conf in $(ls ${extending_cfg_dir}); do |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
for conf in "$extending_cfg_dir"/*.conf; do
for conf in $(ls ${extending_cfg_dir}); do | ||
cat >> "$PGDATA/postgresql.conf" <<EOF | ||
include '$extending_cfg_dir/${conf}' | ||
EOF |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit, but echo would be also OK and a bit more readable.
Thanks, it is close now :-) could we please add s2i test-cases? Mariadb can be used for inspiration. |
@@ -28,9 +28,13 @@ check_env_vars | |||
generate_passwd_file | |||
generate_postgresql_config | |||
|
|||
process_extending_files ${APP_DATA}/src/pre-init ${CONTAINER_SCRIPTS_PATH}/pre-init |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This file needs to be updated to use init-hook
and start-hook
directories.
23189b7
to
55617a6
Compare
The requested changes has been applied; now also to Dockerfile.template and versions 9.5 and 9.4. |
For the source files under |
We need to add/ensure g+r for |
ec63a26
to
f230590
Compare
So based on comments above, fix-permission wasn't changed in latest rebase and is called during assemble. Postgres user is added to root group in Dockerfile to be able to perform the operations. |
9.4/Dockerfile.rhel7
Outdated
# {APP_DATA} needs to be accessed by postgres user while s2i assembling | ||
# postgres user changes permissiond of files in APP_DATA during assemblng | ||
RUN chown -R 26:0 ${APP_DATA} && \ | ||
useradd -G root 26 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This doesn't work on my system. You probably want usermod -a -G root postgres
.
I don't think removal of chmod
was correct, because default umask should be 0022 -> which means that group get's only r-x
permissions.
f230590
to
381227a
Compare
[test-openshift] |
|
||
contained shell scripts (`*.sh`) are sourced once, when database is initialized | ||
|
||
##### `start-hook/` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Still no comment about s/start-hook/postgresql-start-hook/
. Mariadb has mysql-cfg
, mysql-init
and mysql-pre-init
. Shouldn't we have the namespaced hook directory, too?
9.5/Dockerfile.rhel7
Outdated
@@ -70,6 +72,12 @@ ENV BASH_ENV=${CONTAINER_SCRIPTS_PATH}/scl_enable \ | |||
|
|||
VOLUME ["/var/lib/pgsql/data"] | |||
|
|||
# {APP_DATA} needs to be accessed by postgres user while s2i assembling | |||
# postgres user changes permissiond of files in APP_DATA during assemblng |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What about:
Being also in supplemental group 0
, postgres user can by default change the group
ownership of files in $APP_DATA to postgres:root
(by fix-permissions script in assemble
script). This group ownership change is needed because the s2i-built image is run under
arbitrary user uid (but gid=0).
9.5/Dockerfile.rhel7
Outdated
# postgres user changes permissiond of files in APP_DATA during assemblng | ||
RUN chown -R postgres:0 ${APP_DATA} && \ | ||
chmod -R ug+rwx ${APP_DATA} && \ | ||
usermod -a -G root postgres |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I still have the two questions:
- is the write permissions needed in case of postgresql?
- could we just drop chown/chmod and use
fix-permissions
above (where the data ownership is changed)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think fix-permissions
should be enough, at least it looks like it's enough for mysql: https://github.com/sclorg/mysql-container/blob/master/root-common/usr/libexec/container-setup#L57
9.5/Dockerfile.rhel7
Outdated
@@ -70,6 +72,12 @@ ENV BASH_ENV=${CONTAINER_SCRIPTS_PATH}/scl_enable \ | |||
|
|||
VOLUME ["/var/lib/pgsql/data"] | |||
|
|||
# {APP_DATA} needs to be accessed by postgres user while s2i assembling | |||
# postgres user changes permissiond of files in APP_DATA during assemblng |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
two typos: "permissiond" and "assemblng"
381227a
to
1c199b2
Compare
I would prefer to have that hooks namespaced, yes. |
1c199b2
to
8aa193c
Compare
@praiskup Is it now ok? |
Seems to be, small nit with the docs. |
|
||
##### `postgresql-config/` | ||
|
||
contained files will be included at the end of image postgresql.conf file during database initialization |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Meh, github fights against me. This should be either dropped, or at least you should mention that only *.conf files are sourced.
8aa193c
to
0c9da02
Compare
[test-openshift] |
lgtm |
Merging, thanks! |
No description provided.