fix(controller,backup): select Postgres container by name instead of assuming index by Joda89 · Pull Request #8964 · cloudnative-pg/cloudnative-pg
label
Oct 26, 2025and removed size:XS
This PR changes 0-9 lines, ignoring generated files.labels
Oct 27, 2025
armru
changed the title
fix(backup): fix backup function when we have sidecar
fix(backup): do not assume that postgres is the first container
armru
changed the title
fix(backup): do not assume that postgres is the first container
fix(controller,backup): select Postgres container by name instead of assuming index
The purpose of this PR is to fix backups when there is more than one container in the Pod, which is the case when using Istio, for example.
Error message:
{‘level’:‘debug’,“ts”:" 2025-10-26T07:49:29.003680028Z‘,’msg‘:’Instance not having expected image, discarded as target for backup‘,’controller‘:’backup‘,’controllerGroup‘:’postgresql.cnpg.io‘,’controllerKind‘:“Backup”,’ Backup‘:{’name‘:’postgresql-20251026084856‘,’namespace‘:’databases‘},’namespace‘:’databases‘,“name”:’postgresql-20251026084856‘,’ reconcileID‘:’f4dd8a41-2755-4086-89f8-e1daa10bb2bc‘,“caller”:’internal/controller/backup_controller.go:692"}
Signed-off-by: Joda89 <johan.lore@free.fr>
cnpg-bot pushed a commit that referenced this pull request
Oct 28, 2025…assuming index (#8964) Ensure backups identify the Postgres container by its name rather than assuming the Postgres container is the first container in the Pod spec/status. Pods may include sidecars or other containers, which can shift ordering; relying on index zero is brittle and causes incorrect containerID/image checks. Closes #8966 Signed-off-by: Joda89 <johan.lore@free.fr> Signed-off-by: Armando Ruocco <armando.ruocco@enterprisedb.com> Co-authored-by: Armando Ruocco <armando.ruocco@enterprisedb.com> (cherry picked from commit 603b10d)
cnpg-bot pushed a commit that referenced this pull request
Oct 28, 2025…assuming index (#8964) Ensure backups identify the Postgres container by its name rather than assuming the Postgres container is the first container in the Pod spec/status. Pods may include sidecars or other containers, which can shift ordering; relying on index zero is brittle and causes incorrect containerID/image checks. Closes #8966 Signed-off-by: Joda89 <johan.lore@free.fr> Signed-off-by: Armando Ruocco <armando.ruocco@enterprisedb.com> Co-authored-by: Armando Ruocco <armando.ruocco@enterprisedb.com> (cherry picked from commit 603b10d)
mnencia pushed a commit that referenced this pull request
Oct 29, 2025…assuming index (#8964) Ensure backups identify the Postgres container by its name rather than assuming the Postgres container is the first container in the Pod spec/status. Pods may include sidecars or other containers, which can shift ordering; relying on index zero is brittle and causes incorrect containerID/image checks. Closes #8966 Signed-off-by: Joda89 <johan.lore@free.fr> Signed-off-by: Armando Ruocco <armando.ruocco@enterprisedb.com> Co-authored-by: Armando Ruocco <armando.ruocco@enterprisedb.com> (cherry picked from commit 603b10d)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters