Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Disable default cluster health check in BYOWL workloads #46

Merged
merged 1 commit into from
Apr 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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("", "")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't we want cluster health check in cluster-density?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It can be enabled in all workloads https://github.com/kube-burner/kube-burner-ocp/blob/main/cmd/ocp.go#L85-L87
I removed it from cluster-density to standarize

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
Loading