Skip to content

Commit c332cca

Browse files
committed
usc: gracefully handle Nodes in no MCP
1 parent c4f7873 commit c332cca

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

pkg/updatestatus/nodeinformer.go

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,11 @@ func (c *nodeInformerController) sync(ctx context.Context, syncCtx factory.SyncC
111111

112112
mcpName := c.machineConfigPoolSelectorCache.whichMCP(labels.Set(node.Labels))
113113
if mcpName == "" {
114-
return fmt.Errorf("failed to determine which machine config pool the node %s belongs to", node.Name)
114+
// We assume that every node belongs to a MCP at all time.
115+
// Although conceptually the assumption might not be true (see https://docs.openshift.com/container-platform/4.17/machine_configuration/index.html#architecture-machine-config-pools_machine-config-overview),
116+
// we will wait to hear from our users the issues for cluster updates and will handle them accordingly by then.
117+
klog.V(2).Infof("Ignored node %s as it does not belong to any %d machine config pool(s)", node.Name, c.machineConfigPoolSelectorCache.len())
118+
return nil
115119
}
116120
klog.V(4).Infof("Node %s belongs to machine config pool %s", node.Name, mcpName)
117121

@@ -303,6 +307,12 @@ func (c *machineConfigPoolSelectorCache) forget(mcpName string) bool {
303307
return false
304308
}
305309

310+
func (c *machineConfigPoolSelectorCache) len() int {
311+
c.lock.Lock()
312+
defer c.lock.Unlock()
313+
return len(c.cache)
314+
}
315+
306316
func (c *nodeInformerController) reconcileAllNodes(queue workqueue.TypedRateLimitingInterface[any]) error {
307317
nodes, err := c.nodes.List(labels.Everything())
308318
if err != nil {

pkg/updatestatus/nodeinformer_test.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ package updatestatus
22

33
import (
44
"context"
5-
"fmt"
65
"testing"
76
"time"
87

@@ -1013,14 +1012,13 @@ func Test_sync_with_node(t *testing.T) {
10131012
},
10141013
},
10151014
{
1016-
name: "error",
1015+
name: "no error if a node belongs to no MCP",
10171016
node: &corev1.Node{
10181017
ObjectMeta: metav1.ObjectMeta{
10191018
Name: "worker-1",
10201019
Labels: map[string]string{"node-role.kubernetes.io/some": ""},
10211020
},
10221021
},
1023-
expectedErr: fmt.Errorf("failed to determine which machine config pool the node worker-1 belongs to"),
10241022
},
10251023
}
10261024

0 commit comments

Comments
 (0)