@@ -55,22 +55,24 @@ func GetNodesForPool(mcpLister v1.MachineConfigPoolLister, nodeLister corev1list
55
55
// temporarily be set to `unknown`. Once the node exists (is not nil) and the annotations are properly set,
56
56
// the node will update again and the pool name will be updated.
57
57
func GetPrimaryPoolNameForMCN (mcpLister v1.MachineConfigPoolLister , node * corev1.Node ) (string , error ) {
58
+ // Handle case of nil node
58
59
if node == nil {
59
60
klog .Error ("node object is nil, setting associated MCP to unknown" )
60
61
return "unknown" , nil
61
- } else {
62
- primaryPool , err := GetPrimaryPoolForNode (mcpLister , node )
63
- if err != nil {
64
- klog .Errorf ("error getting primary pool for node: %v" , node .Name )
65
- return "" , err
66
- } else if primaryPool == nil {
67
- // On first provisioning, the node may not have annoatations and, thus, will not be associated with a pool
68
- klog .Infof ("No primary pool is associated with node: %v" , node .Name )
69
- return "unknown" , nil
70
- } else {
71
- return primaryPool .Name , nil
72
- }
73
62
}
63
+
64
+ // Use `GetPrimaryPoolForNode` to get primary MCP associated with node
65
+ primaryPool , err := GetPrimaryPoolForNode (mcpLister , node )
66
+ if err != nil {
67
+ klog .Errorf ("error getting primary pool for node: %v" , node .Name )
68
+ return "" , err
69
+ } else if primaryPool == nil {
70
+ // On first provisioning, the node may not have annoatations and, thus, will not be associated with a pool.
71
+ // In this case, the pool value will be set to a temporary dummy value.
72
+ klog .Infof ("No primary pool is associated with node: %v" , node .Name )
73
+ return "unknown" , nil
74
+ }
75
+ return primaryPool .Name , nil
74
76
}
75
77
76
78
func GetPrimaryPoolForNode (mcpLister v1.MachineConfigPoolLister , node * corev1.Node ) (* mcfgv1.MachineConfigPool , error ) {
0 commit comments