Skip to content

Commit 73e4577

Browse files
thiyyakattakoverflow
authored andcommitted
Remove unneeded slice for nonTerminatingMachines
1 parent 032a1cb commit 73e4577

File tree

1 file changed

+6
-9
lines changed

1 file changed

+6
-9
lines changed

pkg/controller/machineset.go

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -336,21 +336,18 @@ func (c *controller) manageReplicas(ctx context.Context, allMachines []*v1alpha1
336336
}
337337

338338
var (
339-
nonTerminatingMachines []*v1alpha1.Machine
339+
numNonTerminatingMachines int
340340
machinesWithoutUpdateSuccessfulLabel []*v1alpha1.Machine
341341
)
342342
for _, m := range allMachines {
343343
if m.Status.CurrentStatus.Phase != v1alpha1.MachineTerminating {
344-
nonTerminatingMachines = append(nonTerminatingMachines, m)
345-
}
346-
}
347-
348-
for _, m := range nonTerminatingMachines {
349-
if m.Labels[v1alpha1.LabelKeyNodeUpdateResult] != v1alpha1.LabelValueNodeUpdateSuccessful {
350-
machinesWithoutUpdateSuccessfulLabel = append(machinesWithoutUpdateSuccessfulLabel, m)
344+
numNonTerminatingMachines++
345+
if m.Labels[v1alpha1.LabelKeyNodeUpdateResult] != v1alpha1.LabelValueNodeUpdateSuccessful {
346+
machinesWithoutUpdateSuccessfulLabel = append(machinesWithoutUpdateSuccessfulLabel, m)
347+
}
351348
}
352349
}
353-
nonTerminatingMachinesDiff := len(nonTerminatingMachines) - int(machineSet.Spec.Replicas)
350+
nonTerminatingMachinesDiff := numNonTerminatingMachines - int(machineSet.Spec.Replicas)
354351
machinesWithoutUpdateSuccessfulLabelDiff := len(machinesWithoutUpdateSuccessfulLabel) - int(machineSet.Spec.Replicas)
355352

356353
// During in-place updates, ScaleUps are disabled in the oldMachineSet and

0 commit comments

Comments
 (0)