Repository navigation
Description
Is there an existing issue already for this bug?
- I have searched for an existing issue, and could not find anything. I believe this is a new bug.
I have read the troubleshooting guide
- I have read the troubleshooting guide and I think this is a new bug.
I am running a supported version of CloudNativePG
- I have read the troubleshooting guide and I think this is a new bug.
Contact Details
No response
Version
trunk (main)
What version of Kubernetes are you using?
1.37
What is your Kubernetes environment?
Self-managed: kind (evaluation)
How did you install the operator?
YAML manifest
What happened?
When a single change to a DatabaseRole turns off its inherit attribute
and adds a role to inRoles, the operator grants the new membership 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 the membership is granted with the old value.
Applying the DatabaseRole below, and then changing it to inherit: false
and inRoles: [pg_monitor] in one update, leaves app_role with
rolinherit set to false, as requested, but with a pg_monitor membership
whose inherit_option is true: the role inherits the privileges of
pg_monitor although it is NOINHERIT.
I expected the membership to take the inherit attribute of the updated
role, as it does when the two changes are applied one after the other.
Every release with DatabaseRole, introduced in 1.30.0 (#6155), is
affected on PostgreSQL 16 and later.
Cluster resource
apiVersion: postgresql.cnpg.io/v1
kind: Cluster
metadata:
name: cluster-example
spec:
instances: 1
imageName: ghcr.io/cloudnative-pg/postgresql:18.6-system-trixie
storage:
size: 1Gi
---
apiVersion: postgresql.cnpg.io/v1
kind: DatabaseRole
metadata:
name: app-role
spec:
cluster:
name: cluster-example
name: app_role
login: true
inherit: trueRelevant log output
# Reproduced in the e2e suite against main (role "update-attrs-6785"):
# after one patch setting `inherit: false` and `inRoles: [pg_monitor]`,
# once the DatabaseRole reports `applied: true`
expected query "SELECT am.inherit_option FROM pg_catalog.pg_auth_members AS am JOIN pg_catalog.pg_roles AS r ON r.oid = am.member WHERE am.roleid = 'pg_monitor'::regrole AND r.rolname = 'update-attrs-6785'" to return "f" (in database "postgres")
Expected
<string>: t
to be equivalent to
<string>: fCode of Conduct
- I agree to follow this project's Code of Conduct
Activity
fix(databaserole): grant memberships after updating the role attributes