Skip to content

[BUG] cnpg-17 problem with db creating #41

@qwiatu-lp

Description

@qwiatu-lp

Describe the bug

Defaulted container "initdb" out of: initdb, bootstrap-controller (init)
{"level":"info","ts":"2025-05-25T19:21:31.345592127Z","msg":"Creating new data directory","logging_pod":"freddie-1-initdb","pgdata":"/var/lib/postgresql/data/pgdata","initDbOptions":["--username","postgres","-D","/var/lib/postgresql/data/pgdata","--encoding=UTF8","--lc-collate=C","--lc-ctype=C"]}
{"level":"info","ts":"2025-05-25T19:21:31.381078403Z","logger":"initdb","msg":"initdb: could not look up effective user ID 26: user does not exist\n","pipe":"stderr","logging_pod":"freddie-1-initdb"}
{"level":"error","ts":"2025-05-25T19:21:31.38114185Z","msg":"Error while bootstrapping data directory","logging_pod":"freddie-1-initdb","error":"error while creating the PostgreSQL instance: exit status 1","stacktrace":"github.com/cloudnative-pg/machinery/pkg/log.(*logger).Error\n\tpkg/mod/github.com/cloudnative-pg/[email protected]/pkg/log/log.go:125\ngithub.com/cloudnative-pg/cloudnative-pg/internal/cmd/manager/instance/initdb.initSubCommand\n\tinternal/cmd/manager/instance/initdb/cmd.go:160\ngithub.com/cloudnative-pg/cloudnative-pg/internal/cmd/manager/instance/initdb.NewCmd.func2\n\tinternal/cmd/manager/instance/initdb/cmd.go:109\ngithub.com/spf13/cobra.(*Command).execute\n\tpkg/mod/github.com/spf13/[email protected]/command.go:985\ngithub.com/spf13/cobra.(*Command).ExecuteC\n\tpkg/mod/github.com/spf13/[email protected]/command.go:1117\ngithub.com/spf13/cobra.(*Command).Execute\n\tpkg/mod/github.com/spf13/[email protected]/command.go:1041\nmain.main\n\tcmd/manager/main.go:68\nruntime.main\n\t/opt/hostedtoolcache/go/1.23.4/x64/src/runtime/proc.go:272"}
Error: error while creating the PostgreSQL instance: exit status 1


Image

cnpg-17. Probably cnpg-16

To Reproduce

Steps to reproduce the behavior:

  1. Install cnpg-operator on k8s
  2. Run following manifest
kubectl apply -f - << EOF
---
apiVersion: v1
kind: Secret
metadata:
  name: postgresql-app
  namespace: freddie
type: kubernetes.io/basic-auth
stringData:
  username: app
  password: mydb

EOF


# FAIL
kubectl apply -f - << EOF
apiVersion: postgresql.cnpg.io/v1
kind: Cluster
metadata:
  name: freddie
spec:
  instances: 1
  imageName: docker.io/sourcemation/postgres-17:17.4.1
  storage:
    size: 1Gi

  bootstrap:
    initdb:
      postInitApplicationSQL:
        - CREATE TABLE n (i SERIAL PRIMARY KEY, m INTEGER)
        - INSERT INTO n (m) (SELECT generate_series(1, 10000))
        - ALTER TABLE n OWNER TO app

  managed:
    roles:
      - name: app
        login: true
        replication: true
        passwordSecret:
          name: postgresql-app
EOF


#SUCCESS


kubectl apply -f - << EOF
apiVersion: postgresql.cnpg.io/v1
kind: Cluster
metadata:
  name: freddie
spec:
  instances: 1
  imageName: ghcr.io/cloudnative-pg/postgresql:17.4
  storage:
    size: 1Gi

  bootstrap:
    initdb:
      postInitApplicationSQL:
        - CREATE TABLE n (i SERIAL PRIMARY KEY, m INTEGER)
        - INSERT INTO n (m) (SELECT generate_series(1, 10000))
        - ALTER TABLE n OWNER TO app

  managed:
    roles:
      - name: app
        login: true
        replication: true
        passwordSecret:
          name: postgresql-app
EOF


Expected behavior

Resolve issue

Additional context

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingquestionFurther information is requested

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions