charts icon indicating copy to clipboard operation
charts copied to clipboard

[bitnami/postgresql] data directory "/bitnami/postgresql/data" has wrong ownership

Open kper3360 opened this issue 1 year ago • 12 comments

Name and Version

/bitnami/postgresql/16.4.0-debian-12-r5

What architecture are you using?

None

What steps will reproduce the bug?

Environment- AWS EKS V 1.28

kubectl logs -f  my-postgresql-0     
postgresql 16:05:51.64 INFO  ==> 
postgresql 16:05:51.72 INFO  ==> Welcome to the Bitnami postgresql container
postgresql 16:05:51.73 INFO  ==> Subscribe to project updates by watching https://github.com/bitnami/containers
postgresql 16:05:51.73 INFO  ==> Submit issues and feature requests at https://github.com/bitnami/containers/issues
postgresql 16:05:51.73 INFO  ==> Upgrade to Tanzu Application Catalog for production environments to access custom-configured and pre-packaged software components. Gain enhanced features, including Software Bill of Materials (SBOM), CVE scan result reports, and VEX documents. To learn more, visit https://bitnami.com/enterprise
postgresql 16:05:51.74 INFO  ==> 
postgresql 16:05:51.83 DEBUG ==> Configuring libnss_wrapper...
postgresql 16:05:51.92 DEBUG ==> Copying files from /opt/bitnami/postgresql/conf.default to /opt/bitnami/postgresql/conf
postgresql 16:05:51.93 INFO  ==> ** Starting PostgreSQL setup **
postgresql 16:05:52.04 INFO  ==> Validating settings in POSTGRESQL_* env vars..
postgresql 16:05:52.14 INFO  ==> Loading custom pre-init scripts...
postgresql 16:05:52.15 INFO  ==> Initializing PostgreSQL database...
postgresql 16:05:52.22 DEBUG ==> Ensuring expected directories/files exist...
postgresql 16:05:52.32 INFO  ==> pg_hba.conf file not detected. Generating it...
postgresql 16:05:52.33 INFO  ==> Generating local authentication configuration
The files belonging to this database system will be owned by user "postgres".
This user must also own the server process.

The database cluster will be initialized with locale "en_US.UTF-8".
The default text search configuration will be set to "english".

Data page checksums are disabled.

fixing permissions on existing directory /bitnami/postgresql/data ... ok
creating subdirectories ... ok
selecting dynamic shared memory implementation ... posix
selecting default max_connections ... 20
selecting default shared_buffers ... 400kB
selecting default time zone ... Etc/UTC
creating configuration files ... ok
2024-08-31 16:05:55.147 UTC [101] FATAL:  data directory "/bitnami/postgresql/data" has wrong ownership
2024-08-31 16:05:55.147 UTC [101] HINT:  The server must be started by the user that owns the data directory.
child process exited with exit code 1
initdb: removing contents of data directory "/bitnami/postgresql/data"

Are you using any custom parameters or values?

no

What is the expected behavior?

No response

What do you see instead?

After I installed the Helm chart the the pod went to crashloopbackoff status.

my-postgresql-0 0/1 CrashLoopBackOff 10 (80s ago) 28m

Additional information

No response

kper3360 avatar Aug 31 '24 17:08 kper3360

Hi!

Could you add more details on the PVC provider you are using? It may have incompatibilities with fsGroup

javsalgar avatar Sep 02 '24 09:09 javsalgar

I use EFS CSI Provisioner

kper3360 avatar Sep 06 '24 09:09 kper3360

Could you try with the volume permissions init container? volumePermissions.enabled=true?

javsalgar avatar Sep 09 '24 07:09 javsalgar

Could you try with the volume permissions init container? volumePermissions.enabled=true?

I tried it. But it didn't work

kper3360 avatar Sep 09 '24 07:09 kper3360

Could you deploy the chart with diagnosticMode.enabled=true, enter the container with kubectl exec and check the permissions on the volume folder?

javsalgar avatar Sep 09 '24 08:09 javsalgar

@javsalgar I have same problem.

CleanShot 2024-09-09 at 16 49 52@2x

The default user id of EFS is 50011, so I tried below config but it doesn't works.

volumePermissions:
  enabled: true
  containerSecurityContext:
    runAsUser: 50011
    runAsGroup: 50011
    runAsNonRoot: false

CleanShot 2024-09-09 at 16 51 00@2x

kamontat avatar Sep 09 '24 09:09 kamontat

Even with that user/group, you are unable to perform a touch command inside the container? What error does it show?

javsalgar avatar Sep 10 '24 07:09 javsalgar

@javsalgar The volumePermissions doesn't works, but when I configure containerSecurityContext to below, it's works.

