Repository navigation
Reject status patches computed from a stale AppWrapper - #2
Merged
Merged
Conversation
|
Automatic reviews are disabled for this repository. Configure in Code Review Settings. |
Status patches now carry the resourceVersion of the AppWrapper they were computed from (MergeFromWithOptimisticLock). A reconcile that read a stale copy from the cache gets a Conflict from the API server and does not write over a newer status. Reconcile treats a Conflict as a requeue, not as an error. The Resuming phase no longer counts a Conflict as a component create failure. With maxConcurrentReconciles > 1, a requeued AppWrapper goes to a free worker at once, often before the informer has delivered the previous status patch. Stale reads are then more frequent than with one worker.
mike-ainsel
force-pushed
the
fix/status-patch-optimistic-lock
branch
from
November 25, 2026 12:47
f15ebc1 to
b2710dc
Compare
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.
Stacked on #1 (base:
feat/v1.2.3-concurrency-quay-ci).Problem
Each reconcile reads the AppWrapper from the informer cache and writes status with a merge patch that has no
resourceVersioncheck (client.MergeFrom(orig)). If the key is requeued while a reconcile runs (for example by a Pod event), the next reconcile can start before the cache shows the previous status patch. It then decides from the old phase and writes over the newer status.Upstream has this problem with one worker too. With
maxConcurrentReconciles > 1from #1, a requeued AppWrapper goes to a free worker at once instead of waiting behind other AppWrappers, so stale reads happen more often.Change
Status().Patchcalls usestatusPatch(orig)=client.MergeFromWithOptions(orig, client.MergeFromWithOptimisticLock{}). The patch carries theresourceVersionof the copy the decision was made from. If the AppWrapper changed on the API server, the patch is rejected with409 Conflict.copyForStatusPatchalready copiesObjectMeta, and each successful patch writes the server response back intoaw, so sequential patches in one reconcile (createComponent) keep a currentresourceVersion.Reconcileis a thin wrapper: on a Conflict it requeues after 1s without an error (no "Reconciler error" log, no error backoff). The state machine moved unchanged toreconcile.createComponentsis returned as is. It is not counted as a create failure, so it cannot lead toCreateFailed/resetOrFail.MILAB.md: new row in the list of changes on top of upstream.Not covered:
Create/Deletecalls that a stale reconcile makes before its status patch is rejected. They are idempotent here (AlreadyExistswith our controller reference is accepted,NotFoundon delete counts as deleted). To remove stale reads fully, the AppWrapper would have to be read with the uncached reader at the start of each reconcile, at the cost of one API GET per reconcile.Tests
Reconcilereturns no error withRequeueAfter > 0. The next reconcile with a current copy moves the AppWrapper to Failed.go test -race ./internal/controller/... ./pkg/...passes locally (envtest 1.37.0).The
milabworkflow runs only for PRs intomilab, so CI does not run on this PR until #1 is merged and the base changes tomilab.