Repository navigation
Conversation
|
❗ By default, the pull request is configured to backport to all release branches.
|
|
/test |
|
@armru, here's the link to the E2E on CNPG workflow run: https://github.com/cloudnative-pg/cloudnative-pg/actions/runs/41474735649 |
ecdaa39 to
20cc41e
Compare
|
I had a look at the PR and I think we need to analyze carefully the consequences of this patch. Today, when a role is removed from inRoles, the operator runs a plain REVOKE, which removes only the grant made by the bootstrap superuser. Grants made by other roles survive with just a warning in the PostgreSQL log. In this PR we read the grantor and issues Both behaviors are right and wrong, for different reasons: Current behavior respects PG's ownership model, because the operator never removes what it didn't grant. But inRoles stops being the source of truth: after removing an entry, the role can keep the membership, and the privileges it inherits, through another role's grant. Behavior after this PR guarantees that the declared state matches the catalog, which is what pre-16 versions did. But it overrides other grantors' decisions, even though the operator can now tell its own grants apart. On upgrade it will remove existing grants made out of band, and a revoke can now fail with dependent privileges exist. Open questions before merging: which semantics the operator promises, whether to revoke only its own grants and report the rest (status or event), whether this should be opt-in, and how to handle dependent grants (RESTRICT vs CASCADE). Whatever we choose, we need to document it and call out the upgrade impact. |
From PostgreSQL 16 a membership can be granted once per grantor: every role holding the `ADMIN` option on a role can grant it again, and a `REVOKE` acts only on the grant of the grantor it names, which for a superuser defaults to the bootstrap superuser. Removing a role from `inRoles` therefore revoked only the grant the operator had made, and a membership granted by another role survived, both for inline managed roles and for a `DatabaseRole`. The memberships are now read with their grantor, and from PostgreSQL 16 the operator names it through `GRANTED BY` on each grant it revokes, so the role is no longer a member of a role it does not list. Before 16 a membership has a single grant, which a superuser `REVOKE` removes whoever granted it, so the statements there are unchanged. A revoke can now fail with `dependent privileges exist` when the member used its `ADMIN` option to grant the role to others, where before the membership was silently left in place. Closes #11825 Signed-off-by: Armando Ruocco <[email protected]>
20cc41e to
9dbb695
Compare
From PostgreSQL 16 a membership can be granted once per grantor: every role holding the
ADMINoption on a role can grant it again, and aREVOKEacts only on the grant of the grantor it names, which for a superuser defaults to the bootstrap superuser. Removing a role frominRoles, or finding a membership the role does not list, therefore revoked only the grant the operator had made, and a membership granted by another role survived with just a warning in the PostgreSQL log, both for inline managed roles and for aDatabaseRole.The memberships are now read with their grantor, and from PostgreSQL 16 the operator names it through
GRANTED BYon each grant it revokes. Before 16 a membership has a single grant, which a superuserREVOKEremoves whoever granted it, so the statements there are unchanged: on 14.24 and 15.19 the plainREVOKEleaves no row, while on 16.15 it leaves the grant of the other role. The major version comes from agetPostgresMajorVersionfunction set onRoleSynchronizerandDatabaseRoleReconcilerwhen they are built, asSubscriptionReconcileralready does.A revoke can now fail with
dependent privileges existwhen the member used itsADMINoption to grant the role to others, where before the membership was silently left in place.The managed roles e2e test gains a step, from PostgreSQL 16, where another role grants
pg_monitorto a managed role, first alone and then next to the grant of the operator. On kind with PostgreSQL 18.6 the step fails on main at the first case, where the membership survives, and passes with this change, which revokes every grant in both cases.This leaves alone the status counting a membership once per grant, #11624, which #11686 fixes.
Closes #11825