Fix reconcile loop when Postgres CR is not found#284
Fix reconcile loop when Postgres CR is not found#284pcallewaert wants to merge 2 commits intomasterfrom
Conversation
pretzelmaker
left a comment
There was a problem hiding this comment.
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.
b8223ab to
6878317
Compare
|
@pretzelmaker Great feedback! I implemented the cross resource watch. Is this what you were thinking about? |
This should resolve the issue in #115