From 99f5dc501dedc35aec20750530ef50829978e522 Mon Sep 17 00:00:00 2001 From: Wilson Mo Date: Mon, 1 Jun 2026 20:03:33 +0800 Subject: [PATCH] feat: log warning if unable to validateRunImageConfig for whatever error returned (#2584) Signed-off-by: Wilson Mo --- pkg/client/create_builder.go | 7 +------ pkg/client/create_builder_test.go | 16 ++++++---------- 2 files changed, 7 insertions(+), 16 deletions(-) diff --git a/pkg/client/create_builder.go b/pkg/client/create_builder.go index fb42b83ef..3831df69a 100644 --- a/pkg/client/create_builder.go +++ b/pkg/client/create_builder.go @@ -172,9 +172,7 @@ func (c *Client) validateRunImageConfig(ctx context.Context, opts CreateBuilderO if !opts.Publish { img, err := c.imageFetcher.Fetch(ctx, i, image.FetchOptions{Daemon: true, PullPolicy: opts.PullPolicy, Target: target}) if err != nil { - if errors.Cause(err) != image.ErrNotFound { - return errors.Wrap(err, "failed to fetch image") - } + c.logger.Warnf("run image %s is not accessible", style.Symbol(i)) } else { runImages = append(runImages, img) continue @@ -183,9 +181,6 @@ func (c *Client) validateRunImageConfig(ctx context.Context, opts CreateBuilderO img, err := c.imageFetcher.Fetch(ctx, i, image.FetchOptions{Daemon: false, PullPolicy: opts.PullPolicy, Target: target}) if err != nil { - if errors.Cause(err) != image.ErrNotFound { - return errors.Wrap(err, "failed to fetch image") - } c.logger.Warnf("run image %s is not accessible", style.Symbol(i)) } else { runImages = append(runImages, img) diff --git a/pkg/client/create_builder_test.go b/pkg/client/create_builder_test.go index 1eb51cf45..83aecc2de 100644 --- a/pkg/client/create_builder_test.go +++ b/pkg/client/create_builder_test.go @@ -388,19 +388,15 @@ func testCreateBuilder(t *testing.T, when spec.G, it spec.S) { h.AssertContains(t, out.String(), "Warning: run image 'some/run-image' is not accessible") }) - it("should fail when not publish and the run image cannot be fetched", func() { - mockImageFetcher.EXPECT().Fetch(gomock.Any(), "some/run-image", image.FetchOptions{Daemon: true, PullPolicy: image.PullAlways}).Return(nil, errors.New("yikes")) - - err := subject.CreateBuilder(context.TODO(), opts) - h.AssertError(t, err, "failed to fetch image: yikes") - }) - - it("should fail when publish and the run image cannot be fetched", func() { - mockImageFetcher.EXPECT().Fetch(gomock.Any(), "some/run-image", image.FetchOptions{Daemon: false, PullPolicy: image.PullAlways}).Return(nil, errors.New("yikes")) + it("should warn when publish and the run image cannot be fetched", func() { + prepareFetcherWithBuildImage() + mockImageFetcher.EXPECT().Fetch(gomock.Any(), "some/run-image", image.FetchOptions{Daemon: false, PullPolicy: image.PullAlways}).Return(nil, errors.Wrap(image.ErrNotFound, "yikes")) + mockImageFetcher.EXPECT().Fetch(gomock.Any(), "localhost:5000/some/run-image", image.FetchOptions{Daemon: false, PullPolicy: image.PullAlways}).Return(nil, errors.Wrap(image.ErrNotFound, "yikes")) opts.Publish = true err := subject.CreateBuilder(context.TODO(), opts) - h.AssertError(t, err, "failed to fetch image: yikes") + h.AssertNil(t, err) + h.AssertContains(t, out.String(), "Warning: run image 'some/run-image' is not accessible") }) it("should fail when the run image isn't a valid image", func() {