Skip to content

Commit

Permalink
fix: [ACM-14189] identify healthy managed clusters during e2e (#1634)
Browse files Browse the repository at this point in the history
* fix: identify healthy managed clusters

Signed-off-by: Subbarao Meduri <[email protected]>

* fix: do not skip local-cluster, as it is skipped in tests directly

Signed-off-by: Subbarao Meduri <[email protected]>

---------

Signed-off-by: Subbarao Meduri <[email protected]>
  • Loading branch information
subbarao-meduri authored Sep 20, 2024
1 parent 6f12d6b commit c70bd0d
Showing 1 changed file with 28 additions and 4 deletions.
32 changes: 28 additions & 4 deletions tests/pkg/utils/mco_managedcluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,16 +52,40 @@ func ListManagedClusters(opt TestOptions) ([]string, error) {
for _, obj := range objs.Items {
metadata := obj.Object["metadata"].(map[string]interface{})
name := metadata["name"].(string)
labels := metadata["labels"].(map[string]interface{})

if os.Getenv("IS_KIND_ENV") == "true" {
// We do not have the obs add on label added in kind cluster
clusterNames = append(clusterNames, name)
continue
}
if labels != nil {
if obsController, ok := labels["feature.open-cluster-management.io/addon-observability-controller"]; ok && obsController.(string) != "unreachable" {
clusterNames = append(clusterNames, name)

status, ok := obj.Object["status"].(map[string]interface{})
if !ok {
// No status found, skip this cluster
continue
}

conditions, ok := status["conditions"].([]interface{})
if !ok {
// No conditions found, skip this cluster
continue
}

available := false
for _, condition := range conditions {
conditionMap, ok := condition.(map[string]interface{})
if !ok {
continue
}
if conditionMap["type"] == "ManagedClusterConditionAvailable" && conditionMap["status"] == "True" {
available = true
break
}
}

// Only add clusters with ManagedClusterConditionAvailable status == True
if available {
clusterNames = append(clusterNames, name)
}
}

Expand Down

0 comments on commit c70bd0d

Please sign in to comment.