reconcile: wait till PVC is in bound phase#1971
Open
AndrewChubatiuk wants to merge 1 commit intomasterfrom
Open
reconcile: wait till PVC is in bound phase#1971AndrewChubatiuk wants to merge 1 commit intomasterfrom
AndrewChubatiuk wants to merge 1 commit intomasterfrom
Conversation
vrutkovs
reviewed
Mar 16, 2026
| } | ||
|
|
||
| return updatePVC(ctx, rclient, &existingObj, newObj, prevObj, owner) | ||
| func waitForPVCBound(ctx context.Context, rclient client.Client, nsn types.NamespacedName, generation int64) error { |
Collaborator
There was a problem hiding this comment.
Lets add unit tests for this function
| if !pvc.DeletionTimestamp.IsZero() { | ||
| return true, fmt.Errorf("cannot wait for PVC=%s, which is being terminated", nsn.String()) | ||
| } | ||
| if generation > pvc.Generation { |
Collaborator
There was a problem hiding this comment.
Not sure why we need generation here at all - and why would PVC generation match the deployment?
Contributor
There was a problem hiding this comment.
4 issues found across 3 files
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="internal/controller/operator/factory/reconcile/reconcile.go">
<violation number="1" location="internal/controller/operator/factory/reconcile/reconcile.go:27">
P1: The new PVC wait uses a hardcoded 5s timeout, so PVC binding can fail much earlier than the operator's configured readiness deadlines.</violation>
</file>
<file name="internal/controller/operator/factory/reconcile/statefulset_pvc_expand.go">
<violation number="1" location="internal/controller/operator/factory/reconcile/statefulset_pvc_expand.go:124">
P1: `waitForPVCBound` is called with the StatefulSet name instead of the PVC name, so it polls a non-existent PVC and times out.</violation>
</file>
<file name="internal/controller/operator/factory/reconcile/pvc.go">
<violation number="1" location="internal/controller/operator/factory/reconcile/pvc.go:51">
P1: Terminating PVCs no longer short-circuit successfully; this unconditional wait turns the previous skip path into a reconcile error.</violation>
<violation number="2" location="internal/controller/operator/factory/reconcile/pvc.go:51">
P1: Waiting for PVCs to reach `Bound` here can block valid `WaitForFirstConsumer` claims before their Deployment is created.</violation>
</file>
Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.
|
|
||
| var ( | ||
| pvcWaitBoundIntervalCheck = 1 * time.Second | ||
| pvcWaitReadyTimeout = 5 * time.Second |
Contributor
There was a problem hiding this comment.
P1: The new PVC wait uses a hardcoded 5s timeout, so PVC binding can fail much earlier than the operator's configured readiness deadlines.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At internal/controller/operator/factory/reconcile/reconcile.go, line 27:
<comment>The new PVC wait uses a hardcoded 5s timeout, so PVC binding can fail much earlier than the operator's configured readiness deadlines.</comment>
<file context>
@@ -23,6 +23,8 @@ import (
var (
+ pvcWaitBoundIntervalCheck = 1 * time.Second
+ pvcWaitReadyTimeout = 5 * time.Second
podWaitReadyIntervalCheck = 50 * time.Millisecond
appWaitReadyDeadline = 5 * time.Second
</file context>
internal/controller/operator/factory/reconcile/statefulset_pvc_expand.go
Show resolved
Hide resolved
| case !existingObj.CreationTimestamp.IsZero(): | ||
| generation = existingObj.Generation | ||
| } | ||
| return waitForPVCBound(ctx, rclient, nsn, generation) |
Contributor
There was a problem hiding this comment.
P1: Waiting for PVCs to reach Bound here can block valid WaitForFirstConsumer claims before their Deployment is created.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At internal/controller/operator/factory/reconcile/pvc.go, line 51:
<comment>Waiting for PVCs to reach `Bound` here can block valid `WaitForFirstConsumer` claims before their Deployment is created.</comment>
<file context>
@@ -20,24 +21,58 @@ import (
+ case !existingObj.CreationTimestamp.IsZero():
+ generation = existingObj.Generation
}
+ return waitForPVCBound(ctx, rclient, nsn, generation)
+}
</file context>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
fixes #1970
Summary by cubic
Wait for PVCs to reach the Bound phase before proceeding in reconcile and during StatefulSet PVC expansion. This removes race conditions where pods start while PVCs are still Pending or terminating.
waitForPVCBoundwith 1s polling and a 5s timeout; respects PVC generation and errors on unexpected phases or termination.updateSTSPVCto ensure expansions complete before continuing.Written for commit 83d01f0. Summary will update on new commits.