Skip to content

Commit

Permalink
adding pvc waiter for bound
Browse files Browse the repository at this point in the history
  • Loading branch information
paigerube14 authored and rsevilla87 committed Nov 15, 2022
1 parent 53f1117 commit 88ffc5f
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions pkg/burner/waiters.go
Expand Up @@ -51,6 +51,8 @@ func (ex *Executor) waitForObjects(ns string) {
go waitForRS(ns, ex.Config.MaxWaitTimeout, &wg)
case "ReplicationController":
go waitForRC(ns, ex.Config.MaxWaitTimeout, &wg)
case "StatefulSet":
go waitForStatefulSet(ns, ex.Config.MaxWaitTimeout, &wg)
case "DaemonSet":
go waitForDS(ns, ex.Config.MaxWaitTimeout, &wg)
case "Pod":
Expand All @@ -67,6 +69,8 @@ func (ex *Executor) waitForObjects(ns string) {
go waitForVMIRS(ns, ex.Config.MaxWaitTimeout, &wg)
case "Job":
go waitForJob(ns, ex.Config.MaxWaitTimeout, &wg)
case "PersistentVolumeClaim":
go waitForPVC(ns, ex.Config.MaxWaitTimeout, &wg)
default:
wg.Done()
}
Expand Down Expand Up @@ -111,6 +115,34 @@ func waitForRS(ns string, maxWaitTimeout time.Duration, wg *sync.WaitGroup) {
})
}

func waitForStatefulSet(ns string, maxWaitTimeout time.Duration, wg *sync.WaitGroup) {
defer wg.Done()
wait.PollImmediate(1*time.Second, maxWaitTimeout, func() (bool, error) {
stss, err := ClientSet.AppsV1().StatefulSets(ns).List(context.TODO(), metav1.ListOptions{})
if err != nil {
return false, err
}
for _, sts := range stss.Items {
if *sts.Spec.Replicas != sts.Status.ReadyReplicas {
log.Debugf("Waiting for replicas from statefulSets in ns %s to be ready", ns)
return false, nil
}
}
return true, nil
})
}

func waitForPVC(ns string, maxWaitTimeout time.Duration, wg *sync.WaitGroup) {
defer wg.Done()
wait.PollImmediate(1*time.Second, maxWaitTimeout, func() (bool, error) {
pvc, err := ClientSet.CoreV1().PersistentVolumeClaims(ns).List(context.TODO(), metav1.ListOptions{FieldSelector: "status.phase!=Bound"})
if err != nil {
return false, err
}
return len(pvc.Items) == 0, nil
})
}

func waitForRC(ns string, maxWaitTimeout time.Duration, wg *sync.WaitGroup) {
defer wg.Done()
wait.PollImmediate(1*time.Second, maxWaitTimeout, func() (bool, error) {
Expand Down

0 comments on commit 88ffc5f

Please sign in to comment.