Skip to content

fix(operator): requeue with a delay when the ObjectStore is missing - #1241

Open
shanurwan wants to merge 1 commit into
cloudnative-pg:mainfrom
shanurwan:fix/requeue-missing-objectstore
Open

shanurwan wants to merge 1 commit into
cloudnative-pg:mainfrom
shanurwan:fix/requeue-missing-objectstore

Conversation

@shanurwan

Copy link
Copy Markdown

Closes #1236

When a Cluster refers to an ObjectStore that does not exist yet, the pre-reconcile hook returns BEHAVIOR_REQUEUE with no RequeueAfter. The operator turns that into StopReconciliation: true with ctrl.Result{RequeueAfter: 0}, which controller-runtime does not requeue, so the Cluster stays without instances until something changes it.

This happens whenever both objects are applied together and the Cluster lands first, for example from a Helm chart (unknown kinds are sorted alphabetically) or a GitOps tool applying one directory.

Change

The hook now sets RequeueAfter to 10 seconds when the ObjectStore is not found. It is the only BEHAVIOR_REQUEUE path in the plugin.

Tests

  • Unit (internal/cnpgi/operator/reconciler_test.go): Pre returns a requeue with a non-zero delay when the ObjectStore is missing, continues once it exists, and continues for kinds other than Cluster. The first test fails with the delay set back to 0.
  • E2E (test/e2e/internal/tests/objectstoreorder): creates the Cluster, checks that no instance appears for 30 s, creates the ObjectStore, then waits for the Cluster to become ready without touching it and checks that its generation is unchanged.

I ran the new e2e spec on k3s v1.35 with CloudNativePG 1.30.1, against the released plugin and against an image built from this branch:

Plugin Result
v0.16.0 Failed: Cluster not ready 600 s after the ObjectStore was created
this branch Passed: Cluster ready 40 s after the ObjectStore was created (70 s spec)

With v0.16.0 the operator logs Pre-reconcile hook stopped the reconciliation loop with "Requeue":false,"RequeueAfter":0 and nothing follows, as described in the issue.

golangci-lint v2.15.0 reports 0 issues and the unit tests pass. I have not run the full e2e suite locally.

When a Cluster refers to an ObjectStore that does not exist yet, the
pre-reconcile hook asked for a requeue without a delay. The operator
maps that to a stopped reconciliation with RequeueAfter 0, which
controller-runtime does not requeue, so the Cluster never got any
instance until something changed it. This happens when both objects
are applied together and the Cluster lands first, as with Helm or a
GitOps tool.

Set RequeueAfter to 10 seconds in that case, and add a unit test for
the Pre hook and an e2e test that creates the Cluster before its
ObjectStore.

Closes cloudnative-pg#1236

Signed-off-by: Wan Nur Shafiqah <[email protected]>
@shanurwan
shanurwan requested a review from a team as a code owner November 14, 2026 14:30

This branch has not been deployed

No deployments
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.

Cluster never reconciles when created before its ObjectStore: requeue without RequeueAfter is dropped

1 participant