diff --git a/tests/pkg/utils/mco_managedcluster.go b/tests/pkg/utils/mco_managedcluster.go index a92b4e2057..a84cff1453 100644 --- a/tests/pkg/utils/mco_managedcluster.go +++ b/tests/pkg/utils/mco_managedcluster.go @@ -53,13 +53,15 @@ func ListManagedClusters(opt TestOptions) ([]string, error) { name := metadata["name"].(string) labels := metadata["labels"].(map[string]interface{}) if labels != nil { - obsControllerStr := "" - if obsController, ok := labels["feature.open-cluster-management.io/addon-observability-controller"]; ok { - obsControllerStr = obsController.(string) - } - if obsControllerStr != "unreachable" { - clusterNames = append(clusterNames, name) + if obsController, ok := labels["feature.open-cluster-management.io/addon-observability-controller"]; !ok { + continue + } else { + obsControllerStr := obsController.(string) + if obsControllerStr != "unreachable" { + clusterNames = append(clusterNames, name) + } } + } }