From 4be780b8dfc97f47065bf05ea038b2a1856497b4 Mon Sep 17 00:00:00 2001 From: Hayato Kiwata Date: Wed, 1 Apr 2026 22:23:01 +0900 Subject: [PATCH] test: resolve a flaky test of TestLoadStdinFromPipe Signed-off-by: Hayato Kiwata --- pkg/imgutil/load/load.go | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/pkg/imgutil/load/load.go b/pkg/imgutil/load/load.go index 5e80096d5db..c8b4c629a56 100644 --- a/pkg/imgutil/load/load.go +++ b/pkg/imgutil/load/load.go @@ -86,7 +86,6 @@ func FromArchive(ctx context.Context, client *containerd.Client, options types.I var loadedImages []images.Image pf, done := transferutil.ProgressHandler(ctx, options.Stdout) - defer done() err = client.Transfer(ctx, tarchive.NewImageImportStream(options.Stdin, ""), @@ -96,9 +95,6 @@ func FromArchive(ctx context.Context, client *containerd.Client, options types.I if img, err := imageService.Get(ctx, p.Name); err == nil { if !beforeSet[img.Name] { loadedImages = append(loadedImages, img) - if !options.Quiet { - fmt.Fprintf(options.Stdout, "Loaded image: %s\n", img.Name) - } } } } @@ -106,6 +102,14 @@ func FromArchive(ctx context.Context, client *containerd.Client, options types.I }), ) + done() + + if !options.Quiet { + for _, img := range loadedImages { + fmt.Fprintf(options.Stdout, "Loaded image: %s\n", img.Name) + } + } + return loadedImages, err }