Skip to content
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

Open
wants to merge 2 commits into
base: machine-controller-manager-provider
Choose a base branch
from

Conversation

rishabh-11
Copy link

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 is totalMachines - mcd.Spec.Replicas. Terminating and Failed 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:

The Refresh method resets the priority annotation on machines with priority 1 to match the desired count. Refer to the PR for details on how the desired count is calculated.

@rishabh-11 rishabh-11 requested review from unmarshall and a team as code owners November 14, 2024 09:15
@gardener-robot gardener-robot added needs/review Needs review size/m Size of pull request is medium (see gardener-robot robot/bots/size.py) labels Nov 14, 2024
@gardener-robot-ci-1 gardener-robot-ci-1 added the reviewed/ok-to-test Has approval for testing (check PR in detail before setting this label because PR is run on CI/CD) label Nov 14, 2024
@gardener-robot-ci-3 gardener-robot-ci-3 added needs/ok-to-test Needs approval for testing (check PR in detail before setting this label because PR is run on CI/CD) and removed reviewed/ok-to-test Has approval for testing (check PR in detail before setting this label because PR is run on CI/CD) labels Nov 14, 2024
@gardener-robot-ci-2 gardener-robot-ci-2 added reviewed/ok-to-test Has approval for testing (check PR in detail before setting this label because PR is run on CI/CD) and removed reviewed/ok-to-test Has approval for testing (check PR in detail before setting this label because PR is run on CI/CD) labels Nov 14, 2024
var collectiveError error
for _, machineDeployment := range machineDeployments {
// ignore the machine deployment if it is in rolling update
if !isRollingUpdateFinished(machineDeployment) {

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 {

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.

Copy link

@elankath elankath Nov 15, 2024

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

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?

@gardener-robot gardener-robot added the needs/changes Needs (more) changes label Nov 15, 2024
@gardener-robot-ci-3 gardener-robot-ci-3 added the reviewed/ok-to-test Has approval for testing (check PR in detail before setting this label because PR is run on CI/CD) label Nov 20, 2024
@gardener-robot-ci-2 gardener-robot-ci-2 removed the reviewed/ok-to-test Has approval for testing (check PR in detail before setting this label because PR is run on CI/CD) label Nov 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs/changes Needs (more) changes needs/ok-to-test Needs approval for testing (check PR in detail before setting this label because PR is run on CI/CD) needs/review Needs review size/m Size of pull request is medium (see gardener-robot robot/bots/size.py)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Fix edge case mentioned in https://github.com/gardener/autoscaler/pull/215
7 participants