Summary
In test/extended-priv/util.go, the helper function getMachineConfigOperatorPod indexes pods[0] before checking whether exutil.GetAllPodsWithLabel succeeded or returned any pods. This can cause a runtime panic if the label query errors or returns an empty list.
Related
Proposed Fix
func getMachineConfigOperatorPod(oc *exutil.CLI) (string, error) {
pods, err := exutil.GetAllPodsWithLabel(oc.AsAdmin(), MachineConfigNamespace, "k8s-app=machine-config-operator")
if err != nil {
return "", err
}
if len(pods) == 0 {
return "", fmt.Errorf("no machine-config-operator pod found in namespace %s", MachineConfigNamespace)
}
logger.Infof("machine-config-operator pod name is %s", pods[0])
return pods[0], nil
}
Summary
In
test/extended-priv/util.go, the helper functiongetMachineConfigOperatorPodindexespods[0]before checking whetherexutil.GetAllPodsWithLabelsucceeded or returned any pods. This can cause a runtime panic if the label query errors or returns an empty list.Related
Proposed Fix