From 0a1ba6bee5f74380017a579a82ca6b73ead2c5ec Mon Sep 17 00:00:00 2001 From: Aviv Zohari <101040711+avivzgroundcover@users.noreply.github.com> Date: Thu, 11 Jan 2024 17:35:44 +0200 Subject: [PATCH] [sc-12837] install flow should wait for static amount of pvcs (#273) Co-authored-by: Steb Veksler --- CHANGELOG.md | 1 + cmd/status.go | 12 +++++++++--- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7cb3c74..9c5b6e5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -21,6 +21,7 @@ We use the following categories for changes: ### Changed ### Fixed +- CLI should expect a static amount of PVCs [#sc-12837] ### Removed diff --git a/cmd/status.go b/cmd/status.go index 7711d1e..1e3dc14 100644 --- a/cmd/status.go +++ b/cmd/status.go @@ -14,6 +14,7 @@ import ( "groundcover.com/pkg/segment" sentry_utils "groundcover.com/pkg/sentry" "groundcover.com/pkg/ui" + appsv1 "k8s.io/api/apps/v1" v1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" ) @@ -308,12 +309,16 @@ func waitForPvcs(ctx context.Context, kubeClient *k8s.Client, releaseName, names LabelSelector: fmt.Sprintf("app.kubernetes.io/instance=%s", releaseName), } - var pvcList *v1.PersistentVolumeClaimList - if pvcList, err = kubeClient.CoreV1().PersistentVolumeClaims(namespace).List(ctx, listOptions); err != nil { + var stsList *appsv1.StatefulSetList + if stsList, err = kubeClient.AppsV1().StatefulSets(namespace).List(ctx, listOptions); err != nil { return err } - expectedBoundPvcsCount := len(pvcList.Items) + expectedBoundPvcsCount := 0 + for _, sts := range stsList.Items { + expectedBoundPvcsCount = expectedBoundPvcsCount + len(sts.Spec.VolumeClaimTemplates) + } + if expectedBoundPvcsCount == 0 { ui.GlobalWriter.PrintWarningMessageln("No Presistent volumes") return nil @@ -328,6 +333,7 @@ func waitForPvcs(ctx context.Context, kubeClient *k8s.Client, releaseName, names boundPvcs := make(map[string]bool, 0) + var pvcList *v1.PersistentVolumeClaimList isPvcsReadyFunc := func() error { if pvcList, err = kubeClient.CoreV1().PersistentVolumeClaims(namespace).List(ctx, listOptions); err != nil { return err