Skip to content

Commit

Permalink
Check for grafana running properly
Browse files Browse the repository at this point in the history
Signed-off-by: Grant Griffiths <ggriffiths@purestorage.com>
  • Loading branch information
Grant Griffiths committed Jul 28, 2023
1 parent 7c9944c commit c6efb64
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 10 deletions.
29 changes: 20 additions & 9 deletions pkg/util/test/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -2994,9 +2994,9 @@ func ValidateGrafana(pxImageList map[string]string, cluster *corev1.StorageClust
return nil
}

shouldBeInstalled := cluster.Spec.Monitoring != nil && cluster.Spec.Monitoring.Grafana != nil &&
cluster.Spec.Monitoring.Grafana.Enabled && cluster.Spec.Monitoring.Prometheus != nil &&
cluster.Spec.Monitoring.Prometheus.Enabled
shouldBeInstalled := cluster.Spec.Monitoring != nil &&
cluster.Spec.Monitoring.Grafana != nil && cluster.Spec.Monitoring.Grafana.Enabled &&
cluster.Spec.Monitoring.Prometheus != nil && cluster.Spec.Monitoring.Prometheus.Enabled
err = ValidateGrafanaDeployment(cluster, shouldBeInstalled, pxImageList)
if err != nil {
return err
Expand All @@ -3014,13 +3014,24 @@ func ValidateGrafana(pxImageList map[string]string, cluster *corev1.StorageClust
}

func ValidateGrafanaDeployment(cluster *corev1.StorageCluster, shouldBeInstalled bool, pxImageList map[string]string) error {
deployment, err := appops.Instance().GetDeployment("px-grafana", cluster.Namespace)
if err != nil {
return fmt.Errorf("failed to get deployment in ns %v: %v", cluster.Namespace, err)
}

if err := appops.Instance().ValidateDeployment(deployment, 2*time.Minute, 10*time.Second); err != nil {
return err
// Deployment to validate
deployment := &appsv1.Deployment{
ObjectMeta: metav1.ObjectMeta{
Name: "px-grafana",
Namespace: cluster.Namespace,
},
}
if shouldBeInstalled {
if err := appops.Instance().ValidateDeployment(deployment, 2*time.Minute, 10*time.Second); err != nil {
return fmt.Errorf("failed to validate deployment %s/%s. should be installed: %v. err: %v",
deployment.Namespace, deployment.Name, shouldBeInstalled, err)
}
} else {
if err := appops.Instance().ValidateTerminatedDeployment(deployment, 2*time.Minute, 10*time.Second); err != nil {
return fmt.Errorf("failed to validate terminated deployment %s/%s. should be installed: %v. err: %v",
deployment.Namespace, deployment.Name, shouldBeInstalled, err)
}
}

return nil
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit c6efb64

Please sign in to comment.