Logical backups cannot use virtual-hosted S3 addressing (no way to set addressing_style)

Aperta
#3,183 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 2 giorni

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
58/100
Tipo di issue
Funzionalità
Chiarezza
Abbastanza chiara
Stato di attività
Attiva
Stack tecnologico
aws, go, kubernetes, postgresql, shell

Direzione di ricerca

Inizia da logical-backup/dump.sh, getCronjobEnvironmentSecretVariables() e generateLogicalBackupJob(); traccia come OpConfig arriva al logical-backup CronJob. Conferma che l’opzione venga passata al job e che dump.sh applichi lo stile di indirizzamento S3 richiesto, mantenendo il comportamento attuale quando non è impostata. Verifica che il rischio relativo al nome del bucket in Virtual-Style sia gestito come concordato.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

  • 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.
Lingua principale
Go
Stelle
5.3k
Fork
1.1k
Merge medio
3g 17h
PR unite (30g)
11

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di zalando/postgres-operator

Tutte le issue di zalando/postgres-operator

Issue simili

Altre issue su Go

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.