Skip to content

Commit a12814e

Browse files
committed
Address comments from reviews
1 parent 3af45bc commit a12814e

File tree

4 files changed

+24
-14
lines changed

4 files changed

+24
-14
lines changed

pkg/updatestatus/controlplaneinformer.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -62,9 +62,9 @@ func newControlPlaneInformerController(
6262

6363
controller := factory.New().
6464
// call sync on ClusterVersion changes
65-
WithInformersQueueKeysFunc(configApiQueueKeys, cvInformer).
65+
WithInformersQueueKeysFunc(controlPlaneInformerQueueKeys, cvInformer).
6666
// call sync on ClusterOperator changes with a filter
67-
WithFilteredEventsInformersQueueKeysFunc(configApiQueueKeys, clusterOperatorEventFilterFunc, coInformer).
67+
WithFilteredEventsInformersQueueKeysFunc(controlPlaneInformerQueueKeys, clusterOperatorEventFilterFunc, coInformer).
6868
WithSync(c.sync).
6969
ToController("ControlPlaneInformer", c.recorder)
7070

@@ -97,7 +97,7 @@ const (
9797
func (c *controlPlaneInformerController) sync(ctx context.Context, syncCtx factory.SyncContext) error {
9898
queueKey := syncCtx.QueueKey()
9999

100-
t, name, err := parseQueueKey(queueKey)
100+
t, name, err := parseControlPlaneInformerQueueKey(queueKey)
101101
if err != nil {
102102
return fmt.Errorf("failed to parse queue key: %w", err)
103103
}
@@ -470,15 +470,15 @@ func versionsFromHistory(history []configv1.UpdateHistory) ControlPlaneUpdateVer
470470
return versions
471471
}
472472

473-
func parseQueueKey(queueKey string) (string, string, error) {
473+
func parseControlPlaneInformerQueueKey(queueKey string) (string, string, error) {
474474
splits := strings.Split(queueKey, "/")
475475
if len(splits) != 2 {
476476
return "", "", fmt.Errorf("invalid queue key: %s", queueKey)
477477
}
478478
return splits[0], splits[1], nil
479479
}
480480

481-
func configApiQueueKeys(object runtime.Object) []string {
481+
func controlPlaneInformerQueueKeys(object runtime.Object) []string {
482482
if object == nil {
483483
return nil
484484
}

pkg/updatestatus/controlplaneinformer_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ func Test_sync_with_cv(t *testing.T) {
215215
now: func() metav1.Time { return now },
216216
}
217217

218-
queueKey := configApiQueueKeys(cv)[0]
218+
queueKey := controlPlaneInformerQueueKeys(cv)[0]
219219

220220
err := controller.sync(context.Background(), newTestSyncContext(queueKey))
221221
if err != nil {
@@ -391,14 +391,14 @@ func Test_configApiQueueKeys(t *testing.T) {
391391
}
392392
}()
393393

394-
actual := configApiQueueKeys(tc.object)
394+
actual := controlPlaneInformerQueueKeys(tc.object)
395395

396396
if diff := cmp.Diff(tc.expected, actual); diff != "" {
397397
t.Errorf("%s: key differs from expected:\n%s", tc.name, diff)
398398
}
399399

400400
if !tc.expectedPanic && len(actual) > 0 {
401-
kind, name, err := parseQueueKey(actual[0])
401+
kind, name, err := parseControlPlaneInformerQueueKey(actual[0])
402402
if err != nil {
403403
t.Errorf("%s: unexpected error raised:\n%v", tc.name, err)
404404
}
@@ -504,7 +504,7 @@ func Test_sync_with_co(t *testing.T) {
504504
now: func() metav1.Time { return now },
505505
}
506506

507-
queueKey := configApiQueueKeys(co)[0]
507+
queueKey := controlPlaneInformerQueueKeys(co)[0]
508508

509509
err := controller.sync(context.Background(), newTestSyncContext(queueKey))
510510
if err != nil {

pkg/updatestatus/nodeinformer.go

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ func newNodeInformerController(
7777
func (c *nodeInformerController) sync(ctx context.Context, syncCtx factory.SyncContext) error {
7878
queueKey := syncCtx.QueueKey()
7979

80-
t, name, err := parseQueueKey(queueKey)
80+
t, name, err := parseNodeInformerControllerQueueKey(queueKey)
8181
if err != nil {
8282
return fmt.Errorf("failed to parse queue key: %w", err)
8383
}
@@ -135,7 +135,7 @@ func (c *nodeInformerController) sync(ctx context.Context, syncCtx factory.SyncC
135135
if klog.V(4).Enabled() {
136136
msgForLog = fmt.Sprintf(" | msg=%s", string(msg.insight))
137137
}
138-
klog.V(2).Infof("CPI :: Syncing %s %s%s", t, name, msgForLog)
138+
klog.V(2).Infof("NI :: Syncing %s %s%s", t, name, msgForLog)
139139
c.sendInsight(msg)
140140
return nil
141141
}
@@ -328,7 +328,9 @@ func assessNode(node *corev1.Node, mcp *machineconfigv1.MachineConfigPool, machi
328328
}
329329

330330
desiredConfig, ok := node.Annotations[mco.DesiredMachineConfigAnnotationKey]
331-
currentVersion, foundCurrent := machineConfigVersions[node.Annotations[mco.CurrentMachineConfigAnnotationKey]]
331+
noDesiredOnNode := !ok
332+
currentConfig := node.Annotations[mco.CurrentMachineConfigAnnotationKey]
333+
currentVersion, foundCurrent := machineConfigVersions[currentConfig]
332334
desiredVersion, foundDesired := machineConfigVersions[desiredConfig]
333335

334336
lns := mco.NewLayeredNodeState(node)
@@ -337,7 +339,7 @@ func assessNode(node *corev1.Node, mcp *machineconfigv1.MachineConfigPool, machi
337339
isDegraded := isNodeDegraded(node)
338340
isUpdated := foundCurrent && mostRecentVersionInCVHistory == currentVersion &&
339341
// The following condition is to handle the multi-arch migration because the version number stays the same there
340-
(!ok || node.Annotations[mco.CurrentMachineConfigAnnotationKey] == desiredConfig)
342+
(noDesiredOnNode || currentConfig == desiredConfig)
341343

342344
// foundCurrent makes sure we don't blip phase "updating" for nodes that we are not sure
343345
// of their actual phase, even though the conservative assumption is that the node is
@@ -377,6 +379,14 @@ const (
377379
nodeKindName = "Node"
378380
)
379381

382+
func parseNodeInformerControllerQueueKey(queueKey string) (string, string, error) {
383+
splits := strings.Split(queueKey, "/")
384+
if len(splits) != 2 {
385+
return "", "", fmt.Errorf("invalid queue key: %s", queueKey)
386+
}
387+
return splits[0], splits[1], nil
388+
}
389+
380390
func nodeInformerControllerQueueKeys(object runtime.Object) []string {
381391
if object == nil {
382392
return nil

pkg/updatestatus/nodeinformer_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ func Test_nodeInformerControllerQueueKeys(t *testing.T) {
7070
}
7171

7272
if !tc.expectedPanic && len(actual) > 0 {
73-
kind, name, err := parseQueueKey(actual[0])
73+
kind, name, err := parseNodeInformerControllerQueueKey(actual[0])
7474
if err != nil {
7575
t.Errorf("%s: unexpected error raised:\n%v", tc.name, err)
7676
}

0 commit comments

Comments
 (0)