From fe2881079d1ef65b7ab3c9bb1a3c7364092d54a1 Mon Sep 17 00:00:00 2001 From: Coleen Iona Quadros Date: Tue, 3 Sep 2024 10:49:01 +0200 Subject: [PATCH 1/7] update tests to ignore clusters that dont have observability addon installed Signed-off-by: Coleen Iona Quadros --- tests/pkg/utils/mco_managedcluster.go | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/tests/pkg/utils/mco_managedcluster.go b/tests/pkg/utils/mco_managedcluster.go index a92b4e205..2aa8412bf 100644 --- a/tests/pkg/utils/mco_managedcluster.go +++ b/tests/pkg/utils/mco_managedcluster.go @@ -53,12 +53,13 @@ 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) + } } } } From c4f938a26820d56d8844d3822f0e43c92e7b671f Mon Sep 17 00:00:00 2001 From: Coleen Iona Quadros Date: Tue, 3 Sep 2024 11:00:30 +0200 Subject: [PATCH 2/7] update tests to ignore clusters that dont have observability addon installed Signed-off-by: Coleen Iona Quadros --- tests/pkg/utils/mco_managedcluster.go | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/tests/pkg/utils/mco_managedcluster.go b/tests/pkg/utils/mco_managedcluster.go index 2aa8412bf..ae9053ef6 100644 --- a/tests/pkg/utils/mco_managedcluster.go +++ b/tests/pkg/utils/mco_managedcluster.go @@ -53,13 +53,8 @@ func ListManagedClusters(opt TestOptions) ([]string, error) { name := metadata["name"].(string) labels := metadata["labels"].(map[string]interface{}) if labels != nil { - 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) - } + if obsController, ok := labels["feature.open-cluster-management.io/addon-observability-controller"]; ok && obsController.(string) != "unreachable" { + clusterNames = append(clusterNames, name) } } } From 4017aebd8b71c1e7f013fc51949939a58597ae57 Mon Sep 17 00:00:00 2001 From: Coleen Iona Quadros Date: Wed, 4 Sep 2024 09:31:16 +0200 Subject: [PATCH 3/7] force add on obervability label for kind Signed-off-by: Coleen Iona Quadros --- cicd-scripts/setup-e2e-tests.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/cicd-scripts/setup-e2e-tests.sh b/cicd-scripts/setup-e2e-tests.sh index 028a7a2df..59c1c4cc4 100755 --- a/cicd-scripts/setup-e2e-tests.sh +++ b/cicd-scripts/setup-e2e-tests.sh @@ -82,6 +82,8 @@ approve_csr_joinrequest() { # update vendor label for KinD env kubectl label managedcluster ${clustername} vendor- kubectl label managedcluster ${clustername} vendor=GKE + # update with label "feature.open-cluster-management.io/addon-observability-controller": "available" + kubectl label managedcluster ${clustername} feature.open-cluster-management.io/addon-observability-controller=available fi done break From b7bae356d0d2ff28ac44ef1796d533277cd31cbe Mon Sep 17 00:00:00 2001 From: Coleen Iona Quadros Date: Wed, 4 Sep 2024 11:26:17 +0200 Subject: [PATCH 4/7] add logs to tests Signed-off-by: Coleen Iona Quadros --- cicd-scripts/setup-e2e-tests.sh | 3 ++- tests/pkg/utils/mco_managedcluster.go | 4 ++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/cicd-scripts/setup-e2e-tests.sh b/cicd-scripts/setup-e2e-tests.sh index 59c1c4cc4..617b22cd7 100755 --- a/cicd-scripts/setup-e2e-tests.sh +++ b/cicd-scripts/setup-e2e-tests.sh @@ -82,8 +82,9 @@ approve_csr_joinrequest() { # update vendor label for KinD env kubectl label managedcluster ${clustername} vendor- kubectl label managedcluster ${clustername} vendor=GKE + echo "Coleen update vendor label for KinD env" # update with label "feature.open-cluster-management.io/addon-observability-controller": "available" - kubectl label managedcluster ${clustername} feature.open-cluster-management.io/addon-observability-controller=available + kubectl label managedcluster ${clustername} feature.open-cluster-management.io/addon-observability-controller=available --overwrite fi done break diff --git a/tests/pkg/utils/mco_managedcluster.go b/tests/pkg/utils/mco_managedcluster.go index ae9053ef6..6238145b1 100644 --- a/tests/pkg/utils/mco_managedcluster.go +++ b/tests/pkg/utils/mco_managedcluster.go @@ -7,6 +7,7 @@ package utils import ( "context" "errors" + "github.com/cloudflare/cfssl/log" goversion "github.com/hashicorp/go-version" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" @@ -52,7 +53,9 @@ func ListManagedClusters(opt TestOptions) ([]string, error) { metadata := obj.Object["metadata"].(map[string]interface{}) name := metadata["name"].(string) labels := metadata["labels"].(map[string]interface{}) + log.Info("Coleen ListManagedClusters", "name", name, "labels", labels) if labels != nil { + log.Info("Coleen ListManagedClusters", "name", name, "labels", labels) if obsController, ok := labels["feature.open-cluster-management.io/addon-observability-controller"]; ok && obsController.(string) != "unreachable" { clusterNames = append(clusterNames, name) } @@ -60,6 +63,7 @@ func ListManagedClusters(opt TestOptions) ([]string, error) { } if len(clusterNames) == 0 { + log.Info("Coleen no clusters", "clusterNames", clusterNames) return clusterNames, errors.New("no managedcluster found") } From 6368901112c99261344a92f7ffdc750b90ceb1fd Mon Sep 17 00:00:00 2001 From: Coleen Iona Quadros Date: Wed, 4 Sep 2024 11:56:49 +0200 Subject: [PATCH 5/7] update Signed-off-by: Coleen Iona Quadros --- cicd-scripts/setup-e2e-tests.sh | 3 --- tests/pkg/utils/mco_managedcluster.go | 9 ++++++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/cicd-scripts/setup-e2e-tests.sh b/cicd-scripts/setup-e2e-tests.sh index 617b22cd7..028a7a2df 100755 --- a/cicd-scripts/setup-e2e-tests.sh +++ b/cicd-scripts/setup-e2e-tests.sh @@ -82,9 +82,6 @@ approve_csr_joinrequest() { # update vendor label for KinD env kubectl label managedcluster ${clustername} vendor- kubectl label managedcluster ${clustername} vendor=GKE - echo "Coleen update vendor label for KinD env" - # update with label "feature.open-cluster-management.io/addon-observability-controller": "available" - kubectl label managedcluster ${clustername} feature.open-cluster-management.io/addon-observability-controller=available --overwrite fi done break diff --git a/tests/pkg/utils/mco_managedcluster.go b/tests/pkg/utils/mco_managedcluster.go index 6238145b1..1c1779a62 100644 --- a/tests/pkg/utils/mco_managedcluster.go +++ b/tests/pkg/utils/mco_managedcluster.go @@ -8,9 +8,9 @@ import ( "context" "errors" "github.com/cloudflare/cfssl/log" - goversion "github.com/hashicorp/go-version" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "os" ) func UpdateObservabilityFromManagedCluster(opt TestOptions, enableObservability bool) error { @@ -53,9 +53,12 @@ func ListManagedClusters(opt TestOptions) ([]string, error) { metadata := obj.Object["metadata"].(map[string]interface{}) name := metadata["name"].(string) labels := metadata["labels"].(map[string]interface{}) - log.Info("Coleen ListManagedClusters", "name", name, "labels", labels) + 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 { - log.Info("Coleen ListManagedClusters", "name", name, "labels", labels) if obsController, ok := labels["feature.open-cluster-management.io/addon-observability-controller"]; ok && obsController.(string) != "unreachable" { clusterNames = append(clusterNames, name) } From aed8613cba31c1a97b3cf141605ad7bd5ca09a26 Mon Sep 17 00:00:00 2001 From: Coleen Iona Quadros Date: Wed, 4 Sep 2024 11:57:40 +0200 Subject: [PATCH 6/7] update Signed-off-by: Coleen Iona Quadros --- tests/pkg/utils/mco_managedcluster.go | 2 -- 1 file changed, 2 deletions(-) diff --git a/tests/pkg/utils/mco_managedcluster.go b/tests/pkg/utils/mco_managedcluster.go index 1c1779a62..915e67bc3 100644 --- a/tests/pkg/utils/mco_managedcluster.go +++ b/tests/pkg/utils/mco_managedcluster.go @@ -7,7 +7,6 @@ package utils import ( "context" "errors" - "github.com/cloudflare/cfssl/log" goversion "github.com/hashicorp/go-version" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "os" @@ -66,7 +65,6 @@ func ListManagedClusters(opt TestOptions) ([]string, error) { } if len(clusterNames) == 0 { - log.Info("Coleen no clusters", "clusterNames", clusterNames) return clusterNames, errors.New("no managedcluster found") } From 7068f2b44efb60564cd6a3abb15118e823e785cc Mon Sep 17 00:00:00 2001 From: Coleen Iona Quadros Date: Wed, 4 Sep 2024 12:07:48 +0200 Subject: [PATCH 7/7] update Signed-off-by: Coleen Iona Quadros --- tests/pkg/utils/mco_managedcluster.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/pkg/utils/mco_managedcluster.go b/tests/pkg/utils/mco_managedcluster.go index 915e67bc3..9e96ffe4b 100644 --- a/tests/pkg/utils/mco_managedcluster.go +++ b/tests/pkg/utils/mco_managedcluster.go @@ -7,9 +7,10 @@ package utils import ( "context" "errors" + "os" + goversion "github.com/hashicorp/go-version" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "os" ) func UpdateObservabilityFromManagedCluster(opt TestOptions, enableObservability bool) error {