Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions pkg/controller/deployment_inplace.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
"maps"
"slices"
"sort"
"strings"

"github.com/gardener/machine-controller-manager/pkg/apis/machine/v1alpha1"
"github.com/gardener/machine-controller-manager/pkg/controller/autoscaler"
Expand Down Expand Up @@ -206,6 +207,7 @@ func (dc *controller) syncMachineSets(ctx context.Context, oldMachineSets []*v1a
Effect: v1.TaintEffectNoSchedule,
})

klog.V(3).Infof("removing inplace labels/annotations and uncordoning node %s", node.Name)
_, err = dc.targetCoreClient.CoreV1().Nodes().Update(ctx, node, metav1.UpdateOptions{})
if err != nil {
return fmt.Errorf("failed to remove inplace labels/annotations and uncordon node %s: %w", node.Name, err)
Expand Down Expand Up @@ -301,7 +303,7 @@ func (dc *controller) reconcileOldMachineSetsInPlace(ctx context.Context, allMac
maxUnavailable := MaxUnavailable(*deployment)

minAvailable := deployment.Spec.Replicas - maxUnavailable
newMachineSetUnavailableMachineCount := newMachineSet.Spec.Replicas - newMachineSet.Status.AvailableReplicas
newMachineSetUnavailableMachineCount := max(0, newMachineSet.Spec.Replicas-newMachineSet.Status.AvailableReplicas)
oldMachineSetsMachinesUndergoingUpdate, err := dc.getMachinesUndergoingUpdate(oldMachineSets)
if err != nil {
return false, err
Expand Down Expand Up @@ -367,7 +369,7 @@ func (dc *controller) transferMachinesFromOldToNewMachineSet(ctx context.Context
}

cond := getMachineCondition(oldMachine, v1alpha1.NodeInPlaceUpdate)
if isUpdateNotSuccessful(cond, node.Labels) {
if isUpdateNotSuccessful(cond, node.Labels) || oldMachine.Status.CurrentStatus.Phase == v1alpha1.MachineInPlaceUpdating {
continue
}

Expand Down Expand Up @@ -525,7 +527,12 @@ func (dc *controller) labelMachinesToSelectedForUpdate(ctx context.Context, mach
return numOfMachinesSelectedForUpdate, err
}

klog.V(3).Infof("machines selected for drain %v", machines)
machinesName := make([]string, 0, len(machines))
for _, machine := range machines {
machinesName = append(machinesName, machine.Name)
}

klog.V(3).Infof("machines selected for drain %v", strings.Join(machinesName, ", "))

for _, machine := range machines {
// labels on the node are added cumulatively and we can find both candidate-for-update and selected-for-update labels on the node.
Expand Down
2 changes: 1 addition & 1 deletion pkg/controller/deployment_inplace_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ var _ = Describe("deployment_inplace", func() {
controlMachineObjects = append(controlMachineObjects, oldMachineSet, newMachineSet)

machines := []*machinev1.Machine{}
machines = append(machines, newMachinesFromMachineSet(int(data.setup.oldMachineSetReplicas), oldMachineSet, &machinev1.MachineStatus{}, nil, map[string]string{"key": "value"})...)
machines = append(machines, newMachinesFromMachineSet(int(data.setup.oldMachineSetReplicas), oldMachineSet, &machinev1.MachineStatus{CurrentStatus: machinev1.CurrentStatus{Phase: machinev1.MachineInPlaceUpdateSuccessful}}, nil, map[string]string{"key": "value"})...)
machines = append(machines, newMachinesFromMachineSet(int(data.setup.newMachineSetReplicas), newMachineSet, &machinev1.MachineStatus{}, nil, nil)...)
machinesWithUpdateSuccessful := 0
for i := range machines {
Expand Down