From d571a67543c1d0c23b26933fe1438b9c8ebffa0d Mon Sep 17 00:00:00 2001 From: Raul Sevilla Date: Thu, 4 Apr 2024 12:43:43 +0200 Subject: [PATCH] Disable default cluster health check in BYOWL workloads Signed-off-by: Raul Sevilla --- cluster-density.go | 11 ----------- cluster_health.go | 11 +++++------ custom-workload.go | 11 ----------- 3 files changed, 5 insertions(+), 28 deletions(-) diff --git a/cluster-density.go b/cluster-density.go index 44fc040a..363b1391 100644 --- a/cluster-density.go +++ b/cluster-density.go @@ -20,9 +20,7 @@ import ( "strconv" "time" - "github.com/kube-burner/kube-burner/pkg/config" "github.com/kube-burner/kube-burner/pkg/workloads" - "github.com/openshift/client-go/config/clientset/versioned" log "github.com/sirupsen/logrus" "github.com/spf13/cobra" ) @@ -38,15 +36,6 @@ func NewClusterDensity(wh *workloads.WorkloadHelper, variant string) *cobra.Comm Use: variant, Short: fmt.Sprintf("Runs %v workload", variant), PreRun: func(cmd *cobra.Command, args []string) { - kubeClientProvider := config.NewKubeClientProvider("", "") - clientSet, restConfig := kubeClientProvider.ClientSet(0, 0) - openshiftClientset, err := versioned.NewForConfig(restConfig) - if err != nil { - log.Fatalf("Error creating OpenShift clientset: %v", err) - } - if !ClusterHealthyOcp(clientSet, openshiftClientset) { - os.Exit(1) - } wh.Metadata.Benchmark = cmd.Name() os.Setenv("JOB_ITERATIONS", fmt.Sprint(iterations)) os.Setenv("CHURN", fmt.Sprint(churn)) diff --git a/cluster_health.go b/cluster_health.go index 32de7159..36dec6d7 100644 --- a/cluster_health.go +++ b/cluster_health.go @@ -20,6 +20,7 @@ import ( "github.com/kube-burner/kube-burner/pkg/config" "github.com/kube-burner/kube-burner/pkg/util" + v1 "github.com/openshift/api/config/v1" "github.com/openshift/client-go/config/clientset/versioned" log "github.com/sirupsen/logrus" "github.com/spf13/cobra" @@ -41,21 +42,21 @@ func ClusterHealth() *cobra.Command { } func ClusterHealthCheck() { - log.Infof("❤️ Checking for Cluster Health") + log.Infof("❤️ Checking for Cluster Health") kubeClientProvider := config.NewKubeClientProvider("", "") clientSet, restConfig := kubeClientProvider.ClientSet(0, 0) openshiftClientset, err := versioned.NewForConfig(restConfig) if err != nil { log.Fatalf("Error creating OpenShift clientset: %v", err) } - if util.ClusterHealthyVanillaK8s(clientSet) && ClusterHealthyOcp(clientSet, openshiftClientset) { + if util.ClusterHealthyVanillaK8s(clientSet) && isClusterHealthy(clientSet, openshiftClientset) { log.Infof("Cluster is Healthy") } else { log.Fatalf("Cluster is Unhealthy") } } -func ClusterHealthyOcp(clientset kubernetes.Interface, openshiftClientset *versioned.Clientset) bool { +func isClusterHealthy(clientset kubernetes.Interface, openshiftClientset *versioned.Clientset) bool { var isHealthy = true operators, err := openshiftClientset.ConfigV1().ClusterOperators().List(context.Background(), metav1.ListOptions{}) if err != nil { @@ -66,13 +67,12 @@ func ClusterHealthyOcp(clientset kubernetes.Interface, openshiftClientset *versi for _, operator := range operators.Items { // Check availability conditions for _, condition := range operator.Status.Conditions { - if condition.Type == "Available" && condition.Status != "True" { //nolint:goconst + if condition.Type == v1.OperatorAvailable && condition.Status != v1.ConditionTrue { isHealthy = false log.Errorf("Cluster Operator: %s, Condition: %s, Status: %v, Reason: %s", operator.Name, condition.Type, condition.Status, condition.Reason) } } } - // Rosa osd-cluster-ready check job, err := clientset.BatchV1().Jobs("openshift-monitoring").Get(context.TODO(), "osd-cluster-ready", metav1.GetOptions{}) if err != nil { @@ -90,6 +90,5 @@ func ClusterHealthyOcp(clientset kubernetes.Interface, openshiftClientset *versi } } } - return isHealthy } diff --git a/custom-workload.go b/custom-workload.go index 2bce56f4..8b1747bf 100644 --- a/custom-workload.go +++ b/custom-workload.go @@ -18,9 +18,7 @@ import ( "os" "strings" - "github.com/kube-burner/kube-burner/pkg/config" "github.com/kube-burner/kube-burner/pkg/workloads" - "github.com/openshift/client-go/config/clientset/versioned" log "github.com/sirupsen/logrus" "github.com/spf13/cobra" ) @@ -31,15 +29,6 @@ func CustomWorkload(wh *workloads.WorkloadHelper) *cobra.Command { Use: "init", Short: "Runs custom workload", PreRun: func(cmd *cobra.Command, args []string) { - kubeClientProvider := config.NewKubeClientProvider("", "") - clientSet, restConfig := kubeClientProvider.ClientSet(0, 0) - openshiftClientset, err := versioned.NewForConfig(restConfig) - if err != nil { - log.Fatalf("Error creating OpenShift clientset: %v", err) - } - if !ClusterHealthyOcp(clientSet, openshiftClientset) { - os.Exit(1) - } wh.Metadata.Benchmark = benchmarkName }, Run: func(cmd *cobra.Command, args []string) {