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
8 changes: 8 additions & 0 deletions pkg/controller/deployment_inplace.go
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,14 @@ func (dc *controller) reconcileNewMachineSetInPlace(ctx context.Context, oldMach
return scaled, err
}

totalReplicas := oldMachinesCount + newMachineSet.Spec.Replicas
if totalReplicas < deployment.Spec.Replicas {
// Scale up the new machine set to reach the desired replica count, considering old machines.
klog.V(3).Infof("scale up the new machine set %s from %d to %d replicas (delta: %d)", newMachineSet.Name, newMachineSet.Spec.Replicas, deployment.Spec.Replicas-oldMachinesCount, deployment.Spec.Replicas-totalReplicas)
scaled, _, err := dc.scaleMachineSetAndRecordEvent(ctx, newMachineSet, deployment.Spec.Replicas-oldMachinesCount, deployment)
return scaled, err
}

addedNewReplicasCount, err := dc.transferMachinesFromOldToNewMachineSet(ctx, oldMachineSets, newMachineSet, deployment)
if err != nil {
return false, fmt.Errorf("error while transferring machines from old to new machine set: %w", err)
Expand Down
10 changes: 10 additions & 0 deletions pkg/controller/deployment_inplace_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -368,6 +368,16 @@ var _ = Describe("deployment_inplace", func() {
scaled: true,
},
}),
Entry("scale up newMachineSet to max possible replicas when oldMachinesCount+newMachineSet.Spec.Replicas < deployment.Spec.Replicas", &data{
setup: setup{
oldMachineSetReplicas: 1,
newMachineSetReplicas: 1,
nodesWithUpdateSuccessful: 0,
},
expect: expect{
scaled: true,
},
}),
)
})

Expand Down
Loading