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

init scripts not running in Postgres chart #31256

Open
UTF-8x opened this issue Jan 8, 2025 · 1 comment
Open

init scripts not running in Postgres chart #31256

UTF-8x opened this issue Jan 8, 2025 · 1 comment
Assignees
Labels
in-progress postgresql tech-issues The user has a technical issue about an application

Comments

@UTF-8x
Copy link

UTF-8x commented Jan 8, 2025

Name and Version

bitnami/postgresql:16.3.5

What architecture are you using?

amd64

What steps will reproduce the bug?

  1. Install the chart with following values:
     primary:
       initdb:
         scripts:
           00_init_extensions.sql: |
             CREATE EXTENSION IF NOT EXISTS postgis;
           00_debug.sh: |
             echo "This is debug"
  2. Look in the logs for This is debug
  3. SELECT * FROM pg_extension; look for postgis

Are you using any custom parameters or values?

global:
    postgresql:
      auth:
        postgresPassword: "..."
        username: "..."
        password: "..."
        database: "..."

  image:
    tag: 17.2.0-debian-12-r5
    debug: true
  
  auth:
    enablePostgresUser: true
    postgresPassword: "..."
    username: "..."
    password: "..."
    database: "..."
  
  postgresqlSharedPreloadLibraries: "pgaudit"
  
  rbac:
    create: true

  primary:
    initdb:
      user: "postgres"
      password: "..."
      scripts:
        00_init_extensions.sql: |
          CREATE EXTENSION IF NOT EXISTS postgis;
        00_debug.sh: |
          echo "This is debug"

What is the expected behavior?

"This is debug" is printed to the log and the postgis extension is enabled

What do you see instead?

postgres pod log

postgresql 08:11:35.16 INFO  ==> Welcome to the Bitnami postgresql container
postgresql 08:11:35.25 INFO  ==> Subscribe to project updates by watching https://github.com/bitnami/containers
postgresql 08:11:35.25 INFO  ==> Did you know there are enterprise versions of the Bitnami catalog? For enhanced secure software supply chain features, unlimited pulls from Docker, LTS support, or application customization, see Bitnami Premium or Tanzu Application Catalog. See https://www.arrow.com/globalecs/na/vendors/bitnami/ for more information.
postgresql 08:11:35.25 INFO  ==>
postgresql 08:11:35.35 DEBUG ==> Configuring libnss_wrapper...
postgresql 08:11:35.46 DEBUG ==> Copying files from /opt/bitnami/postgresql/conf.default to /opt/bitnami/postgresql/conf
postgresql 08:11:35.55 INFO  ==> ** Starting PostgreSQL setup **
postgresql 08:11:35.76 INFO  ==> Validating settings in POSTGRESQL_* env vars..
postgresql 08:11:35.86 INFO  ==> Loading custom pre-init scripts...
postgresql 08:11:35.95 INFO  ==> Initializing PostgreSQL database...
postgresql 08:11:35.96 DEBUG ==> Ensuring expected directories/files exist...
postgresql 08:11:36.15 INFO  ==> pg_hba.conf file not detected. Generating it...
postgresql 08:11:36.16 INFO  ==> Generating local authentication configuration
postgresql 08:11:36.36 INFO  ==> Deploying PostgreSQL with persisted data...
postgresql 08:11:36.55 INFO  ==> Configuring replication parameters
postgresql 08:11:37.05 INFO  ==> Configuring fsync
postgresql 08:11:37.14 INFO  ==> Configuring synchronous_replication
postgresql 08:11:37.65 INFO  ==> Loading custom scripts...
postgresql 08:11:37.66 INFO  ==> Enabling remote connections
postgresql 08:11:37.84 INFO  ==> ** PostgreSQL setup finished! **
postgresql 08:11:38.05 INFO  ==> ** Starting PostgreSQL **
2025-01-08 08:11:38.269 GMT [1] LOG:  pgaudit extension initialized
2025-01-08 08:11:38.363 GMT [1] LOG:  starting PostgreSQL 17.2 on x86_64-pc-linux-gnu, compiled by gcc (Debian 12.2.0-14) 12.2.0, 64-bit
2025-01-08 08:11:38.363 GMT [1] LOG:  listening on IPv4 address "0.0.0.0", port 5432
2025-01-08 08:11:38.364 GMT [1] LOG:  listening on IPv6 address "::", port 5432
2025-01-08 08:11:38.367 GMT [1] LOG:  listening on Unix socket "/tmp/.s.PGSQL.5432"
2025-01-08 08:11:38.467 GMT [95] LOG:  database system was shut down at 2025-01-08 08:09:30 GMT
2025-01-08 08:11:38.553 GMT [1] LOG:  database system is ready to accept connections

