diff --git a/cluster-density.go b/cluster-density.go index 4249faeb..906f7e81 100644 --- a/cluster-density.go +++ b/cluster-density.go @@ -57,9 +57,9 @@ func NewClusterDensity(wh *workloads.WorkloadHelper, variant string) *cobra.Comm Run: func(cmd *cobra.Command, args []string) { if cmd.Name() == "cluster-density-v2" { kubeClientProvider := config.NewKubeClientProvider("", "") - clientset, _ := kubeClientProvider.ClientSet(0, 0) - if !clusterImageRegistryCheck(clientset) { - log.Errorf("image-registry deployment is not deployed") + clientSet, _ := kubeClientProvider.ClientSet(0, 0) + if err := IsClusterImageRegistryAvailable(clientSet); err != nil { + log.Fatal(err.Error()) } } setMetrics(cmd, metricsProfiles) diff --git a/cluster_health.go b/cluster_health.go index d60dfa34..19e1d863 100644 --- a/cluster_health.go +++ b/cluster_health.go @@ -16,6 +16,7 @@ package ocp import ( "context" + "fmt" "os" "github.com/kube-burner/kube-burner/pkg/config" @@ -93,15 +94,14 @@ func isClusterHealthy(clientset kubernetes.Interface, openshiftClientset *versio return isHealthy } -func clusterImageRegistryCheck(clientset kubernetes.Interface) bool { +func IsClusterImageRegistryAvailable(clientset kubernetes.Interface) error { deployment, err := clientset.AppsV1().Deployments("openshift-image-registry").Get(context.TODO(), "image-registry", metav1.GetOptions{}) if err != nil { - log.Errorf("Error getting deployment: %v", err) - return false + return fmt.Errorf("Error getting deployment: %v", err) } if deployment.Status.AvailableReplicas > 0 { log.Debugf("Deployment image-registry in namespace openshift-image-registry is available with %d replicas", deployment.Status.AvailableReplicas) - return true + return nil } - return false + return fmt.Errorf("Deployment image-registry in namespace openshift-image-registry doesn't have available replicas") }