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

[Bug]: Bootstrapping from a backup fails if ssl = on is present in the backup's postgresql.auto.conf #4509

Open
4 tasks done
nick-ivanov-edb opened this issue May 9, 2024 · 0 comments
Assignees
Labels
triage Pending triage

Comments

@nick-ivanov-edb
Copy link

Is there an existing issue already for this bug?

  • I have searched for an existing issue, and could not find anything. I believe this is a new bug.

I have read the troubleshooting guide

  • I have read the troubleshooting guide and I think this is a new bug.

I am running a supported version of CloudNativePG

  • I have read the troubleshooting guide and I think this is a new bug.

Contact Details

No response

Version

older in 1.21.x

What version of Kubernetes are you using?

1.29

What is your Kubernetes environment?

Cloud: Amazon EKS

How did you install the operator?

YAML manifest

What happened?

The backup stored in S3 has postgresql.auto.conf with ssl = on in it. The bootstrapping fails after successfully restoring the backup with this error message:

{"level":"info","ts":"2024-05-09T19:47:12Z","logger":"pg_ctl","msg":"waiting for server to start....2024-05-09 19:47:12.449 UTC [33] FATAL:  could not load server certificate file \"/controller/certificates/server.crt\": No such file or directory","pipe":"stdout","logging_pod":"test-restore-1-full-recovery"}

Looking at the code:

	// Disable SSL as we still don't have the required certificates
	err = fileutils.AppendStringToFile(
		path.Join(info.PgData, constants.PostgresqlCustomConfigurationFile),
		"ssl = 'off'\n")

we do attempt to override the ssl setting, but postgresql.auto.conf has the final say.

Perhaps it would be better to just remove it when bootstrapping from a backup, because who knows what else might be there messing up with the new cluster's config.

Cluster resource

kind: Cluster
metadata:
  name: test-restore
spec:
  instances: 1
  primaryUpdateStrategy: unsupervised
  storage:
    size: 1Gi

  imageName: ghcr.io/cloudnative-pg/postgresql:12.18
  # imageName: ghcr.io/cloudnative-pg/postgresql:16.1
  bootstrap:
    recovery:
      source: clusterBackup

  externalClusters:
    - name: clusterBackup
      barmanObjectStore:
        serverName: cluster-example
        # serverName: m1-1
        destinationPath: "s3://m1-1"
        endpointURL: "https://minio.ns-minio.svc.cluster.local"
        endpointCA:
          name: kube-root-ca.crt
          key: ca.crt
        s3Credentials:
          accessKeyId:
            key: ACCESS_KEY_ID
            name: demo-s3-auth
          secretAccessKey:
            key: ACCESS_SECRET_KEY
            name: demo-s3-auth

Relevant log output

{"level":"info","ts":"2024-05-09T19:47:12Z","logger":"pg_ctl","msg":"waiting for server to start....2024-05-09 19:47:12.449 UTC [33] FATAL:  could not load server certificate file \"/controller/certificates/server.crt\": No such file or directory","pipe":"stdout","logging_pod":"test-restore-1-full-recovery"}
{"level":"info","ts":"2024-05-09T19:47:12Z","logger":"pg_ctl","msg":"2024-05-09 19:47:12.449 UTC [33] LOG:  database system is shut down","pipe":"stdout","logging_pod":"test-restore-1-full-recovery"}
{"level":"info","ts":"2024-05-09T19:47:12Z","logger":"pg_ctl","msg":" stopped waiting","pipe":"stdout","logging_pod":"test-restore-1-full-recovery"}
{"level":"info","ts":"2024-05-09T19:47:12Z","logger":"pg_ctl","msg":"pg_ctl: could not start server","pipe":"stderr","logging_pod":"test-restore-1-full-recovery"}
{"level":"info","ts":"2024-05-09T19:47:12Z","logger":"pg_ctl","msg":"Examine the log output.","pipe":"stderr","logging_pod":"test-restore-1-full-recovery"}
{"level":"info","ts":"2024-05-09T19:47:12Z","msg":"Exited log pipe","fileName":"/controller/log/postgres.csv","logging_pod":"test-restore-1-full-recovery"}
{"level":"error","ts":"2024-05-09T19:47:12Z","msg":"Error while restoring a backup","logging_pod":"test-restore-1-full-recovery","error":"while activating instance: error starting PostgreSQL instance: exit status 1","stacktrace":"github.com/cloudnative-pg/cloudnative-pg/pkg/management/log.(*logger).Error\n\tpkg/management/log/log.go:128\ngithub.com/cloudnative-pg/cloudnative-pg/pkg/management/log.Error\n\tpkg/management/log/log.go:166\ngithub.com/cloudnative-pg/cloudnative-pg/internal/cmd/manager/instance/restore.restoreSubCommand\n\tinternal/cmd/manager/instance/restore/cmd.go:89\ngithub.com/cloudnative-pg/cloudnative-pg/internal/cmd/manager/instance/restore.NewCmd.func2\n\tinternal/cmd/manager/instance/restore/cmd.go:60\ngithub.com/spf13/cobra.(*Command).execute\n\tpkg/mod/github.com/spf13/cobra@v1.8.0/command.go:983\ngithub.com/spf13/cobra.(*Command).ExecuteC\n\tpkg/mod/github.com/spf13/cobra@v1.8.0/command.go:1115\ngithub.com/spf13/cobra.(*Command).Execute\n\tpkg/mod/github.com/spf13/cobra@v1.8.0/command.go:1039\nmain.main\n\tcmd/manager/main.go:64\nruntime.main\n\t/opt/hostedtoolcache/go/1.21.6/x64/src/runtime/proc.go:267"}

Code of Conduct

  • I agree to follow this project's Code of Conduct
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
triage Pending triage
Projects
None yet
Development

No branches or pull requests

2 participants