[master] Fix preservation reconciliation to prevent deviation from regular flow for non-preservation-bound machines and prevent machines getting stuck in creation flow beyond CreationTimeout#1118
Draft
gardener-ci-robot wants to merge 20 commits into
Conversation
…eservation state.
…hase. Ignore node not found errors.
…ines is not modified by `manageMachinePreservation`
…ss function calls.
…n manageMachinePreservation: This call is made to uncordon nodes that are preserved with preserve=now and the machine has recovered to Running. Preservation is not stopped in this case.
… reduced when possible
…edByMCM` to `PreserveMachineAnnotationValueAutoPreserved`
- nits - if not found, machine annotation value must be enforced - if machine annotation value is invalid, log and continue assuming it does not exist - gate `removePreserveAnnotationOnMachine` when node is not found
…encing happens in future edits. Add removed test.
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
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.
What this PR does / why we need it:
The previous implementation had several correctness issues in the machine preservation flow:
Runningmachine with a cordoned backing node — even one cordoned for reasons unrelated to preservation (e.g. Cluster Autoscaler scale-down) — would be unconditionally uncordoned on every reconcile pass.LastAppliedNodePreserveValueAnnotationsync in the defer compared annotations on a clone that had already been updated via UpdateStatus calls insidepreserveMachine/stopPreservationIfActive. Because UpdateStatus returns the server's stored metadata (not the in-memory mutation), the annotation diff was never detected and the sync was silently dropped. On paths where the sync did fire, it was using a stale ResourceVersion, producing spurious conflict errors.This PR fixes all of the above by:
preserveStateInfo structpopulated bygetPreserveStateInfoat the start of each reconcile, reading node and machine annotation state in a single pass and storing it for the rest of the function. This eliminates the double lister read and decouples the annotation sync from the defer.isMachinePreservationBoundgate: machines with no preservation state (noPreserveExpiryTime, no preserve annotation on machine or node, noLastAppliedNodePreserveValueAnnotation) skip the entire preservation flow andreturn LongRetry, nilimmediately.LastAppliedNodePreserveValueAnnotationsync to an explicitupdatePreserveAnnotationOnMachinecall at the end of the function viashouldAnnotationsBeUpdatedOnMachine, rather than a defer that compared potentially stale annotation maps.stopPreservationIfActive(step 4), so it fires only when preservation is actively being stopped for aRunning machine— not on every reconcile of any active machine. ThemanageMachinePreservationpath retains a narrower uncordon call gated on!preservationStopped && PreserveExpiryTime != nil && Phase == Runningto handle the case wherepreserveMachineis called on aRunningmachine (e.g.preserve=nowset by user).IsNotFoundhandling in the defer so transient not-found errors during preservation (e.g. machine deleted mid-reconcile) returnLongRetryrather thanShortRetry.removePreservationRelatedAnnotationsOnNode(now returns*corev1.Node) so that the subsequent uncordon step instopPreservationIfActiveoperates on a current node object rather than a potentially stale one.PreventAutoPreserveAnnotationValuesset in machineutils (it was identical toAllowedPreserveAnnotationValuesminus "");manageAutoPreservationOfFailedMachinesin machineset.go now usesAllowedPreserveAnnotationValuesdirectly.Which issue(s) this PR fixes:
Fixes #1110
Special notes for your reviewer:
Release note: