Skip to content

AB-449 PostgreSQL Operator: Grant, Database and Schema CRD - #2

Merged
ThoSap merged 31 commits into
mainfrom
ab-449-postgresql-operator-grant-and-db
Jan 22, 2026
Merged

AB-449 PostgreSQL Operator: Grant, Database and Schema CRD#2
ThoSap merged 31 commits into
mainfrom
ab-449-postgresql-operator-grant-and-db

Conversation

@ThoSap

@ThoSap ThoSap commented Jan 12, 2026

Copy link
Copy Markdown
Member

No description provided.

@ThoSap ThoSap self-assigned this Jan 12, 2026
@linear

linear Bot commented Jan 12, 2026

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

  • Role management
  • Grant management
  • Database management

@ThoSap
ThoSap force-pushed the ab-449-postgresql-operator-grant-and-db branch from 6b80a96 to 8d54cfe Compare January 14, 2026 15:01
@ThoSap ThoSap changed the title AB-449 PostgreSQL Operator: Grant and Database CRD AB-449 PostgreSQL Operator: Grant, Database and Schema CRD Jan 16, 2026
@ThoSap
ThoSap requested a review from Copilot January 16, 2026 14:44

This comment was marked as outdated.

@ThoSap
ThoSap requested a review from Copilot January 16, 2026 14:49

This comment was marked as outdated.

@ThoSap
ThoSap requested a review from Copilot January 16, 2026 14:56

This comment was marked as outdated.

…Reconciler.java

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@ThoSap
ThoSap requested a review from Copilot January 16, 2026 14:58

This comment was marked as outdated.

@alexlanz alexlanz left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks really good! I like it.

}
}

// We do not actually delete the database if the reclaimPolicy is set to RETAIN, we only delete the CR instance

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this mean that the SDK has already a logic built in so that I can decide that when I say delete a DB it is acutally not really deleted? That would be nice.

@ThoSap ThoSap Jan 17, 2026

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, that is exactly what my current Cleaner<Database|Schema> interface implementation does.

The cleanup method only removes the CR instance including the PostgreSQL DB/Schema when the reclaimPolicy was set to Delete in the spec, else if it is set to Retain only the CR instance will be deleted but the DB/Schema will be untouched.

If an error happens in the cleanup phase, the cleanup will be retriggered in 60 seconds.

}

@Override
public DeleteControl cleanup(

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When will this method be called? Currently I don't see any usages.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This method is internally called by the operator when a CR instance is deleted.
We do not actually need to call this method ourselves, the Operator Framework does that for us.

@ThoSap
ThoSap requested a review from Copilot January 21, 2026 12:25

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 43 out of 62 changed files in this pull request and generated 1 comment.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread operator/src/main/java/it/aboutbits/postgresql/crd/grant/Grant.java Outdated
@ThoSap

ThoSap commented Jan 21, 2026

Copy link
Copy Markdown
Member Author

@alexlanz @mmalfertheiner since your last review, I basically just improved the tests, updated NullAway, and implemented your review feedback.

From #2 (comment) (see also for the next steps)

I did not add all the tests yet, and the CRD CEL validations for the other CRDs are not aligned everywhere.
I would like to add more tests, for example, creating a Grant, changing its privileges, deleting the Grant, and in all steps, check the permissions against the DB, or the CRD CEL validation tests, as I have done them in GrantReconcilerTest.

I will implement the CRD CEL validation tests for the other existing CRDs in a follow-up PR, else this PR gets way too big.

@ThoSap
ThoSap marked this pull request as ready for review January 21, 2026 12:36
@ThoSap
ThoSap merged commit 5228dfb into main Jan 22, 2026
1 check passed
@ThoSap
ThoSap deleted the ab-449-postgresql-operator-grant-and-db branch January 22, 2026 07:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants