Logical backups cannot use virtual-hosted S3 addressing (no way to set addressing_style)
维护者通常 2 天内回复
还没有人认领这个 Issue。
评估
- 难度
- 4/5
- 预计耗时
- 3-5 天
- 新手友好度
- 58/100
调研方向
从 logical-backup/dump.sh、getCronjobEnvironmentSecretVariables() 和 generateLogicalBackupJob() 开始,追踪 OpConfig 如何到达 logical-backup CronJob。确认该选项会传递给 job,并且 dump.sh 会应用请求的 S3 寻址样式,同时在未设置该选项时保持当前行为。验证 Virtual-Style 下的 bucket 名称问题已按约定处理。
由索引模型根据 Issue 内容生成。
描述
- Which image of the operator are you using? ghcr.io/zalando/postgres-operator:v1.15.0
- Where do you run it - cloud or metal? Kubernetes or OpenShift? Bare Metal K8s
- Are you running Postgres Operator in production? yes
- Type of issue? feature request
Problem
logical-backup/dump.sh invokes the AWS CLI with only --endpoint-url and --region:
aws s3 cp - "$PATH_TO_BACKUP" "${args[@]//\'/}"
With --endpoint-url, botocore defaults to path-style addressing. Some S3-compatible
providers support only virtual-hosted addressing, so logical backups cannot be used
with them at all.
WAL-G backups do not have this problem: Spilo lets you pick the style through the
WALE_S3_ENDPOINT scheme (https+path://… / https+virtual://…) and derives
AWS_S3_FORCE_PATH_STYLE from it. There is no equivalent for logical backups.
Why this cannot be solved with the existing knobs
1. botocore takes addressing_style only from a config file. The environment
variable is ignored — verified on botocore 1.35.86 (image v1.14.0) and 1.42.12
(image v1.15.1). Only this works:
[default]
s3 =
addressing_style = virtual
2. The operator can inject env vars into the CronJob, but not a file.
getCronjobEnvironmentSecretVariables() produces EnvVar entries with SecretKeyRef;
there is no file-based equivalent.
3. Per-cluster volumes are not available for the backup pod.
generateLogicalBackupJob() calls generatePodTemplate() with an empty
[]acidv1.AdditionalVolume{}, so spec.additionalVolumes never reaches it.
4. additionalSecretMount does reach the pod — it is passed through from
OpConfig — so mounting a config file is technically possible. But it is a single
global operator setting, and the Secret must exist in every namespace that has
clusters. With clusters spread over dozens of namespaces this is fragile: a newly
created namespace silently breaks backups there.
Extra hazard: silent fallback
Even when addressing_style = virtual is set, botocore applies it only if the bucket
name is a single DNS label. If the name contains a dot, it silently falls back to
path-style over HTTPS — no error, no log line
(aws_is_virtual_hostable_s3_bucket, allowSubDomains=false for https).
Measured with botocore 1.35.86, addressing_style = virtual in the config file:
| bucket | resulting request URL |
|---|---|
spilo-operator.example.k8s |
https://s3.example.one/spilo-operator.example.k8s?list-type=2… (path!) |
spilo-operator-example-k8s |
https://spilo-operator-example-k8s.s3.example.one/?list-type=2… (virtual) |
For a provider that requires virtual-hosted addressing this means the request quietly
goes to the base endpoint instead of the bucket, which in our case is a different network
route entirely.
Proposed fix
A new operator option, e.g. logical_backup_s3_addressing_style (path | virtual,
empty = current behaviour), passed to the CronJob as
LOGICAL_BACKUP_S3_ADDRESSING_STYLE, plus a few lines in dump.sh:
if [[ -n "${LOGICAL_BACKUP_S3_ADDRESSING_STYLE}" ]]; then
export AWS_CONFIG_FILE=/tmp/aws-config
printf '[default]\ns3 =\n addressing_style = %s\n' \
"${LOGICAL_BACKUP_S3_ADDRESSING_STYLE}" > "${AWS_CONFIG_FILE}"
fi
Optionally, fail fast when virtual is requested for a bucket name containing a dot,
since botocore will silently ignore the setting.
We currently carry this as a wrapper around /dump.sh in a derived image. Happy to
submit a PR if the approach looks acceptable.
Related
- #3182 — default request checksums break multipart uploads on some S3-compatible
storages. Different root cause, same image; we work around it in the same wrapper with
AWS_REQUEST_CHECKSUM_CALCULATION=WHEN_REQUIRED. Worth mentioning only because both
are about AWS CLI defaults that cannot be adjusted from the operator.
- 主要语言
- Go
- 星标
- 5.3k
- 派生
- 1.1k
- 平均合并
- 3 天 17 小时
- 30 天内合并 PR
- 11
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
zalando/postgres-operator 的其他 Issue
-
难度 2/5 1-3 小时 新手友好度 76/100
zalando/postgres-operator#3257 ·
维护者通常 2 天内回复
-
难度 2/5 1-3 小时 新手友好度 78/100
zalando/postgres-operator#3254 ·
维护者通常 2 天内回复
-
难度 2/5 1-3 小时 新手友好度 75/100
zalando/postgres-operator#3253 ·
维护者通常 2 天内回复
-
难度 2/5 1-3 小时 新手友好度 76/100
zalando/postgres-operator#3252 ·
维护者通常 2 天内回复
-
难度 2/5 1-3 小时 新手友好度 74/100
zalando/postgres-operator#3182 · 1 条评论 ·
维护者通常 2 天内回复
查看 zalando/postgres-operator 的全部 Issue
相似的 Issue
-
bug
难度 2/5 1-3 小时 新手友好度 75/100
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 70/100
pg-sharding/spqr#3314 ·
维护者通常 1 天内回复
-
难度 1/5 1 小时以内 新手友好度 80/100
slavakurilyak/awesome-ai-agents#1051 ·
-
难度 2/5 1-3 小时 新手友好度 76/100
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 73/100
google-gemini/gemini-api-cli#247 ·
维护者通常 1 天内回复