-
Notifications
You must be signed in to change notification settings - Fork 137
[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
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
gardener-prow
merged 20 commits into
gardener:master
from
gardener-ci-robot:cherry-pick-1111-to-master
Jul 24, 2026
Merged
Changes from all commits
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
6351898
Add gate to ensure preservation code is only run for machines with pr…
thiyyakat c69d06f
Uncordon node only if Machine is preservation-bound, and in Running p…
thiyyakat 715fa43
Return updated machine object from preservation functions to prevent …
thiyyakat 6efd2f0
Handle IsNotFound error in the defer function.
thiyyakat 023935c
Fix tests and defer function.
thiyyakat 9b26615
Add tests and code to ensure the flow for non-preservation bound mach…
thiyyakat 65e0edb
Add tests to cover uncordoning of machine when machines recover to Ru…
thiyyakat 418a543
Uncordon machines in `stopMachinePreservationIfActive` to allow retry.
thiyyakat b41a9de
Introduce struct preserveStateInfo to persist preservation state acro…
thiyyakat 866d00e
Remove "" as a valid preservation value
thiyyakat b8e4057
Add helper functions and simplify defer
thiyyakat c77bad5
Ensure machine preservation was not stopped before uncordoning node i…
thiyyakat c2f50d7
Minor code changes and test refactoring to ensure conflict errors are…
thiyyakat 22fc353
Address review comment: Rename `PreserveMachineAnnotationValuePreserv…
thiyyakat b4bdf32
Correct docstring for `PreserveMachineAnnotationValueFalse`
thiyyakat d534ef4
Log node name in `uncordonNodeIfCordoned`.
thiyyakat 96ebb55
Address review comments
thiyyakat f4ecd74
Address review comments - part 2
thiyyakat 21db791
Return machine object even on error so no accidental nil ptr de-refer…
thiyyakat cce877c
Address review comment: modify `getPreserveStateInfo` to return a val…
thiyyakat File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -920,7 +920,7 @@ func (c *controller) shouldFailedMachineBeTerminated(machine *v1alpha1.Machine) | |
| return true | ||
| } | ||
| switch preserveValue { | ||
| case machineutils.PreserveMachineAnnotationValueWhenFailed, machineutils.PreserveMachineAnnotationValueNow, machineutils.PreserveMachineAnnotationValuePreservedByMCM: // this is in case preservation process is not complete yet | ||
| case machineutils.PreserveMachineAnnotationValueWhenFailed, machineutils.PreserveMachineAnnotationValueNow, machineutils.PreserveMachineAnnotationValueAutoPreserved: // this is in case preservation process is not complete yet | ||
| return false | ||
| case machineutils.PreserveMachineAnnotationValueFalse: | ||
| return true | ||
|
|
@@ -949,7 +949,7 @@ func (c *controller) manageAutoPreservationOfFailedMachines(ctx context.Context, | |
| var others []*v1alpha1.Machine | ||
| for _, m := range machines { | ||
| // check if machine is already annotated for preservation, if yes, skip. Machine controller will take care of the rest. | ||
| if machineutils.IsMachineFailed(m) && !machineutils.PreventAutoPreserveAnnotationValues.Has(m.Annotations[machineutils.PreserveMachineAnnotationKey]) { | ||
| if machineutils.IsMachineFailed(m) && !machineutils.AllowedPreserveAnnotationValues.Has(m.Annotations[machineutils.PreserveMachineAnnotationKey]) { | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Introduce function |
||
| autoPreservationCandidates = append(autoPreservationCandidates, m) | ||
| } else { | ||
| others = append(others, m) | ||
|
|
@@ -978,7 +978,7 @@ func (c *controller) manageAutoPreservationOfFailedMachines(ctx context.Context, | |
| func (c *controller) stopAutoPreservationForMachines(ctx context.Context, machines []*v1alpha1.Machine, numToStop int) int { | ||
| var autoPreservedMachines []*v1alpha1.Machine | ||
| for _, m := range machines { | ||
| if m.Annotations[machineutils.PreserveMachineAnnotationKey] == machineutils.PreserveMachineAnnotationValuePreservedByMCM { | ||
| if m.Annotations[machineutils.PreserveMachineAnnotationKey] == machineutils.PreserveMachineAnnotationValueAutoPreserved { | ||
| autoPreservedMachines = append(autoPreservedMachines, m) | ||
| } | ||
| } | ||
|
|
@@ -998,7 +998,7 @@ func (c *controller) stopAutoPreservationForMachines(ctx context.Context, machin | |
| klog.V(2).Infof("Removing auto-preservation annotation from machine %q as AutoPreserveFailedMachineMax is breached", m.Name) | ||
| updatedMachine, err := machineutils.UpdateMachineWithRetries(ctx, c.controlMachineClient.Machines(m.Namespace), c.machineLister, m.Namespace, m.Name, removeAutoPreserveAnnotationFromMachine) | ||
| if err != nil { | ||
| klog.Warningf("Error removing %q=%q annotation from machine %q: %v.", machineutils.PreserveMachineAnnotationKey, machineutils.PreserveMachineAnnotationValuePreservedByMCM, m.Name, err) | ||
| klog.Warningf("Error removing %q=%q annotation from machine %q: %v.", machineutils.PreserveMachineAnnotationKey, machineutils.PreserveMachineAnnotationValueAutoPreserved, m.Name, err) | ||
| continue | ||
| } | ||
| autoPreservedMachines[index] = updatedMachine | ||
|
|
@@ -1011,7 +1011,7 @@ func addAutoPreserveAnnotationOnMachine(machineToUpdate *v1alpha1.Machine) error | |
| if machineToUpdate.Annotations == nil { | ||
| machineToUpdate.Annotations = make(map[string]string) | ||
| } | ||
| machineToUpdate.Annotations[machineutils.PreserveMachineAnnotationKey] = machineutils.PreserveMachineAnnotationValuePreservedByMCM | ||
| machineToUpdate.Annotations[machineutils.PreserveMachineAnnotationKey] = machineutils.PreserveMachineAnnotationValueAutoPreserved | ||
| return nil | ||
| } | ||
|
|
||
|
|
||
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
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
Oops, something went wrong.
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Kindly create function
machineutils.IsAutoPreserved(m *v1alpha.Machine). It is used in a dozen places not just here.