Skip to content

Conversation

@acumino
Copy link
Member

@acumino acumino commented Nov 17, 2025

What this PR does / why we need it:
Adds a check to ensure the new machine set is scaled up when the combined replicas of old and new machine sets are less than the desired deployment replicas. This basically ensures that if a machine is deleted manually from the old machine sets, a new machine should be created in the new machine set with the updated configuration.

Which issue(s) this PR fixes:
Fixes #

Special notes for your reviewer:

Release note:

Fixed an issue where deleting a machine from an old MachineSet could prevent proper scaling. The new MachineSet now scales up when total replicas (old + new) drop below the desired count, ensuring replacements are created with the updated configuration.

@gardener-robot gardener-robot added needs/review Needs review size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. labels Nov 17, 2025
@acumino acumino marked this pull request as ready for review November 17, 2025 14:18
@acumino acumino requested a review from a team as a code owner November 17, 2025 14:18
}

if oldMachinesCount+newMachineSet.Spec.Replicas < deployment.Spec.Replicas {
// Scale up the new machine set to the maximum possible replicas.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This term "maximum possible replicas" could be misleading. Maybe change it to say "deployment replicas"


if oldMachinesCount+newMachineSet.Spec.Replicas < deployment.Spec.Replicas {
// Scale up the new machine set to the maximum possible replicas.
klog.V(3).Infof("scale up the new machine set %s by %d to %d replicas", newMachineSet.Name, (deployment.Spec.Replicas - (oldMachinesCount + newMachineSet.Spec.Replicas)), deployment.Spec.Replicas-oldMachinesCount)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This log can be improved a bit. Can you update this to be like the following (feel free to instead add a log line you feel is better suited)

scaling up new machine set <name> from y to z (delta: x)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please also assign the expression oldMachinesCount + newMachineSet.Spec.Replicas to variable desiredReplicas to avoid excessive repeat of this expression.

Copy link
Member

@elankath elankath left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks for the fix.

@gardener-robot gardener-robot added the needs/changes Needs (more) changes label Dec 16, 2025
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/review Needs review size/XS Denotes a PR that changes 0-9 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants