Skip to content

Commit 5ab80c4

Browse files
committed
eks*: spinner in job waits
Signed-off-by: Gyuho Lee <leegyuho@amazon.com>
1 parent 1531dc1 commit 5ab80c4

File tree

9 files changed

+19
-2
lines changed

9 files changed

+19
-2
lines changed

eks/cluster-loader/remote/cluster-loader.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,7 @@ func (ts *tester) Create() (err error) {
121121
_, pods, err = k8s_client.WaitForJobCompletes(
122122
ctx,
123123
ts.cfg.Logger,
124+
ts.cfg.LogWriter,
124125
ts.cfg.Stopc,
125126
ts.cfg.K8SClient,
126127
2*time.Minute,

eks/configmaps/remote/configmaps.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,7 @@ func (ts *tester) Create() (err error) {
129129
_, pods, err = k8s_client.WaitForJobCompletes(
130130
ctx,
131131
ts.cfg.Logger,
132+
ts.cfg.LogWriter,
132133
ts.cfg.Stopc,
133134
ts.cfg.K8SClient,
134135
3*time.Minute,

eks/cron-jobs/cron-jobs.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,7 @@ func (ts *tester) Create() (err error) {
108108
_, pods, err = k8s_client.WaitForCronJobCompletes(
109109
ctx,
110110
ts.cfg.Logger,
111+
ts.cfg.LogWriter,
111112
ts.cfg.Stopc,
112113
ts.cfg.K8SClient,
113114
3*time.Minute,

eks/csrs/remote/csrs.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,7 @@ func (ts *tester) Create() (err error) {
129129
_, pods, err = k8s_client.WaitForJobCompletes(
130130
ctx,
131131
ts.cfg.Logger,
132+
ts.cfg.LogWriter,
132133
ts.cfg.Stopc,
133134
ts.cfg.K8SClient,
134135
3*time.Minute,

eks/jobs-echo/jobs-echo.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@ func (ts *tester) Create() (err error) {
107107
_, pods, err = k8s_client.WaitForJobCompletes(
108108
ctx,
109109
ts.cfg.Logger,
110+
ts.cfg.LogWriter,
110111
ts.cfg.Stopc,
111112
ts.cfg.K8SClient,
112113
2*time.Minute,

eks/jobs-pi/jobs-pi.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ func (ts *tester) Create() (err error) {
8686
_, pods, err = k8s_client.WaitForJobCompletes(
8787
ctx,
8888
ts.cfg.Logger,
89+
ts.cfg.LogWriter,
8990
ts.cfg.Stopc,
9091
ts.cfg.K8SClient,
9192
2*time.Minute,

eks/secrets/remote/secrets.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,7 @@ func (ts *tester) Create() (err error) {
129129
_, pods, err = k8s_client.WaitForJobCompletes(
130130
ctx,
131131
ts.cfg.Logger,
132+
ts.cfg.LogWriter,
132133
ts.cfg.Stopc,
133134
ts.cfg.K8SClient,
134135
3*time.Minute,

eks/stresser/remote/stresser.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,7 @@ func (ts *tester) Create() (err error) {
137137
_, pods, err = k8s_client.WaitForJobCompletes(
138138
ctx,
139139
ts.cfg.Logger,
140+
ts.cfg.LogWriter,
140141
ts.cfg.Stopc,
141142
ts.cfg.K8SClient,
142143
time.Minute+ts.cfg.EKSConfig.AddOnStresserRemote.Duration/2,

pkg/k8s-client/k8s.go

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -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
510512
func 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(
527530
func 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

Comments
 (0)