primary:
  containerSecurityContext:
    runAsUser: 50011
    runAsGroup: 50011
    runAsNonRoot: true
readReplicas:
  containerSecurityContext:
    runAsUser: 50011
    runAsGroup: 50011
    runAsNonRoot: true

kamontat avatar Sep 19 '24 09:09 kamontat

@javsalgar The volumePermissions doesn't works, but when I configure containerSecurityContext to below, it's works.

primary:
  containerSecurityContext:
    runAsUser: 50011
    runAsGroup: 50011
    runAsNonRoot: true
readReplicas:
  containerSecurityContext:
    runAsUser: 50011
    runAsGroup: 50011
    runAsNonRoot: true

I tried this, But it didn't work. Can you please provide the complete values file.

kper3360 avatar Sep 30 '24 12:09 kper3360

I have the same error with the docker container running with docker compose with BITNAMI_DEBUG=true. It worked fine a month ago... I didn't change anything on my setup. I'm using bitnami/postgresql:16. I tried bitnami/postgresql:17 and I have the same error.

postgres-1   | postgresql 13:18:25.10 INFO  ==> Generating local authentication configuration
postgres-1   | The files belonging to this database system will be owned by user "postgres".
postgres-1   | This user must also own the server process.
postgres-1   |
postgres-1   | The database cluster will be initialized with locale "en_US.UTF-8".
postgres-1   | The default text search configuration will be set to "english".
postgres-1   |
postgres-1   | Data page checksums are disabled.
postgres-1   |
postgres-1   | fixing permissions on existing directory /bitnami/postgresql/data ... ok
postgres-1   | creating subdirectories ... ok
postgres-1   | selecting dynamic shared memory implementation ... posix
postgres-1   | selecting default "max_connections" ... 100
postgres-1   | selecting default "shared_buffers" ... 128MB
postgres-1   | selecting default time zone ... Etc/UTC
postgres-1   | creating configuration files ... ok
postgres-1   | 2024-10-02 13:18:25.207 UTC [58] FATAL:  data directory "/bitnami/postgresql/data" has wrong ownership
postgres-1   | 2024-10-02 13:18:25.207 UTC [58] HINT:  The server must be started by the user that owns the data directory.
postgres-1   | child process exited with exit code 1
postgres-1   | initdb: removing contents of data directory "/bitnami/postgresql/data"
postgres-1   | running bootstrap script ...

rsignavong avatar Oct 02 '24 13:10 rsignavong

I have the same error with the docker container running with docker compose with BITNAMI_DEBUG=true. It worked fine a month ago... I didn't change anything on my setup. I'm using bitnami/postgresql:16. I tried bitnami/postgresql:17 and I have the same error.

postgres-1   | postgresql 13:18:25.10 INFO  ==> Generating local authentication configuration
postgres-1   | The files belonging to this database system will be owned by user "postgres".
postgres-1   | This user must also own the server process.
postgres-1   |
postgres-1   | The database cluster will be initialized with locale "en_US.UTF-8".
postgres-1   | The default text search configuration will be set to "english".
postgres-1   |
postgres-1   | Data page checksums are disabled.
postgres-1   |
postgres-1   | fixing permissions on existing directory /bitnami/postgresql/data ... ok
postgres-1   | creating subdirectories ... ok
postgres-1   | selecting dynamic shared memory implementation ... posix
postgres-1   | selecting default "max_connections" ... 100
postgres-1   | selecting default "shared_buffers" ... 128MB
postgres-1   | selecting default time zone ... Etc/UTC
postgres-1   | creating configuration files ... ok
postgres-1   | 2024-10-02 13:18:25.207 UTC [58] FATAL:  data directory "/bitnami/postgresql/data" has wrong ownership
postgres-1   | 2024-10-02 13:18:25.207 UTC [58] HINT:  The server must be started by the user that owns the data directory.
postgres-1   | child process exited with exit code 1
postgres-1   | initdb: removing contents of data directory "/bitnami/postgresql/data"
postgres-1   | running bootstrap script ...

I manage to make it work by using docker volume instead of bind mount. But it's strange, it previously worked with a bind mount volume before.

rsignavong avatar Oct 02 '24 20:10 rsignavong

This Issue has been automatically marked as "stale" because it has not had recent activity (for 15 days). It will be closed if no further activity occurs. Thanks for the feedback.

github-actions[bot] avatar Oct 18 '24 01:10 github-actions[bot]

Due to the lack of activity in the last 5 days since it was marked as "stale", we proceed to close this Issue. Do not hesitate to reopen it later if necessary.

github-actions[bot] avatar Oct 23 '24 01:10 github-actions[bot]