mydb=# select * from pg_extension;
  oid  | extname | extowner | extnamespace | extrelocatable | extversion | extconfig | extcondition
-------+---------+----------+--------------+----------------+------------+-----------+--------------
 13569 | plpgsql |       10 |           11 | f              | 1.0        |           |
(1 row)

Additional information

No response

@UTF-8x UTF-8x added the tech-issues The user has a technical issue about an application label Jan 8, 2025
@github-actions github-actions bot added the triage Triage is needed label Jan 8, 2025
@github-actions github-actions bot removed the triage Triage is needed label Jan 8, 2025
@github-actions github-actions bot assigned dgomezleon and unassigned carrodher Jan 8, 2025
@dgomezleon
Copy link
Member

dgomezleon commented Jan 13, 2025

Hi @UTF-8x

This worked for me:

global:
    postgresql:
      auth:
        postgresPassword: "pgpass"
        username: "myuser"
        password: "mypass"
        database: "mydb"
image:
    tag: 17.2.0-debian-12-r5
    debug: true
auth:
    enablePostgresUser: true
    postgresPassword: "pgpass"
    username: "myuser"
    password: "mypass"
    database: "mydb"
postgresqlSharedPreloadLibraries: "pgaudit"
rbac:
    create: true
primary:
    initdb:
      user: "postgres"
      password: "pgpass"
      scripts:
        00_init_extensions.sql: |
          CREATE EXTENSION IF NOT EXISTS postgis;
        00_debug.sh: |
          echo "This is debug"

The logs shows is:

...
2025-01-13 09:26:22.693 GMT [161] LOG:  database system is ready to accept connections
postgresql 09:26:23.58 DEBUG ==> Sourcing /docker-entrypoint-initdb.d/..2025_01_13_09_26_05.4149028189/00_debug.sh
This is debug
postgresql 09:26:23.58 DEBUG ==> Executing /docker-entrypoint-initdb.d/..2025_01_13_09_26_05.4149028189/00_init_extensions.sql
CREATE EXTENSION
postgresql 09:26:28.08 INFO  ==> Enabling remote connections
...

and I can see the extension too

I have no name!@postgresql-0:/$ psql -U myuser mydb
Password for user david: 
psql (17.2)
Type "help" for help.

btdb=> select * from pg_extension;
  oid  | extname | extowner | extnamespace | extrelocatable | extversion | extconfig |           extcondition            
-------+---------+----------+--------------+----------------+------------+-----------+-----------------------------------
 13569 | plpgsql |       10 |           11 | f              | 1.0        |           | 
 16386 | postgis |       10 |         2200 | f              | 3.4.4      | {16704}   | {"WHERE NOT (                    +
       |         |          |              |                |            |           | srid BETWEEN 2000 AND 2217       +
       |         |          |              |                |            |           | OR srid BETWEEN 2219 AND 2220    +
       |         |          |              |                |            |           | OR srid BETWEEN 2222 AND 2292    +
 ...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in-progress postgresql tech-issues The user has a technical issue about an application
Projects
None yet
Development

No branches or pull requests

3 participants