Skip to content

fix(databaserole): grant memberships after updating the role attributes - #11827

Open
armru wants to merge 1 commit into
mainfrom
dev/role-membership-order
Open

armru wants to merge 1 commit into
mainfrom
dev/role-membership-order

Conversation

@armru

@armru armru commented Nov 2, 2026

Copy link
Copy Markdown
Member

When updating an existing role, the DatabaseRole reconciler granted and revoked its memberships before running ALTER ROLE. From PostgreSQL 16 a membership granted without an INHERIT option takes it from the inherit attribute the role has at that moment, so a membership added in the same change that turned the attribute off was granted with inherit_option set, and the role inherited the privileges of that role although it was NOINHERIT.

The memberships are now applied after the attributes and the comment. The e2e test "applies the updated attributes in PostgreSQL" now sets inherit: false and inRoles: [pg_monitor] in the same patch and, from PostgreSQL 16, checks the inherit_option of the new membership: on kind with PostgreSQL 18.6 it is t on main and f with this change.

Closes #11824

When updating an existing role, the `DatabaseRole` reconciler granted
and revoked its memberships before running `ALTER ROLE`. From PostgreSQL
16 a membership granted without an `inherit` option takes it from the
`inherit` attribute the role has at that moment, so a membership added
in the same change that turned the attribute off was granted with
`inherit_option` set, and the role kept inheriting the privileges of
that role. Memberships are now applied after the attributes and the
comment.

Closes #11824

Signed-off-by: Armando Ruocco <[email protected]>
@armru
armru requested review from a team, NiccoloFei and litaocdl as code owners November 2, 2026 15:41
@cnpg-bot cnpg-bot added backport-requested ◀️ This pull request should be backported to all supported releases release-1.28 release-1.30 labels Nov 2, 2026
@github-actions

github-actions Bot commented Nov 2, 2026

Copy link
Copy Markdown
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

@armru armru removed the release-1.28 label Nov 2, 2026
@armru

armru commented Nov 2, 2026

Copy link
Copy Markdown
Member Author

/test

@github-actions

github-actions Bot commented Nov 2, 2026

Copy link
Copy Markdown
Contributor

@armru

armru commented Nov 3, 2026

Copy link
Copy Markdown
Member Author

/test

@github-actions

github-actions Bot commented Nov 3, 2026

Copy link
Copy Markdown
Contributor

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 release-1.30

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: DatabaseRole grants a new membership before applying the inherit attribute

2 participants