Skip to content

Commit

Permalink
Disable default cluster health check in BYOWL workloads
Browse files Browse the repository at this point in the history
Signed-off-by: Raul Sevilla <[email protected]>
  • Loading branch information
rsevilla87 committed Apr 4, 2024
1 parent f96d4ce commit d571a67
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 28 deletions.
11 changes: 0 additions & 11 deletions cluster-density.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)
Expand All @@ -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))
Expand Down
11 changes: 5 additions & 6 deletions cluster_health.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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 {
Expand All @@ -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 {
Expand All @@ -90,6 +90,5 @@ func ClusterHealthyOcp(clientset kubernetes.Interface, openshiftClientset *versi
}
}
}

return isHealthy
}
11 changes: 0 additions & 11 deletions custom-workload.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)
Expand All @@ -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) {
Expand Down

0 comments on commit d571a67

Please sign in to comment.