From fdb401273c1fcc24eef172a78659b25ccff57919 Mon Sep 17 00:00:00 2001 From: Ramkumar Chinchani <45800463+rchincha@users.noreply.github.com> Date: Tue, 12 Mar 2024 22:28:08 -0700 Subject: [PATCH] fix: ignore metadb errors if tag not found (#2301) --- pkg/api/routes.go | 2 +- pkg/meta/hooks.go | 2 +- test/blackbox/annotations.bats | 6 ++++++ 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/pkg/api/routes.go b/pkg/api/routes.go index 340d5fd0..9defd48e 100644 --- a/pkg/api/routes.go +++ b/pkg/api/routes.go @@ -514,7 +514,7 @@ func (rh *RouteHandler) GetManifest(response http.ResponseWriter, request *http. if rh.c.MetaDB != nil { err := meta.OnGetManifest(name, reference, mediaType, content, rh.c.StoreController, rh.c.MetaDB, rh.c.Log) - if err != nil { + if err != nil && !errors.Is(err, zerr.ErrImageMetaNotFound) { response.WriteHeader(http.StatusInternalServerError) return diff --git a/pkg/meta/hooks.go b/pkg/meta/hooks.go index aff5ef98..74fe3e0d 100644 --- a/pkg/meta/hooks.go +++ b/pkg/meta/hooks.go @@ -100,7 +100,7 @@ func OnDeleteManifest(repo, reference, mediaType string, digest godigest.Digest, return nil } -// OnDeleteManifest is called when a manifest is downloaded. It increments the download couter on that manifest. +// OnGetManifest is called when a manifest is downloaded. It increments the download couter on that manifest. func OnGetManifest(name, reference, mediaType string, body []byte, storeController storage.StoreController, metaDB mTypes.MetaDB, log log.Logger, ) error { diff --git a/test/blackbox/annotations.bats b/test/blackbox/annotations.bats index 819ad7c6..55754c07 100644 --- a/test/blackbox/annotations.bats +++ b/test/blackbox/annotations.bats @@ -136,6 +136,12 @@ function teardown_file() { [ "$status" -eq 0 ] local sigName=$(echo "${lines[-1]}" | jq '.[].critical.image."docker-manifest-digest"') [[ "$sigName" == *"${digest}"* ]] + tags=( $(oras repo tags --plain-http localhost:${zot_port}/annotations) ) + [ "$status" -eq 0 ] + local sigdes=$(oras manifest fetch --descriptor localhost:${zot_port}/annotations:${tags[1]} | jq .digest | tr -d \") + [ "$status" -eq 0 ] + run oras manifest fetch --plain-http localhost:${zot_port}/annotations@${sigdes} + [ "$status" -eq 0 ] } @test "sign/verify with cosign (only referrers)" {