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 baf4b36 commit 7e6da52
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 @@ -2997,9 +2997,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 @@ -3017,13 +3017,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
2 changes: 1 addition & 1 deletion test/integration_test/utils/storagecluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,7 @@ func UpdateAndValidateGrafana(cluster *corev1.StorageCluster, f func(*corev1.Sto
latestLiveCluster, err := UpdateStorageCluster(newCluster)
require.NoError(t, err)

err = testutil.ValidateGrafana(pxSpecImages, cluster)
err = testutil.ValidateGrafana(pxSpecImages, latestLiveCluster)
require.NoError(t, err)

return latestLiveCluster
Expand Down

0 comments on commit 7e6da52

Please sign in to comment.