Skip to content

Commit

Permalink
Image registry failure should be fatal
Browse files Browse the repository at this point in the history
Signed-off-by: Raul Sevilla <[email protected]>
  • Loading branch information
rsevilla87 committed Dec 3, 2024
1 parent 41d0561 commit d33e1cb
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
6 changes: 3 additions & 3 deletions cluster-density.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
10 changes: 5 additions & 5 deletions cluster_health.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ package ocp

import (
"context"
"fmt"
"os"

"github.com/kube-burner/kube-burner/pkg/config"
Expand Down Expand Up @@ -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")
}

0 comments on commit d33e1cb

Please sign in to comment.