From c4a70ba1dfda9c5723bd2c33277891385db2fdd9 Mon Sep 17 00:00:00 2001 From: Roman Vynar Date: Wed, 18 Sep 2024 11:42:05 +0300 Subject: [PATCH] Add more error logging --- Makefile | 3 +++ registry/client.go | 18 +++++++++++++++--- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index a0ba9a9..4108795 100755 --- a/Makefile +++ b/Makefile @@ -13,5 +13,8 @@ build: public: docker buildx build ${NOCACHE} --platform linux/amd64,linux/arm64 -t ${IMAGE}:${VERSION} -t ${IMAGE}:latest --push . +debug: + docker buildx build ${NOCACHE} --platform linux/amd64,linux/arm64 -t ${IMAGE}:debug --push . + test: docker buildx build ${NOCACHE} --platform linux/amd64 -t docker.quiq.im/registry-ui:test -t docker.quiq.sh/registry-ui:test --push . diff --git a/registry/client.go b/registry/client.go index bbb7c1d..5254d1e 100644 --- a/registry/client.go +++ b/registry/client.go @@ -205,7 +205,11 @@ func (c *Client) GetImageInfo(imageRef string) (ImageInfo, error) { } if ii.IsImage { - img, _ := descr.Image() + img, err := descr.Image() + if err != nil { + c.logger.Errorf("Cannot convert descriptor to Image for image reference %s: %s", imageRef, err) + return ImageInfo{}, err + } cfg, err := img.ConfigFile() if err != nil { c.logger.Errorf("Cannot fetch ConfigFile for image reference %s: %s", imageRef, err) @@ -228,7 +232,11 @@ func (c *Client) GetImageInfo(imageRef string) (ImageInfo, error) { // In case of Image Index, if we request for Image() > ConfigFile(), it will be resolved // to a config of one of the manifests (one of the platforms). // It doesn't make a lot of sense, even they are usually identical. Also extra API calls which slows things down. - imgIdx, _ := descr.ImageIndex() + imgIdx, err := descr.ImageIndex() + if err != nil { + c.logger.Errorf("Cannot convert descriptor to ImageIndex for image reference %s: %s", imageRef, err) + return ImageInfo{}, err + } IdxMf, _ := imgIdx.IndexManifest() platforms := []string{} for _, m := range IdxMf.Manifests { @@ -271,7 +279,11 @@ func (c *Client) GetImageCreated(imageRef string) time.Time { return *zeroTime } // In case of ImageIndex, it is resolved to a random sub-image which should be fine. - img, _ := descr.Image() + img, err := descr.Image() + if err != nil { + c.logger.Errorf("Cannot convert descriptor to Image for image reference %s: %s", imageRef, err) + return *zeroTime + } cfg, err := img.ConfigFile() if err != nil { c.logger.Errorf("Cannot fetch ConfigFile for image reference %s: %s", imageRef, err)