AB-449 PostgreSQL Operator: DefaultPrivilege CRD - #4
Conversation
AB-449 PostgreSQL Operator
Based on the research and PoC done in the ticket and PR https://github.com/aboutbits/minio-operator/pull/1 We most likely will use CloudNativePG AB-396 for the DB Setup and this operator to manage the access, e.g. PostgreSQL roles and grants. The scope of the operator is:
|
…eVersion is not synchronized in the operator primary cache
There was a problem hiding this comment.
Pull request overview
This pull request introduces a new DefaultPrivilege CRD (Custom Resource Definition) for the PostgreSQL Operator. The implementation follows a similar pattern to the existing Grant CRD but handles default privileges instead of direct grants. The changes also include refactoring privilege handling by moving GrantPrivilege to a shared Privilege enum and updating timeout configurations.
Changes:
- Introduces
DefaultPrivilegeCRD with reconciler, service, and object type support - Refactors
GrantPrivilegeto sharedPrivilegeenum in core package - Updates Quarkus version from 3.30.6 to 3.30.7
- Standardizes wait timeout values from 10 to 5 seconds across test creators
Reviewed changes
Copilot reviewed 24 out of 32 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| operator/src/main/java/it/aboutbits/postgresql/core/Privilege.java | Moved and renamed from GrantPrivilege to shared Privilege enum |
| operator/src/main/java/it/aboutbits/postgresql/crd/defaultprivilege/DefaultPrivilege.java | New CRD class for default privileges |
| operator/src/main/java/it/aboutbits/postgresql/crd/defaultprivilege/DefaultPrivilegeSpec.java | Specification class defining default privilege fields and validation rules |
| operator/src/main/java/it/aboutbits/postgresql/crd/defaultprivilege/DefaultPrivilegeObjectType.java | Enum defining supported object types (schema, table, sequence) for default privileges |
| operator/src/main/java/it/aboutbits/postgresql/crd/defaultprivilege/DefaultPrivilegeService.java | Service implementing grant/revoke operations for default privileges |
| operator/src/main/java/it/aboutbits/postgresql/crd/defaultprivilege/DefaultPrivilegeReconciler.java | Reconciler managing lifecycle of default privilege resources |
| operator/src/main/java/it/aboutbits/postgresql/crd/grant/*.java | Updated to use shared Privilege enum instead of GrantPrivilege |
| operator/src/test/java/it/aboutbits/postgresql/crd/defaultprivilege/DefaultPrivilegeReconcilerTest.java | Comprehensive test coverage for default privilege functionality |
| operator/src/test/java/it/aboutbits/postgresql/_support/testdata/persisted/creator/DefaultPrivilegeCreate.java | Test data creator for default privilege resources |
| gradle.properties | Updated Quarkus version to 3.30.7 |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| return DeleteControl.noFinalizerRemoval() | ||
| .rescheduleAfter(1, TimeUnit.SECONDS); |
There was a problem hiding this comment.
If you are wondering why I added this to every CRD cleanup callback method after the phase DELETING patchStatus call.
Without this, we will get the following error on CR instance deletion (and in the @BeforeEach test cleanup):
Deleting Role [resource=default/test-role-valid-until, spec.name=test-role-valid-until, status.phase=DELETING]
Uncaught error during event processing ExecutionScope{ resource id: ResourceID{name='test-role-nologin', namespace='default'}, version: 2422} - but another reconciliation will be attempted because a superseding event has been received or another retry attempt is pending.
io.javaoperatorsdk.operator.OperatorException: Exceeded maximum (10) retry attempts to patch resource: ResourceID{name='test-role-nologin', namespace='default'}
at io.javaoperatorsdk.operator.processing.event.ReconciliationDispatcher.conflictRetryingPatch(ReconciliationDispatcher.java:401)
at io.javaoperatorsdk.operator.processing.event.ReconciliationDispatcher.handleCleanup(ReconciliationDispatcher.java:274)
at io.javaoperatorsdk.operator.processing.event.ReconciliationDispatcher.handleDispatch(ReconciliationDispatcher.java:96)
at io.javaoperatorsdk.operator.processing.event.ReconciliationDispatcher.handleExecution(ReconciliationDispatcher.java:69)
at io.javaoperatorsdk.operator.processing.event.EventProcessor$ReconcilerExecutor.run(EventProcessor.java:483)
at java.base@25.0.2/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1090)
at java.base@25.0.2/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:614)
at java.base@25.0.2/java.lang.Thread.run(Thread.java:1474)
No description provided.