From 7eb79d3abb283f42ff2990b59a929292e2d640ea Mon Sep 17 00:00:00 2001 From: schristoff <28318173+schristoff@users.noreply.github.com> Date: Thu, 3 Oct 2024 18:14:52 +0100 Subject: [PATCH 1/4] (feat): Remove progress bar Signed-off-by: schristoff <28318173+schristoff@users.noreply.github.com> --- src/internal/packager/images/common.go | 4 ++-- src/internal/packager2/mirror.go | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/internal/packager/images/common.go b/src/internal/packager/images/common.go index 285c541edb..d3b97b9a50 100644 --- a/src/internal/packager/images/common.go +++ b/src/internal/packager/images/common.go @@ -107,9 +107,9 @@ func createPushOpts(cfg PushConfig, pb *message.ProgressBar) []crane.Option { // TODO (@WSTARR) This is set to match the TLSHandshakeTimeout to potentially mitigate effects of https://github.com/zarf-dev/zarf/issues/1444 transport.ResponseHeaderTimeout = 10 * time.Second - transportWithProgressBar := helpers.NewTransport(transport, pb) + transportWithoutProgressBar := helpers.NewTransport(transport, nil) - opts = append(opts, crane.WithTransport(transportWithProgressBar)) + opts = append(opts, crane.WithTransport(transportWithoutProgressBar)) return opts } diff --git a/src/internal/packager2/mirror.go b/src/internal/packager2/mirror.go index 8532a8c4e6..c2b70c5109 100644 --- a/src/internal/packager2/mirror.go +++ b/src/internal/packager2/mirror.go @@ -89,11 +89,11 @@ func pushImagesToRegistry(ctx context.Context, c *cluster.Cluster, pkgLayout *la transport.TLSClientConfig.InsecureSkipVerify = config.CommonOptions.InsecureSkipTLSVerify // TODO (@WSTARR) This is set to match the TLSHandshakeTimeout to potentially mitigate effects of https://github.com/zarf-dev/zarf/issues/1444 transport.ResponseHeaderTimeout = 10 * time.Second - transportWithProgressBar := helpers.NewTransport(transport, nil) + transportWithoutProgressBar := helpers.NewTransport(transport, nil) pushOptions := []crane.Option{ crane.WithPlatform(&v1.Platform{OS: "linux", Architecture: pkgLayout.Pkg.Build.Architecture}), - crane.WithTransport(transportWithProgressBar), + crane.WithTransport(transportWithoutProgressBar), crane.WithAuth(authn.FromConfig(authn.AuthConfig{ Username: regInfo.PushUsername, Password: regInfo.PushPassword, From c273b6a393e264df68f23867744db6dc82a37c05 Mon Sep 17 00:00:00 2001 From: schristoff <28318173+schristoff@users.noreply.github.com> Date: Thu, 3 Oct 2024 18:45:12 +0100 Subject: [PATCH 2/4] remove pb Signed-off-by: schristoff <28318173+schristoff@users.noreply.github.com> --- src/internal/packager/images/common.go | 3 +-- src/internal/packager/images/push.go | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/src/internal/packager/images/common.go b/src/internal/packager/images/common.go index d3b97b9a50..f37f971267 100644 --- a/src/internal/packager/images/common.go +++ b/src/internal/packager/images/common.go @@ -13,7 +13,6 @@ import ( "github.com/google/go-containerregistry/pkg/crane" v1 "github.com/google/go-containerregistry/pkg/v1" "github.com/zarf-dev/zarf/src/config" - "github.com/zarf-dev/zarf/src/pkg/message" "github.com/zarf-dev/zarf/src/pkg/transform" "github.com/zarf-dev/zarf/src/types" ) @@ -98,7 +97,7 @@ func WithPushAuth(ri types.RegistryInfo) crane.Option { return WithBasicAuth(ri.PushUsername, ri.PushPassword) } -func createPushOpts(cfg PushConfig, pb *message.ProgressBar) []crane.Option { +func createPushOpts(cfg PushConfig) []crane.Option { opts := CommonOpts(cfg.Arch) opts = append(opts, WithPushAuth(cfg.RegInfo)) diff --git a/src/internal/packager/images/push.go b/src/internal/packager/images/push.go index f8cbf90c4e..2b7c14ee2e 100644 --- a/src/internal/packager/images/push.go +++ b/src/internal/packager/images/push.go @@ -67,7 +67,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) + pushOptions := createPushOpts(cfg) pushImage := func(img v1.Image, name string) error { if tunnel != nil { From 582b76b5cefee5b31d9256f4a79aa1061bce2329 Mon Sep 17 00:00:00 2001 From: schristoff <28318173+schristoff@users.noreply.github.com> Date: Thu, 3 Oct 2024 19:07:32 +0100 Subject: [PATCH 3/4] remove progress bar Signed-off-by: schristoff <28318173+schristoff@users.noreply.github.com> --- 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 2b7c14ee2e..24de30f179 100644 --- a/src/internal/packager/images/push.go +++ b/src/internal/packager/images/push.go @@ -6,11 +6,9 @@ package images import ( "context" - "fmt" "time" "github.com/avast/retry-go/v4" - "github.com/defenseunicorns/pkg/helpers/v2" "github.com/google/go-containerregistry/pkg/crane" "github.com/google/go-containerregistry/pkg/logs" v1 "github.com/google/go-containerregistry/pkg/v1" @@ -64,9 +62,6 @@ func Push(ctx context.Context, cfg PushConfig) error { defer tunnel.Close() } } - - progress := message.NewProgressBar(totalSize, fmt.Sprintf("Pushing %d images", len(toPush))) - defer progress.Close() pushOptions := createPushOpts(cfg) pushImage := func(img v1.Image, name string) error { @@ -84,8 +79,6 @@ func Push(ctx context.Context, cfg PushConfig) error { } }() for refInfo, img := range toPush { - refTruncated := helpers.Truncate(refInfo.Reference, 55, true) - progress.Updatef(fmt.Sprintf("Pushing %s", refTruncated)) size, err := calcImgSize(img) if err != nil { @@ -122,7 +115,6 @@ 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 { From c0d8fa41d40d5936e05da2906dee2a66ff40838f Mon Sep 17 00:00:00 2001 From: schristoff <28318173+schristoff@users.noreply.github.com> Date: Fri, 4 Oct 2024 09:56:20 +0100 Subject: [PATCH 4/4] do it right this time Signed-off-by: schristoff <28318173+schristoff@users.noreply.github.com> --- src/internal/packager/images/push.go | 40 ---------------------------- 1 file changed, 40 deletions(-) diff --git a/src/internal/packager/images/push.go b/src/internal/packager/images/push.go index 24de30f179..480bc5075c 100644 --- a/src/internal/packager/images/push.go +++ b/src/internal/packager/images/push.go @@ -25,7 +25,6 @@ func Push(ctx context.Context, cfg PushConfig) error { logs.Progress.SetOutput(&message.DebugWriter{}) toPush := map[transform.Image]v1.Image{} - var totalSize int64 // Build an image list from the references for _, refInfo := range cfg.ImageList { img, err := utils.LoadOCIImage(cfg.SourceDirectory, refInfo) @@ -33,16 +32,6 @@ func Push(ctx context.Context, cfg PushConfig) error { return err } toPush[refInfo] = img - imgSize, err := calcImgSize(img) - if err != nil { - return err - } - totalSize += imgSize - } - - // If this is not a no checksum image push we will be pushing two images (the second will go faster as it checks the same layers) - if !cfg.NoChecksum { - totalSize = totalSize * 2 } var ( @@ -80,11 +69,6 @@ func Push(ctx context.Context, cfg PushConfig) error { }() for refInfo, img := range toPush { - 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) @@ -96,7 +80,6 @@ func Push(ctx context.Context, cfg PushConfig) error { return err } - totalSize -= size } // To allow for other non-zarf workloads to easily see the images upload a non-checksum version @@ -113,7 +96,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)) @@ -123,25 +105,3 @@ func Push(ctx context.Context, cfg PushConfig) error { return nil } - -func calcImgSize(img v1.Image) (int64, error) { - size, err := img.Size() - if err != nil { - return size, err - } - - layers, err := img.Layers() - if err != nil { - return size, err - } - - for _, layer := range layers { - ls, err := layer.Size() - if err != nil { - return size, err - } - size += ls - } - - return size, nil -}