Skip to content

fix: prefix extension and tablespace volume names to avoid collisions#9973

Merged
mnencia merged 7 commits intomainfrom
dev/9972
Feb 20, 2026
Merged

fix: prefix extension and tablespace volume names to avoid collisions#9973
mnencia merged 7 commits intomainfrom
dev/9972

Conversation

@mnencia
Copy link
Member

@mnencia mnencia commented Feb 12, 2026

Add namespace prefixes to extension and tablespace volume names so they cannot collide with system volumes (pgdata, shm, pg-wal, scratch-data, projected) or with each other. Extensions get an "ext-" prefix, tablespaces get a "tbs-" prefix.

Webhook validation rejects names that produce duplicate volume names after K8s name sanitization, for both extensions and tablespaces.

Migration logic normalizes old unprefixed volume names during pod spec comparison, preventing unnecessary pod restarts on upgrade. The operator upgrade E2E fixtures now include a tablespace to exercise this path.

Closes #9972

@cnpg-bot cnpg-bot added backport-requested ◀️ This pull request should be backported to all supported releases release-1.25 release-1.27 release-1.28 labels Feb 12, 2026
@github-actions
Copy link
Contributor

❗ By default, the pull request is configured to backport to all release branches.

  • To stop backporting this pr, remove the label: backport-requested ◀️ or add the label 'do not backport'
  • To stop backporting this pr to a certain release branch, remove the specific branch label: release-x.y

@mnencia
Copy link
Member Author

mnencia commented Feb 14, 2026

/test

@github-actions
Copy link
Contributor

@mnencia, here's the link to the E2E on CNPG workflow run: https://github.com/cloudnative-pg/cloudnative-pg/actions/runs/22016169538

@mnencia mnencia force-pushed the dev/9972 branch 3 times, most recently from 6fa3682 to 884095c Compare February 14, 2026 11:26
@mnencia mnencia changed the title fix: prefix extension volume names to avoid collisions fix: prefix extension and tablespace volume names to avoid collisions Feb 14, 2026
@mnencia mnencia marked this pull request as ready for review February 14, 2026 11:28
@mnencia mnencia requested review from a team, NiccoloFei, jsilvela and litaocdl as code owners February 14, 2026 11:28
@dosubot dosubot bot added size:L This PR changes 100-499 lines, ignoring generated files. bug 🐛 Something isn't working labels Feb 14, 2026
@cnpg-bot cnpg-bot added the ok to merge 👌 This PR can be merged label Feb 14, 2026
@dosubot dosubot bot added the lgtm This PR has been approved by a maintainer label Feb 16, 2026
@NiccoloFei NiccoloFei force-pushed the dev/9972 branch 3 times, most recently from 1ce05ae to 405548e Compare February 19, 2026 15:35
@NiccoloFei
Copy link
Collaborator

/test

@github-actions
Copy link
Contributor

@NiccoloFei, here's the link to the E2E on CNPG workflow run: https://github.com/cloudnative-pg/cloudnative-pg/actions/runs/22190712682

Add an "ext-" prefix to extension volume names so they cannot
collide with system volumes (pgdata, shm, pg-wal, scratch-data,
projected) or tablespace volumes.

Closes #9972

Signed-off-by: Marco Nenciarini <[email protected]>
mnencia and others added 5 commits February 20, 2026 14:15
Add a "tbs-" prefix to tablespace volume names produced by
VolumeMountNameForTablespace() to prevent collisions with system
volumes (pgdata, shm, pg-wal, scratch-data, projected) and
extension volumes.

Add webhook validation to detect tablespace names that produce
duplicate volume names after K8s name sanitization, matching the
existing extension collision detection pattern.

Signed-off-by: Marco Nenciarini <[email protected]>
Add normalization functions that translate old unprefixed volume
and volume mount names to the new prefixed naming scheme (ext- for
extensions, tbs- for tablespaces) during pod spec comparison. This
prevents unnecessary pod restarts when upgrading from an operator
version that used unprefixed names.

Signed-off-by: Marco Nenciarini <[email protected]>
Export SanitizeExtensionNameForVolume and use it in the extension
webhook validation instead of reimplementing the same logic inline.

Signed-off-by: Marco Nenciarini <[email protected]>
Add integration tests for volume mount migration normalization in
compareVolumeMounts (extension and tablespace paths). Document known
limitation where ext_*/tbs_* named resources may cause one spurious
pod restart during upgrade.

Signed-off-by: Armando Ruocco <[email protected]>
Signed-off-by: Niccolò Fei <[email protected]>
@mnencia mnencia merged commit 8d3af4d into main Feb 20, 2026
36 checks passed
@mnencia mnencia deleted the dev/9972 branch February 20, 2026 13:40
mnencia added a commit that referenced this pull request Feb 20, 2026
…#9973)

Add namespace prefixes to extension and tablespace volume names so they
cannot collide with system volumes (pgdata, shm, pg-wal, scratch-data,
projected) or with each other. Extensions get an "ext-" prefix,
tablespaces get a "tbs-" prefix.

Webhook validation rejects names that produce duplicate volume names
after K8s name sanitization, for both extensions and tablespaces.

Migration logic normalizes old unprefixed volume names during pod spec
comparison, preventing unnecessary pod restarts on upgrade. The operator
upgrade E2E fixtures now include a tablespace to exercise this path.

Closes #9972

Signed-off-by: Marco Nenciarini <[email protected]>
Signed-off-by: Armando Ruocco <[email protected]>
Signed-off-by: Niccolò Fei <[email protected]>
Co-authored-by: Armando Ruocco <[email protected]>
Co-authored-by: Niccolò Fei <[email protected]>
(cherry picked from commit 8d3af4d)
mnencia added a commit that referenced this pull request Feb 20, 2026
…#9973)

Add namespace prefixes to extension and tablespace volume names so they
cannot collide with system volumes (pgdata, shm, pg-wal, scratch-data,
projected) or with each other. Extensions get an "ext-" prefix,
tablespaces get a "tbs-" prefix.

Webhook validation rejects names that produce duplicate volume names
after K8s name sanitization, for both extensions and tablespaces.

Migration logic normalizes old unprefixed volume names during pod spec
comparison, preventing unnecessary pod restarts on upgrade. The operator
upgrade E2E fixtures now include a tablespace to exercise this path.

Closes #9972

Signed-off-by: Marco Nenciarini <[email protected]>
Signed-off-by: Armando Ruocco <[email protected]>
Signed-off-by: Niccolò Fei <[email protected]>
Co-authored-by: Armando Ruocco <[email protected]>
Co-authored-by: Niccolò Fei <[email protected]>
(cherry picked from commit 8d3af4d)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport-requested ◀️ This pull request should be backported to all supported releases bug 🐛 Something isn't working lgtm This PR has been approved by a maintainer ok to merge 👌 This PR can be merged release-1.27 release-1.28 size:L This PR changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Extension and tablespace volume names can collide with each other and with system volumes

4 participants