@@ -25,11 +25,13 @@ import (
2525 "context"
2626 "errors"
2727 "fmt"
28+ "io"
2829 "net"
2930 "strings"
3031 "time"
3132
3233 "github.com/aws/aws-k8s-tester/pkg/ctxutil"
34+ "github.com/aws/aws-k8s-tester/pkg/spinner"
3335 "go.uber.org/zap"
3436 batchv1 "k8s.io/api/batch/v1"
3537 batchv1beta1 "k8s.io/api/batch/v1beta1"
@@ -510,6 +512,7 @@ func CreateObject(dynamicClient dynamic.Interface, namespace string, name string
510512func WaitForJobCompletes (
511513 ctx context.Context ,
512514 lg * zap.Logger ,
515+ logWriter io.Writer ,
513516 stopc chan struct {},
514517 k8sClient EKS ,
515518 initialWait time.Duration ,
@@ -518,7 +521,7 @@ func WaitForJobCompletes(
518521 jobName string ,
519522 target int ,
520523 opts ... OpOption ) (job * batchv1.Job , pods []apiv1.Pod , err error ) {
521- job , _ , pods , err = waitForJobCompletes (false , ctx , lg , stopc , k8sClient , initialWait , pollInterval , namespace , jobName , target , opts ... )
524+ job , _ , pods , err = waitForJobCompletes (false , ctx , lg , logWriter , stopc , k8sClient , initialWait , pollInterval , namespace , jobName , target , opts ... )
522525 return job , pods , err
523526}
524527
@@ -527,6 +530,7 @@ func WaitForJobCompletes(
527530func WaitForCronJobCompletes (
528531 ctx context.Context ,
529532 lg * zap.Logger ,
533+ logWriter io.Writer ,
530534 stopc chan struct {},
531535 k8sClient EKS ,
532536 initialWait time.Duration ,
@@ -535,7 +539,7 @@ func WaitForCronJobCompletes(
535539 jobName string ,
536540 target int ,
537541 opts ... OpOption ) (cronJob * batchv1beta1.CronJob , pods []apiv1.Pod , err error ) {
538- _ , cronJob , pods , err = waitForJobCompletes (true , ctx , lg , stopc , k8sClient , initialWait , pollInterval , namespace , jobName , target , opts ... )
542+ _ , cronJob , pods , err = waitForJobCompletes (true , ctx , lg , logWriter , stopc , k8sClient , initialWait , pollInterval , namespace , jobName , target , opts ... )
539543 return cronJob , pods , err
540544}
541545
@@ -559,6 +563,7 @@ func waitForJobCompletes(
559563 isCronJob bool ,
560564 ctx context.Context ,
561565 lg * zap.Logger ,
566+ logWriter io.Writer ,
562567 stopc chan struct {},
563568 k8sClient EKS ,
564569 initialWait time.Duration ,
@@ -575,6 +580,7 @@ func waitForJobCompletes(
575580 pollInterval = DefaultNamespaceDeletionInterval
576581 }
577582
583+ sp := spinner .New (logWriter , "Waiting for Job completes " + jobName )
578584 lg .Info ("waiting Job completes" ,
579585 zap .String ("namespace" , namespace ),
580586 zap .String ("job-name" , jobName ),
@@ -585,10 +591,13 @@ func waitForJobCompletes(
585591 zap .String ("ctx-time-left" , ctxutil .TimeLeftTillDeadline (ctx )),
586592 zap .Int ("target" , target ),
587593 )
594+ sp .Restart ()
588595 select {
589596 case <- stopc :
597+ sp .Stop ()
590598 return nil , nil , nil , errors .New ("initial wait aborted" )
591599 case <- time .After (initialWait ):
600+ sp .Stop ()
592601 }
593602
594603 retryWaitFunc := func () (done bool , err error ) {
0 commit comments