Skip to content

Commit aebcdbd

Browse files
Add in-place to machineset controller (oldMS)
1 parent fbdba20 commit aebcdbd

File tree

7 files changed

+1643
-451
lines changed

7 files changed

+1643
-451
lines changed

internal/controllers/machinedeployment/machinedeployment_rollout_planner_test.go

Lines changed: 245 additions & 169 deletions
Large diffs are not rendered by default.

internal/controllers/machinedeployment/machinedeployment_rollout_rollingupdate.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,19 @@ func (p *rolloutPlanner) reconcileReplicasPendingAcknowledgeMove(ctx context.Con
160160
}
161161
}
162162

163+
// reconcileNewMachineSet reconciles replica number for the new MS.
164+
// Note: In case of scale down this function does not make consideration about possible impacts on availability.
165+
// This is considered acceptable because historically it never led to any problem, but we might revisit this in the future
166+
// because some limitations of this approach are becoming more evident, e.g.
167+
//
168+
// when users scale down the MD, the operation might temporarily breach min availability
169+
//
170+
// There are code paths specifically added to prevent this issue to become more relevant when doing in-place updates;
171+
// e.g. the MS controller will give highest delete priority to machines still updating in-place,
172+
// which are also unavailable machines.
173+
//
174+
// Notably, there is also not agreement yet on a different way forward because e.g. limiting scale down of the
175+
// new MS could lead e.g. to completing in place upgrade of machines that will be otherwise deleted.
163176
func (p *rolloutPlanner) reconcileNewMachineSet(ctx context.Context) error {
164177
log := ctrl.LoggerFrom(ctx)
165178
allMSs := append(p.oldMSs, p.newMS)

internal/controllers/machineset/machineset_controller.go

Lines changed: 361 additions & 137 deletions
Large diffs are not rendered by default.

internal/controllers/machineset/machineset_controller_status_test.go

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1140,12 +1140,31 @@ func fakeMachine(name string, options ...fakeMachinesOption) *clusterv1.Machine
11401140
return p
11411141
}
11421142

1143+
func withOwnerMachineSet(msName string) fakeMachinesOption {
1144+
return func(m *clusterv1.Machine) {
1145+
m.OwnerReferences = []metav1.OwnerReference{
1146+
{
1147+
APIVersion: clusterv1.GroupVersion.String(),
1148+
Kind: "MachineSet",
1149+
Name: msName,
1150+
Controller: ptr.To(true),
1151+
},
1152+
}
1153+
}
1154+
}
1155+
11431156
func withCreationTimestamp(t time.Time) fakeMachinesOption {
11441157
return func(m *clusterv1.Machine) {
11451158
m.CreationTimestamp = metav1.Time{Time: t}
11461159
}
11471160
}
11481161

1162+
func withMachineFinalizer() fakeMachinesOption {
1163+
return func(m *clusterv1.Machine) {
1164+
m.Finalizers = []string{clusterv1.MachineFinalizer}
1165+
}
1166+
}
1167+
11491168
func withDeletionTimestamp() fakeMachinesOption {
11501169
return func(m *clusterv1.Machine) {
11511170
m.DeletionTimestamp = ptr.To(metav1.Time{Time: time.Now()})
@@ -1158,6 +1177,18 @@ func withStaleDeletionTimestamp() fakeMachinesOption {
11581177
}
11591178
}
11601179

1180+
func withMachineLabels(labels map[string]string) fakeMachinesOption {
1181+
return func(m *clusterv1.Machine) {
1182+
m.Labels = labels
1183+
}
1184+
}
1185+
1186+
func withMachineAnnotations(annotations map[string]string) fakeMachinesOption {
1187+
return func(m *clusterv1.Machine) {
1188+
m.Annotations = annotations
1189+
}
1190+
}
1191+
11611192
func withStaleDrain() fakeMachinesOption {
11621193
return func(m *clusterv1.Machine) {
11631194
if m.Status.Deletion == nil {
@@ -1172,3 +1203,17 @@ func withCondition(c metav1.Condition) fakeMachinesOption {
11721203
conditions.Set(m, c)
11731204
}
11741205
}
1206+
1207+
func withHealthyStatus() fakeMachinesOption {
1208+
return func(m *clusterv1.Machine) {
1209+
m.Status = clusterv1.MachineStatus{
1210+
NodeRef: clusterv1.MachineNodeReference{Name: "some-node"},
1211+
Conditions: []metav1.Condition{
1212+
{
1213+
Type: clusterv1.MachineNodeHealthyCondition,
1214+
Status: metav1.ConditionUnknown,
1215+
},
1216+
},
1217+
}
1218+
}
1219+
}

0 commit comments

Comments
 (0)