Skip to content

Commit

Permalink
Check if Mahchine has node
Browse files Browse the repository at this point in the history
Without it we might get a nil pointer exception
  • Loading branch information
razo7 committed Jun 12, 2023
1 parent aa695f5 commit 496c640
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion test/e2e/utils/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,17 @@ func GetAWSNodeInfoList(machineClient *machineclient.MachineV1beta1Client) (map[
return nodeList, err
}

var missNodeMachineErr error
// creates map for nodeName and AWS instance ID
for _, machine := range machineList.Items {
if machine.Status.NodeRef == nil || machine.Spec.ProviderID == nil {
if missNodeMachineErr != nil {
missNodeMachineErr = fmt.Errorf("machine %s is not associated with any node or it't provider ID is missing\n%w", string(machine.Spec.Name), missNodeMachineErr)
} else {
missNodeMachineErr = fmt.Errorf("machine %s is not associated with any node or it't provider ID is missing", string(machine.Spec.Name))
}
continue
}
nodeName := v1alpha1.NodeName(string(machine.Status.NodeRef.Name))
providerID := string(*machine.Spec.ProviderID)

Expand All @@ -69,7 +78,7 @@ func GetAWSNodeInfoList(machineClient *machineclient.MachineV1beta1Client) (map[
nodeList[nodeName] = instanceID
fmt.Printf("node: %s Instance ID: %s \n", nodeName, instanceID)
}
return nodeList, nil
return nodeList, missNodeMachineErr
}

// GetBMHNodeInfoList returns a list of the node names and their identification, e.g., ports
Expand Down

0 comments on commit 496c640

Please sign in to comment.