Skip to content

Set the status to READY when a Database, Schema or Role is already up to date - #91

Merged
ThoSap merged 4 commits into
mainfrom
fix-status-stays-pending-when-up-to-date
Oct 25, 2026
Merged

ThoSap merged 4 commits into
mainfrom
fix-status-stays-pending-when-up-to-date

Conversation

@ThoSap

@ThoSap ThoSap commented Oct 25, 2026

Copy link
Copy Markdown
Member

Fixes #89

DatabaseReconciler, SchemaReconciler and RoleReconciler returned UpdateControl.noUpdate() when the PostgreSQL object already matched the spec. The reconcile did not write the status, so a PENDING or ERROR phase stayed after its cause went away. On a test cluster, 21 resources showed PENDING for 40 days after a short outage of their ClusterConnection, although each reconcile logged "up-to-date".

What changed

  1. The "up-to-date" branch writes the status. It sets READY, clears the message and returns UpdateControl.patchStatus(resource), as GrantReconciler, DefaultPrivilegeReconciler and ClusterConnectionReconciler already do, and as the Garage Operator does.
  2. lastProbeTime and observedGeneration are written on each reconcile. Before, noUpdate() also dropped them. After a spec change that needed no SQL statement, observedGeneration stayed at the old generation.
  3. New tests for all six resources. Database, Schema, Role, Grant and DefaultPrivilege point clusterRef to a missing ClusterConnection, so the operator sets PENDING, and then point it back. ClusterConnection changes its port to a closed port, so the operator sets ERROR, and then restores it. Each test expects READY at the end.

Consequences

  • Each reconcile now does one status write, also when nothing changed. This happens at each resync and at each restart. generation-aware: true filters the status events, so the write does not start a new reconcile.
  • An "up-to-date" reconcile clears the message. A message such as "Database owner changed [...]" stays only until the next reconcile.

Checks that CI cannot do

  • Without the fix in the three reconcilers, the new Database, Schema and Role tests fail. Each one times out when clusterRef points back, because observedGeneration is never written. The new Grant, DefaultPrivilege and ClusterConnection tests guard behavior that was already correct.

Related

Other changes

  • var where the same type is inferred, and formatting of a few test files. These changes do not change the behavior.

Without a status patch, a PENDING or ERROR phase stayed after its cause
went away, because the reconcile found nothing to change.

Assisted-by: Claude:claude-opus-5-5
@ThoSap ThoSap self-assigned this Oct 25, 2026
@ThoSap
ThoSap force-pushed the fix-status-stays-pending-when-up-to-date branch from fe662b0 to 9400f48 Compare October 25, 2026 14:33
@ThoSap
ThoSap merged commit 820caff into main Oct 25, 2026
4 checks passed
@ThoSap
ThoSap deleted the fix-status-stays-pending-when-up-to-date branch October 25, 2026 14:38
@ThoSap ThoSap added the bug Something isn't working label Oct 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Database, Schema and Role stay PENDING or ERROR when the PostgreSQL object is already up to date

1 participant