Skip to content

Commit 619ae36

Browse files
controller: update is node done check to handle image mode disabling case
1 parent 7a56cf0 commit 619ae36

File tree

2 files changed

+28
-4
lines changed

2 files changed

+28
-4
lines changed

pkg/controller/common/layered_node_state.go

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,16 @@ func NewLayeredNodeState(n *corev1.Node) *LayeredNodeState {
2626
return &LayeredNodeState{node: n}
2727
}
2828

29-
// Checks if the node is done "working" and that the node is targeting is MachineConfig
30-
// determined by the pool. If in layered mode, the image annotations are also checked
31-
// checked against the OCL objects.
29+
// Checks if the node is done "working." For a node in both layered and non-layered MCPs, the
30+
// node's state annotation must be "Done" and it must be targeting the correct MachineConfig. For
31+
// `layered` MCPs, the node's desired image annotation must match the image defined in the
32+
// MachineOsConfig and the desired MachineConfig must match the config version defined in the
33+
// MachineOSBuild. For non-layered MCPs, the node must not have a desired image annotation value.
3234
func (l *LayeredNodeState) IsDone(mcp *mcfgv1.MachineConfigPool, layered bool, mosc *mcfgv1.MachineOSConfig, mosb *mcfgv1.MachineOSBuild) bool {
3335
if layered {
3436
return l.IsNodeDone() && l.IsDesiredMachineConfigEqualToPool(mcp) && l.IsDesiredEqualToBuild(mosc, mosb)
3537
}
36-
return l.IsNodeDone() && l.IsDesiredMachineConfigEqualToPool(mcp)
38+
return l.IsNodeDone() && l.IsDesiredMachineConfigEqualToPool(mcp) && !l.IsDesiredImageAnnotationPresentOnNode()
3739
}
3840

3941
// The original behavior of getUnavailableMachines is: getUnavailableMachines

pkg/controller/node/status_test.go

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -287,6 +287,28 @@ func TestGetUpdatedMachines(t *testing.T) {
287287
newNode("node-1", machineConfigV1, machineConfigV1),
288288
newNodeWithReady("node-2", machineConfigV1, machineConfigV1, corev1.ConditionTrue),
289289
},
290+
}, {
291+
name: "Pool with image mode disabling, one node updating, 2 nodes not not acted upon",
292+
nodes: []*corev1.Node{
293+
newLayeredNode("node-0", machineConfigV0, machineConfigV0, imageV1, ""),
294+
newLayeredNode("node-1", machineConfigV0, machineConfigV0, imageV1, imageV1),
295+
newLayeredNode("node-2", machineConfigV0, machineConfigV0, imageV1, imageV1),
296+
},
297+
currentConfig: machineConfigV0,
298+
updated: nil,
299+
layered: false,
300+
}, {
301+
name: "Pool with image mode disabling, one node updated, 1 node updating, 1 node not acted upon",
302+
nodes: []*corev1.Node{
303+
newNode("node-0", machineConfigV0, machineConfigV0),
304+
newLayeredNode("node-1", machineConfigV0, machineConfigV0, imageV1, ""),
305+
newLayeredNode("node-2", machineConfigV0, machineConfigV0, imageV1, imageV1),
306+
},
307+
currentConfig: machineConfigV0,
308+
updated: []*corev1.Node{
309+
newNode("node-0", machineConfigV0, machineConfigV0),
310+
},
311+
layered: false,
290312
},
291313
}
292314

0 commit comments

Comments
 (0)