From 77d40125841cbc9e8f8931cc9b2bf5a738123881 Mon Sep 17 00:00:00 2001 From: Austin Abro Date: Wed, 4 Sep 2024 17:38:52 +0000 Subject: [PATCH 1/3] fix progress bar on push Signed-off-by: Austin Abro --- src/internal/packager/images/push.go | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/internal/packager/images/push.go b/src/internal/packager/images/push.go index 7bac363001..9c36424178 100644 --- a/src/internal/packager/images/push.go +++ b/src/internal/packager/images/push.go @@ -55,6 +55,7 @@ func Push(ctx context.Context, cfg PushConfig) error { progress := message.NewProgressBar(totalSize, fmt.Sprintf("Pushing %d images", len(toPush))) defer progress.Close() + pushOptions := createPushOpts(cfg, progress) err = retry.Do(func() error { c, _ := cluster.NewCluster() @@ -68,9 +69,6 @@ func Push(ctx context.Context, cfg PushConfig) error { } } - progress = message.NewProgressBar(totalSize, fmt.Sprintf("Pushing %d images", len(toPush))) - pushOptions := createPushOpts(cfg, progress) - pushImage := func(img v1.Image, name string) error { if tunnel != nil { return tunnel.Wrap(func() error { return crane.Push(img, name, pushOptions...) }) From 704ff0e2b96e0f26a7eeefd6e2250c07e899dffb Mon Sep 17 00:00:00 2001 From: Austin Abro Date: Thu, 5 Sep 2024 12:17:44 +0000 Subject: [PATCH 2/3] get rid of references to totalSize after progress bar has been created Signed-off-by: Austin Abro --- src/internal/packager/images/push.go | 8 -------- 1 file changed, 8 deletions(-) diff --git a/src/internal/packager/images/push.go b/src/internal/packager/images/push.go index 9c36424178..84b111d3e7 100644 --- a/src/internal/packager/images/push.go +++ b/src/internal/packager/images/push.go @@ -87,11 +87,6 @@ func Push(ctx context.Context, cfg PushConfig) error { refTruncated := helpers.Truncate(refInfo.Reference, 55, true) progress.Updatef(fmt.Sprintf("Pushing %s", refTruncated)) - size, err := calcImgSize(img) - if err != nil { - return err - } - // If this is not a no checksum image push it for use with the Zarf agent if !cfg.NoChecksum { offlineNameCRC, err := transform.ImageTransformHost(registryURL, refInfo.Reference) @@ -102,8 +97,6 @@ func Push(ctx context.Context, cfg PushConfig) error { if err = pushImage(img, offlineNameCRC); err != nil { return err } - - totalSize -= size } // To allow for other non-zarf workloads to easily see the images upload a non-checksum version @@ -120,7 +113,6 @@ func Push(ctx context.Context, cfg PushConfig) error { } pushed = append(pushed, refInfo) - totalSize -= size } return nil }, retry.Context(ctx), retry.Attempts(uint(cfg.Retries)), retry.Delay(500*time.Millisecond)) From f057f8fbdb853ed532b5d0e87452b39bfce08630 Mon Sep 17 00:00:00 2001 From: Austin Abro Date: Thu, 5 Sep 2024 14:11:00 +0000 Subject: [PATCH 3/3] use the inner progress bar Signed-off-by: Austin Abro --- src/internal/packager/images/push.go | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/src/internal/packager/images/push.go b/src/internal/packager/images/push.go index 84b111d3e7..f8cbf90c4e 100644 --- a/src/internal/packager/images/push.go +++ b/src/internal/packager/images/push.go @@ -53,10 +53,6 @@ func Push(ctx context.Context, cfg PushConfig) error { registryURL = cfg.RegInfo.Address ) - progress := message.NewProgressBar(totalSize, fmt.Sprintf("Pushing %d images", len(toPush))) - defer progress.Close() - pushOptions := createPushOpts(cfg, progress) - err = retry.Do(func() error { c, _ := cluster.NewCluster() if c != nil { @@ -69,6 +65,10 @@ func Push(ctx context.Context, cfg PushConfig) error { } } + progress := message.NewProgressBar(totalSize, fmt.Sprintf("Pushing %d images", len(toPush))) + defer progress.Close() + pushOptions := createPushOpts(cfg, progress) + pushImage := func(img v1.Image, name string) error { if tunnel != nil { return tunnel.Wrap(func() error { return crane.Push(img, name, pushOptions...) }) @@ -87,6 +87,11 @@ func Push(ctx context.Context, cfg PushConfig) error { refTruncated := helpers.Truncate(refInfo.Reference, 55, true) progress.Updatef(fmt.Sprintf("Pushing %s", refTruncated)) + size, err := calcImgSize(img) + if err != nil { + return err + } + // If this is not a no checksum image push it for use with the Zarf agent if !cfg.NoChecksum { offlineNameCRC, err := transform.ImageTransformHost(registryURL, refInfo.Reference) @@ -97,6 +102,8 @@ func Push(ctx context.Context, cfg PushConfig) error { if err = pushImage(img, offlineNameCRC); err != nil { return err } + + totalSize -= size } // To allow for other non-zarf workloads to easily see the images upload a non-checksum version @@ -113,15 +120,15 @@ func Push(ctx context.Context, cfg PushConfig) error { } pushed = append(pushed, refInfo) + totalSize -= size } + progress.Successf("Pushed %d images", len(cfg.ImageList)) return nil }, retry.Context(ctx), retry.Attempts(uint(cfg.Retries)), retry.Delay(500*time.Millisecond)) if err != nil { return err } - progress.Successf("Pushed %d images", len(cfg.ImageList)) - return nil }