-
Notifications
You must be signed in to change notification settings - Fork 25
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
Handle edge case as described in issue #328 #335
base: machine-controller-manager-provider
Are you sure you want to change the base?
Handle edge case as described in issue #328 #335
Conversation
4609e3c
to
b10e0d9
Compare
var collectiveError error | ||
for _, machineDeployment := range machineDeployments { | ||
// ignore the machine deployment if it is in rolling update | ||
if !isRollingUpdateFinished(machineDeployment) { |
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.
What happens when a machine deployment is paused/frozen?
if machine.Status.CurrentStatus.Phase == v1alpha1.MachineTerminating || machine.Status.CurrentStatus.Phase == v1alpha1.MachineFailed { | ||
continue | ||
} | ||
if machine.Annotations != nil && machine.Annotations[machinePriorityAnnotation] != defaultPriorityValue { |
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.
Instead use:
if machine.Annotations != nil && machine.Annotations[machinePriorityAnnotation] == 1 {
annotatedMachines = append(annotatedMachines, machine)
}
And maybe you can create a constant for 1 to give it a semantically meaningful name.
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.
Please use annotVal, ok := machine.Annotations[machinePriorityAnnotation]
in map to avoid possible panic.
collectiveError = errors.Join(collectiveError, err) | ||
continue | ||
} | ||
var annotatedMachines []*v1alpha1.Machine |
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.
can you instead use machinesMarkedForDeletion
instead of annotatedMachines
?
What this PR does / why we need it:
This PR modifies the
Refresh
method of CA to reset the priority annotation on the machine objects only if the number of annotated machines is more than desired. The desired count istotalMachines - mcd.Spec.Replicas
.Terminating
andFailed
machines are excluded while calculating the total number of annotated machines.Which issue(s) this PR fixes:
Fixes #328
Special notes for your reviewer:
Release note: