Skip to content

Fix reconcile loop when Postgres CR is not found#284

Merged
pcallewaert merged 2 commits into
masterfrom
fix/fix-reconcile-loop
May 19, 2026
Merged

Fix reconcile loop when Postgres CR is not found#284
pcallewaert merged 2 commits into
masterfrom
fix/fix-reconcile-loop

Conversation

@pcallewaert

Copy link
Copy Markdown
Contributor

This should resolve the issue in #115

@pcallewaert pcallewaert self-assigned this Dec 24, 2025
@pcallewaert pcallewaert marked this pull request as ready for review December 24, 2025 09:49

@pretzelmaker pretzelmaker 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.

Thanks for taking this on! I think this is a great start.

I did notice that by returning ctrl.Result{}, nil in the scenario that the Postgres CR is not found, eventual consistency will be broken. Let me explain.

Currently, if a user applies a Postgres CR and a PostgresUser CR at the same time, or if the Posgtres CR is created after the user, the code will catch that the database is missing and the PostgresUser will not get reconciled again until the CR is updated or the operator is restarted. This breaks the idea of eventual consistency.

I think best way to go about addressing this issue in the "kubernetes way" would be to have a cross-resource watch of the Postgres CR in the SetupWithManager function. This way, PostgresUsers will only get created once changes on Postgres CRs are detected. There are pros/cons to this approach, such as a situation where the Postgres database is not managed by the operator, but we should be able to account for this.

@pcallewaert pcallewaert force-pushed the fix/fix-reconcile-loop branch from b8223ab to 6878317 Compare February 4, 2026 14:47
@pcallewaert

Copy link
Copy Markdown
Contributor Author

@pretzelmaker Great feedback! I implemented the cross resource watch. Is this what you were thinking about?

@pcallewaert pcallewaert requested a review from hitman99 February 4, 2026 14:59

@hitman99 hitman99 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.

LGTM

@pcallewaert pcallewaert force-pushed the fix/fix-reconcile-loop branch from b386bcf to 569de9f Compare May 19, 2026 08:55
@pcallewaert pcallewaert merged commit 8dda714 into master May 19, 2026
3 checks passed
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.

3 participants