zalando / zalando/postgres-operator
WAL bucket scope prefix/suffix missing when configuring WAL_S3_BUCKET locally
Nobody has claimed this yet.
- Dominant language
- Go
- Stars
- 5.2k
- Forks
- 1.1k
- Avg merge
- 2d 16h
- Merged PRs (30d)
- 3
Description
When configuring WAL_S3_BUCKET via ConfigMap, Secret, or spec.env (per PostgreSQL cluster) instead of globally in the operator config, then the operator doesn't configure WAL_BUCKET_SCOPE_SUFFIX and WAL_BUCKET_SCOPE_PREFIX.
This is due to the following check: https://github.com/zalando/postgres-operator/blob/640581fb4661dbab852dfc0995b5e9f6140fd8f8/pkg/cluster/k8sres.go#L939
This hit us unexpectedly when we wanted to migrate our setup to use a distinct bucket per PostgreSQL cluster. Furthermore, even when using a distinct bucket per PostgreSQL cluster, it's still a good idea to have the cluster UID in the WAL_BUCKET_SCOPE_SUFFIX, so that a cluster that gets recreated has a clean state and doesn't conflict with existing WAL backups.
Possible solution: Maybe the operator can unconditionally inject WAL_BUCKET_SCOPE_SUFFIX and WAL_BUCKET_SCOPE_PREFIX, no matter if c.OpConfig.WALES3Bucket is non-empty.
Workaround: In the OperatorConfiguration, set configuration.aws_or_gcp.wal_s3_bucket: dummy and overwrite it on a per-PostgreSQL-cluster basis by setting the environment variable WAL_S3_BUCKET via ConfigMap, Secret, or spec.env. I only tested it with spec.env and that seems to have precedence over the environment variable injected by the operator.
- Which image of the operator are you using? registry.opensource.zalan.do/acid/postgres-operator:v1.8.2
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in pkg/cluster/k8sres.go around line 939 and inspect the check that controls WAL_BUCKET_SCOPE_SUFFIX and WAL_BUCKET_SCOPE_PREFIX. Reproduce the configuration with WAL_S3_BUCKET supplied through ConfigMap, Secret, or spec.env, then verify that both scope variables are configured even when the operator-level bucket is empty.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go, kubernetes, postgresql
- Domain
- databases, devops, infrastructure
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 42/100