From b963e37cc61a502269240798d67c26f999f16aca Mon Sep 17 00:00:00 2001 From: muhammad adil ghaffar Date: Thu, 29 Feb 2024 10:02:15 +0200 Subject: [PATCH] EnsureImage download image fix Signed-off-by: muhammad adil ghaffar --- test/e2e/common.go | 4 ++++ test/go.mod | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/test/e2e/common.go b/test/e2e/common.go index f02a1857fb..868786a2ee 100644 --- a/test/e2e/common.go +++ b/test/e2e/common.go @@ -22,6 +22,7 @@ import ( ipamv1 "github.com/metal3-io/ip-address-manager/api/v1alpha1" . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" + "github.com/pkg/errors" "golang.org/x/crypto/ssh" corev1 "k8s.io/api/core/v1" apiextensionsv1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1" @@ -181,6 +182,9 @@ func DownloadFile(filePath string, url string) error { if err != nil { return err } + if resp.StatusCode != http.StatusOK { + return errors.Errorf("failed to download image from %q got %d %s", filePath, resp.StatusCode, http.StatusText(resp.StatusCode)) + } defer resp.Body.Close() // Create the file diff --git a/test/go.mod b/test/go.mod index 9f77fe5798..22bb09195d 100644 --- a/test/go.mod +++ b/test/go.mod @@ -10,6 +10,7 @@ require ( github.com/metal3-io/ip-address-manager/api v1.6.0 github.com/onsi/ginkgo/v2 v2.15.0 github.com/onsi/gomega v1.31.1 + github.com/pkg/errors v0.9.1 golang.org/x/crypto v0.20.0 gopkg.in/yaml.v3 v3.0.1 k8s.io/api v0.29.2 @@ -90,7 +91,6 @@ require ( github.com/opencontainers/image-spec v1.0.2 // indirect github.com/pelletier/go-toml v1.9.5 // indirect github.com/pelletier/go-toml/v2 v2.1.0 // indirect - github.com/pkg/errors v0.9.1 // indirect github.com/prometheus/client_golang v1.18.0 // indirect github.com/prometheus/client_model v0.5.0 // indirect github.com/prometheus/common v0.45.0 // indirect