diff --git a/.github/workflows/cluster.yaml b/.github/workflows/cluster.yaml index 07357f6c..2047b60c 100644 --- a/.github/workflows/cluster.yaml +++ b/.github/workflows/cluster.yaml @@ -140,7 +140,13 @@ jobs: killall --wait -r zot-*; \ exit 1; \ fi + env: + AWS_ACCESS_KEY_ID: minioadmin + AWS_SECRET_ACCESS_KEY: minioadmin + - name: Kill zot and collect logs for push-pull tests + if: always() + run: | echo "killing zot instances" killall --wait -r zot-* @@ -153,9 +159,6 @@ jobs: sudo rm -rf /tmp/zot*/ # clean zot logs rm /tmp/*.log - env: - AWS_ACCESS_KEY_ID: minioadmin - AWS_SECRET_ACCESS_KEY: minioadmin - name: Upload zot logs for push-pull tests uses: actions/upload-artifact@v4 @@ -179,7 +182,13 @@ jobs: # run zb with --src-cidr bin/zb-linux-amd64 -c 10 -n 50 -o ci-cd --src-cidr 127.0.0.0/8 http://localhost:8080 + env: + AWS_ACCESS_KEY_ID: minioadmin + AWS_SECRET_ACCESS_KEY: minioadmin + - name: Kill zot and collect logs for cidr tests + if: always() + run: | echo "killing zot instances" killall --wait -r zot-* @@ -192,9 +201,6 @@ jobs: sudo rm -rf /tmp/zot*/ # clean zot logs rm /tmp/*.log - env: - AWS_ACCESS_KEY_ID: minioadmin - AWS_SECRET_ACCESS_KEY: minioadmin - name: Upload zot logs for cidr tests uses: actions/upload-artifact@v4 @@ -218,15 +224,18 @@ jobs: # run zb with --src-ips bin/zb-linux-amd64 -c 10 -n 50 -o ci-cd --src-ips 127.0.0.2,127.0.0.3,127.0.0.4,127.0.0.5,127.0.0.6,127.0.12.5,127.0.12.6 http://localhost:8080 + env: + AWS_ACCESS_KEY_ID: minioadmin + AWS_SECRET_ACCESS_KEY: minioadmin + - name: Kill zot and collect logs for src-ips tests + if: always() + run: | echo "killing zot instances" killall --wait -r zot-* # archive logs zip logs-src-ips-bolt.zip /tmp/*.log -r - env: - AWS_ACCESS_KEY_ID: minioadmin - AWS_SECRET_ACCESS_KEY: minioadmin - name: Upload zot logs for src-ips tests uses: actions/upload-artifact@v4 @@ -395,7 +404,13 @@ jobs: killall --wait -r zot-*; \ exit 1; \ fi + env: + AWS_ACCESS_KEY_ID: minioadmin + AWS_SECRET_ACCESS_KEY: minioadmin + - name: Kill zot and collect logs for push-pull tests + if: always() + run: | echo "killing zot instances" killall --wait -r zot-* @@ -408,9 +423,6 @@ jobs: docker exec redis redis-cli FLUSHDB # clean zot logs rm /tmp/*.log - env: - AWS_ACCESS_KEY_ID: minioadmin - AWS_SECRET_ACCESS_KEY: minioadmin - name: Upload zot logs for push-pull tests uses: actions/upload-artifact@v4 @@ -434,7 +446,13 @@ jobs: # run zb with --src-cidr bin/zb-linux-amd64 -c 10 -n 50 -o ci-cd --src-cidr 127.0.0.0/8 http://localhost:8080 + env: + AWS_ACCESS_KEY_ID: minioadmin + AWS_SECRET_ACCESS_KEY: minioadmin + - name: Kill zot and collect logs for cidr tests + if: always() + run: | echo "killing zot instances" killall --wait -r zot-* @@ -447,9 +465,6 @@ jobs: docker exec redis redis-cli FLUSHDB # clean zot logs rm /tmp/*.log - env: - AWS_ACCESS_KEY_ID: minioadmin - AWS_SECRET_ACCESS_KEY: minioadmin - name: Upload zot logs for cidr tests uses: actions/upload-artifact@v4 @@ -473,15 +488,18 @@ jobs: # run zb with --src-ips bin/zb-linux-amd64 -c 10 -n 50 -o ci-cd --src-ips 127.0.0.2,127.0.0.3,127.0.0.4,127.0.0.5,127.0.0.6,127.0.12.5,127.0.12.6 http://localhost:8080 + env: + AWS_ACCESS_KEY_ID: minioadmin + AWS_SECRET_ACCESS_KEY: minioadmin + - name: Kill zot and collect logs for src-ips tests + if: always() + run: | echo "killing zot instances" killall --wait -r zot-* # archive logs zip logs-src-ips-redis.zip /tmp/*.log -r - env: - AWS_ACCESS_KEY_ID: minioadmin - AWS_SECRET_ACCESS_KEY: minioadmin - name: Upload zot logs for src-ips tests uses: actions/upload-artifact@v4 diff --git a/pkg/meta/boltdb/boltdb.go b/pkg/meta/boltdb/boltdb.go index d357c8dd..b54523fd 100644 --- a/pkg/meta/boltdb/boltdb.go +++ b/pkg/meta/boltdb/boltdb.go @@ -17,6 +17,7 @@ import ( zerr "zotregistry.dev/zot/errors" "zotregistry.dev/zot/pkg/api/constants" zcommon "zotregistry.dev/zot/pkg/common" + "zotregistry.dev/zot/pkg/compat" "zotregistry.dev/zot/pkg/log" "zotregistry.dev/zot/pkg/meta/common" mConvert "zotregistry.dev/zot/pkg/meta/convert" @@ -142,13 +143,13 @@ func (bdw *BoltDB) SetImageMeta(digest godigest.Digest, imageMeta mTypes.ImageMe protoImageMeta := &proto_go.ImageMeta{} - switch imageMeta.MediaType { - case ispec.MediaTypeImageManifest: + if imageMeta.MediaType == ispec.MediaTypeImageManifest || + compat.IsCompatibleManifestMediaType(imageMeta.MediaType) { manifest := imageMeta.Manifests[0] - protoImageMeta = mConvert.GetProtoImageManifestData(manifest.Manifest, manifest.Config, manifest.Size, manifest.Digest.String()) - case ispec.MediaTypeImageIndex: + } else if imageMeta.MediaType == ispec.MediaTypeImageIndex || + compat.IsCompatibleManifestListMediaType(imageMeta.MediaType) { protoImageMeta = mConvert.GetProtoImageIndexMeta(*imageMeta.Index, imageMeta.Size, imageMeta.Digest.String()) } @@ -399,7 +400,8 @@ func (bdw *BoltDB) FilterImageMeta(ctx context.Context, digests []string, return err } - if protoImageMeta.MediaType == ispec.MediaTypeImageIndex { + if protoImageMeta.MediaType == ispec.MediaTypeImageIndex || + compat.IsCompatibleManifestListMediaType(protoImageMeta.MediaType) { _, manifestDataList, err := getAllContainedMeta(imageBuck, protoImageMeta) if err != nil { return err @@ -487,16 +489,26 @@ func getAllContainedMeta(imageBuck *bbolt.Bucket, imageIndexData *proto_go.Image imageMetaList := make([]*proto_go.ImageMeta, 0, len(imageIndexData.Index.Index.Manifests)) for _, manifest := range imageIndexData.Index.Index.Manifests { + if manifest.MediaType != ispec.MediaTypeImageManifest && + manifest.MediaType != ispec.MediaTypeImageIndex && + !compat.IsCompatibleManifestMediaType(manifest.MediaType) && + !compat.IsCompatibleManifestListMediaType(manifest.MediaType) { + // filter out unexpected media types from the manifest lists, + // this could be the case of buildkit cache entries for example + continue + } + imageManifestData, err := getProtoImageMeta(imageBuck, manifest.Digest) if err != nil { return imageMetaList, manifestDataList, err } - switch imageManifestData.MediaType { - case ispec.MediaTypeImageManifest: + if imageManifestData.MediaType == ispec.MediaTypeImageManifest || + compat.IsCompatibleManifestMediaType(imageManifestData.MediaType) { imageMetaList = append(imageMetaList, imageManifestData) manifestDataList = append(manifestDataList, imageManifestData.Manifests[0]) - case ispec.MediaTypeImageIndex: + } else if imageManifestData.MediaType == ispec.MediaTypeImageIndex || + compat.IsCompatibleManifestListMediaType(imageManifestData.MediaType) { partialImageDataList, partialManifestDataList, err := getAllContainedMeta(imageBuck, imageManifestData) if err != nil { return imageMetaList, manifestDataList, err @@ -555,8 +567,8 @@ func (bdw *BoltDB) SearchTags(ctx context.Context, searchText string, var protoImageMeta *proto_go.ImageMeta - switch descriptor.MediaType { - case ispec.MediaTypeImageManifest: + if descriptor.MediaType == ispec.MediaTypeImageManifest || //nolint:gocritic + compat.IsCompatibleManifestMediaType(descriptor.MediaType) { manifestDigest := descriptor.Digest imageManifestData, err := getProtoImageMeta(imageBuck, manifestDigest) @@ -566,7 +578,8 @@ func (bdw *BoltDB) SearchTags(ctx context.Context, searchText string, } protoImageMeta = imageManifestData - case ispec.MediaTypeImageIndex: + } else if descriptor.MediaType == ispec.MediaTypeImageIndex || + compat.IsCompatibleManifestListMediaType(descriptor.MediaType) { indexDigest := descriptor.Digest imageIndexData, err := getProtoImageMeta(imageBuck, indexDigest) @@ -583,7 +596,7 @@ func (bdw *BoltDB) SearchTags(ctx context.Context, searchText string, imageIndexData.Manifests = manifestDataList protoImageMeta = imageIndexData - default: + } else { bdw.Log.Error().Str("mediaType", descriptor.MediaType).Msg("unsupported media type") continue @@ -637,8 +650,8 @@ func (bdw *BoltDB) FilterTags(ctx context.Context, filterRepoTag mTypes.FilterRe continue } - switch descriptor.MediaType { - case ispec.MediaTypeImageManifest: + if descriptor.MediaType == ispec.MediaTypeImageManifest || //nolint:gocritic + compat.IsCompatibleManifestMediaType(descriptor.MediaType) { manifestDigest := descriptor.Digest imageManifestData, err := getProtoImageMeta(imageMetaBuck, manifestDigest) @@ -653,7 +666,8 @@ func (bdw *BoltDB) FilterTags(ctx context.Context, filterRepoTag mTypes.FilterRe if filterFunc(repoMeta, imageMeta) { images = append(images, mConvert.GetFullImageMetaFromProto(tag, protoRepoMeta, imageManifestData)) } - case ispec.MediaTypeImageIndex: + } else if descriptor.MediaType == ispec.MediaTypeImageIndex || + compat.IsCompatibleManifestListMediaType(descriptor.MediaType) { indexDigest := descriptor.Digest protoImageIndexMeta, err := getProtoImageMeta(imageMetaBuck, indexDigest) @@ -687,7 +701,7 @@ func (bdw *BoltDB) FilterTags(ctx context.Context, filterRepoTag mTypes.FilterRe images = append(images, mConvert.GetFullImageMetaFromProto(tag, protoRepoMeta, protoImageIndexMeta)) } - default: + } else { bdw.Log.Error().Str("mediaType", descriptor.MediaType).Msg("unsupported media type") continue @@ -812,7 +826,8 @@ func (bdw *BoltDB) GetFullImageMeta(ctx context.Context, repo string, tag string return err } - if protoImageMeta.MediaType == ispec.MediaTypeImageIndex { + if protoImageMeta.MediaType == ispec.MediaTypeImageIndex || + compat.IsCompatibleManifestListMediaType(protoImageMeta.MediaType) { _, manifestDataList, err := getAllContainedMeta(imageBuck, protoImageMeta) if err != nil { return err @@ -838,7 +853,8 @@ func (bdw *BoltDB) GetImageMeta(digest godigest.Digest) (mTypes.ImageMeta, error return err } - if protoImageMeta.MediaType == ispec.MediaTypeImageIndex { + if protoImageMeta.MediaType == ispec.MediaTypeImageIndex || + compat.IsCompatibleManifestListMediaType(protoImageMeta.MediaType) { _, manifestDataList, err := getAllContainedMeta(imageBuck, protoImageMeta) if err != nil { return err diff --git a/pkg/meta/convert/convert.go b/pkg/meta/convert/convert.go index 6f2924bd..3d8663b4 100644 --- a/pkg/meta/convert/convert.go +++ b/pkg/meta/convert/convert.go @@ -9,6 +9,7 @@ import ( "google.golang.org/protobuf/types/known/timestamppb" "zotregistry.dev/zot/pkg/common" + "zotregistry.dev/zot/pkg/compat" proto_go "zotregistry.dev/zot/pkg/meta/proto/gen" mTypes "zotregistry.dev/zot/pkg/meta/types" ) @@ -362,10 +363,17 @@ func GetManifests(descriptors []ispec.Descriptor) []mTypes.ManifestMeta { manifestList := []mTypes.ManifestMeta{} for _, manifest := range descriptors { - manifestList = append(manifestList, mTypes.ManifestMeta{ - Digest: manifest.Digest, - Size: manifest.Size, - }) + mediaType := manifest.MediaType + + // let's filter out unexpected media types from the manifest lists, + // this could be the case of buildkit cache entries for example + if mediaType == ispec.MediaTypeImageManifest || compat.IsCompatibleManifestMediaType(mediaType) || + mediaType == ispec.MediaTypeImageIndex || compat.IsCompatibleManifestListMediaType(mediaType) { + manifestList = append(manifestList, mTypes.ManifestMeta{ + Digest: manifest.Digest, + Size: manifest.Size, + }) + } } return manifestList diff --git a/pkg/meta/dynamodb/dynamodb.go b/pkg/meta/dynamodb/dynamodb.go index 73aa35fa..186542e0 100644 --- a/pkg/meta/dynamodb/dynamodb.go +++ b/pkg/meta/dynamodb/dynamodb.go @@ -19,6 +19,7 @@ import ( zerr "zotregistry.dev/zot/errors" "zotregistry.dev/zot/pkg/api/constants" zcommon "zotregistry.dev/zot/pkg/common" + "zotregistry.dev/zot/pkg/compat" "zotregistry.dev/zot/pkg/log" "zotregistry.dev/zot/pkg/meta/common" mConvert "zotregistry.dev/zot/pkg/meta/convert" @@ -228,10 +229,19 @@ func (dwr *DynamoDB) getAllContainedMeta(ctx context.Context, imageIndexData *pr ) ([]*proto_go.ImageMeta, []*proto_go.ManifestMeta, error) { manifestDataList := make([]*proto_go.ManifestMeta, 0, len(imageIndexData.Index.Index.Manifests)) imageMetaList := make([]*proto_go.ImageMeta, 0, len(imageIndexData.Index.Index.Manifests)) - manifestDigests := make([]string, 0, len(imageIndexData.Index.Index.Manifests)) - for i := range imageIndexData.Index.Index.Manifests { - manifestDigests = append(manifestDigests, imageIndexData.Index.Index.Manifests[i].Digest) + + for _, manifest := range imageIndexData.Index.Index.Manifests { + if manifest.MediaType != ispec.MediaTypeImageManifest && + manifest.MediaType != ispec.MediaTypeImageIndex && + !compat.IsCompatibleManifestMediaType(manifest.MediaType) && + !compat.IsCompatibleManifestListMediaType(manifest.MediaType) { + // filter out unexpected media types from the manifest lists, + // this could be the case of buildkit cache entries for example + continue + } + + manifestDigests = append(manifestDigests, manifest.Digest) } manifestsAttributes, err := dwr.fetchImageMetaAttributesByDigest(ctx, manifestDigests) @@ -245,11 +255,12 @@ func (dwr *DynamoDB) getAllContainedMeta(ctx context.Context, imageIndexData *pr return imageMetaList, manifestDataList, err } - switch imageManifestData.MediaType { - case ispec.MediaTypeImageManifest: + if imageManifestData.MediaType == ispec.MediaTypeImageManifest || + compat.IsCompatibleManifestMediaType(imageManifestData.MediaType) { imageMetaList = append(imageMetaList, imageManifestData) manifestDataList = append(manifestDataList, imageManifestData.Manifests[0]) - case ispec.MediaTypeImageIndex: + } else if imageManifestData.MediaType == ispec.MediaTypeImageIndex || + compat.IsCompatibleManifestListMediaType(imageManifestData.MediaType) { partialImageDataList, partialManifestDataList, err := dwr.getAllContainedMeta(ctx, imageManifestData) if err != nil { return imageMetaList, manifestDataList, err @@ -659,8 +670,8 @@ func (dwr *DynamoDB) SearchTags(ctx context.Context, searchText string) ([]mType var protoImageMeta *proto_go.ImageMeta - switch descriptor.MediaType { - case ispec.MediaTypeImageManifest: + if descriptor.MediaType == ispec.MediaTypeImageManifest || //nolint:gocritic + compat.IsCompatibleManifestMediaType(descriptor.MediaType) { manifestDigest := descriptor.Digest imageManifestData, err := dwr.GetProtoImageMeta(ctx, godigest.Digest(manifestDigest)) @@ -670,7 +681,8 @@ func (dwr *DynamoDB) SearchTags(ctx context.Context, searchText string) ([]mType } protoImageMeta = imageManifestData - case ispec.MediaTypeImageIndex: + } else if descriptor.MediaType == ispec.MediaTypeImageIndex || + compat.IsCompatibleManifestListMediaType(descriptor.MediaType) { indexDigest := godigest.Digest(descriptor.Digest) imageIndexData, err := dwr.GetProtoImageMeta(ctx, indexDigest) @@ -687,7 +699,7 @@ func (dwr *DynamoDB) SearchTags(ctx context.Context, searchText string) ([]mType imageIndexData.Manifests = manifestDataList protoImageMeta = imageIndexData - default: + } else { dwr.Log.Error().Str("mediaType", descriptor.MediaType).Msg("unsupported media type") continue @@ -741,8 +753,8 @@ func (dwr *DynamoDB) FilterTags(ctx context.Context, filterRepoTag mTypes.Filter continue } - switch descriptor.MediaType { - case ispec.MediaTypeImageManifest: + if descriptor.MediaType == ispec.MediaTypeImageManifest || //nolint:gocritic + compat.IsCompatibleManifestMediaType(descriptor.MediaType) { manifestDigest := descriptor.Digest imageManifestData, err := dwr.GetProtoImageMeta(ctx, godigest.Digest(manifestDigest)) @@ -757,7 +769,8 @@ func (dwr *DynamoDB) FilterTags(ctx context.Context, filterRepoTag mTypes.Filter if filterFunc(repoMeta, imageMeta) { images = append(images, mConvert.GetFullImageMetaFromProto(tag, protoRepoMeta, imageManifestData)) } - case ispec.MediaTypeImageIndex: + } else if descriptor.MediaType == ispec.MediaTypeImageIndex || + compat.IsCompatibleManifestListMediaType(descriptor.MediaType) { indexDigest := descriptor.Digest protoImageIndexMeta, err := dwr.GetProtoImageMeta(ctx, godigest.Digest(indexDigest)) @@ -791,7 +804,7 @@ func (dwr *DynamoDB) FilterTags(ctx context.Context, filterRepoTag mTypes.Filter images = append(images, mConvert.GetFullImageMetaFromProto(tag, protoRepoMeta, protoImageIndexMeta)) } - default: + } else { dwr.Log.Error().Str("mediaType", descriptor.MediaType).Msg("unsupported media type") continue @@ -896,7 +909,8 @@ func (dwr *DynamoDB) GetFullImageMeta(ctx context.Context, repo string, tag stri return mTypes.FullImageMeta{}, err } - if protoImageMeta.MediaType == ispec.MediaTypeImageIndex { + if protoImageMeta.MediaType == ispec.MediaTypeImageIndex || + compat.IsCompatibleManifestListMediaType(protoImageMeta.MediaType) { _, manifestDataList, err := dwr.getAllContainedMeta(ctx, protoImageMeta) if err != nil { return mTypes.FullImageMeta{}, err @@ -923,7 +937,8 @@ func (dwr *DynamoDB) GetImageMeta(digest godigest.Digest) (mTypes.ImageMeta, err return mTypes.ImageMeta{}, err } - if protoImageMeta.MediaType == ispec.MediaTypeImageIndex { + if protoImageMeta.MediaType == ispec.MediaTypeImageIndex || + compat.IsCompatibleManifestListMediaType(protoImageMeta.MediaType) { _, manifestDataList, err := dwr.getAllContainedMeta(context.Background(), protoImageMeta) if err != nil { return mTypes.ImageMeta{}, err @@ -1344,7 +1359,8 @@ func (dwr *DynamoDB) FilterImageMeta(ctx context.Context, digests []string, return nil, err } - if protoImageMeta.MediaType == ispec.MediaTypeImageIndex { + if protoImageMeta.MediaType == ispec.MediaTypeImageIndex || + compat.IsCompatibleManifestListMediaType(protoImageMeta.MediaType) { _, manifestDataList, err := dwr.getAllContainedMeta(context.Background(), protoImageMeta) if err != nil { return nil, err diff --git a/pkg/meta/redis/redis.go b/pkg/meta/redis/redis.go index 50aefa6f..94a07eba 100644 --- a/pkg/meta/redis/redis.go +++ b/pkg/meta/redis/redis.go @@ -19,6 +19,7 @@ import ( zerr "zotregistry.dev/zot/errors" "zotregistry.dev/zot/pkg/api/constants" zcommon "zotregistry.dev/zot/pkg/common" + "zotregistry.dev/zot/pkg/compat" "zotregistry.dev/zot/pkg/log" "zotregistry.dev/zot/pkg/meta/common" mConvert "zotregistry.dev/zot/pkg/meta/convert" @@ -696,13 +697,13 @@ func (rc *RedisDB) SetImageMeta(digest godigest.Digest, imageMeta mTypes.ImageMe protoImageMeta := &proto_go.ImageMeta{} ctx := context.Background() - switch imageMeta.MediaType { - case ispec.MediaTypeImageManifest: + if imageMeta.MediaType == ispec.MediaTypeImageManifest || + compat.IsCompatibleManifestMediaType(imageMeta.MediaType) { manifest := imageMeta.Manifests[0] - protoImageMeta = mConvert.GetProtoImageManifestData(manifest.Manifest, manifest.Config, manifest.Size, manifest.Digest.String()) - case ispec.MediaTypeImageIndex: + } else if imageMeta.MediaType == ispec.MediaTypeImageIndex || + compat.IsCompatibleManifestListMediaType(imageMeta.MediaType) { protoImageMeta = mConvert.GetProtoImageIndexMeta(*imageMeta.Index, imageMeta.Size, imageMeta.Digest.String()) } @@ -980,8 +981,8 @@ func (rc *RedisDB) SearchTags(ctx context.Context, searchText string) ([]mTypes. var protoImageMeta *proto_go.ImageMeta - switch descriptor.MediaType { - case ispec.MediaTypeImageManifest: + if descriptor.MediaType == ispec.MediaTypeImageManifest || //nolint:gocritic + compat.IsCompatibleManifestMediaType(descriptor.MediaType) { manifestDigest := descriptor.Digest imageManifestData, err := rc.getProtoImageMeta(ctx, manifestDigest) @@ -991,7 +992,8 @@ func (rc *RedisDB) SearchTags(ctx context.Context, searchText string) ([]mTypes. } protoImageMeta = imageManifestData - case ispec.MediaTypeImageIndex: + } else if descriptor.MediaType == ispec.MediaTypeImageIndex || + compat.IsCompatibleManifestListMediaType(descriptor.MediaType) { indexDigest := descriptor.Digest imageIndexData, err := rc.getProtoImageMeta(ctx, indexDigest) @@ -1008,7 +1010,7 @@ func (rc *RedisDB) SearchTags(ctx context.Context, searchText string) ([]mTypes. imageIndexData.Manifests = manifestDataList protoImageMeta = imageIndexData - default: + } else { rc.Log.Error().Str("mediaType", descriptor.MediaType).Msg("unsupported media type") continue @@ -1060,8 +1062,8 @@ func (rc *RedisDB) FilterTags(ctx context.Context, filterRepoTag mTypes.FilterRe continue } - switch descriptor.MediaType { - case ispec.MediaTypeImageManifest: + if descriptor.MediaType == ispec.MediaTypeImageManifest || //nolint:gocritic + compat.IsCompatibleManifestMediaType(descriptor.MediaType) { manifestDigest := descriptor.Digest imageManifestData, err := rc.getProtoImageMeta(ctx, manifestDigest) @@ -1076,7 +1078,8 @@ func (rc *RedisDB) FilterTags(ctx context.Context, filterRepoTag mTypes.FilterRe if filterFunc(repoMeta, imageMeta) { images = append(images, mConvert.GetFullImageMetaFromProto(tag, protoRepoMeta, imageManifestData)) } - case ispec.MediaTypeImageIndex: + } else if descriptor.MediaType == ispec.MediaTypeImageIndex || + compat.IsCompatibleManifestListMediaType(descriptor.MediaType) { indexDigest := descriptor.Digest protoImageIndexMeta, err := rc.getProtoImageMeta(ctx, indexDigest) @@ -1110,7 +1113,7 @@ func (rc *RedisDB) FilterTags(ctx context.Context, filterRepoTag mTypes.FilterRe images = append(images, mConvert.GetFullImageMetaFromProto(tag, protoRepoMeta, protoImageIndexMeta)) } - default: + } else { rc.Log.Error().Str("mediaType", descriptor.MediaType).Msg("unsupported media type") continue @@ -1206,7 +1209,8 @@ func (rc *RedisDB) GetFullImageMeta(ctx context.Context, repo string, tag string return mConvert.GetFullImageMetaFromProto(tag, protoRepoMeta, protoImageMeta), err } - if protoImageMeta.MediaType == ispec.MediaTypeImageIndex { + if protoImageMeta.MediaType == ispec.MediaTypeImageIndex || + compat.IsCompatibleManifestListMediaType(protoImageMeta.MediaType) { _, manifestDataList, err := rc.getAllContainedMeta(ctx, protoImageMeta) if err != nil { return mConvert.GetFullImageMetaFromProto(tag, protoRepoMeta, protoImageMeta), err @@ -1228,7 +1232,8 @@ func (rc *RedisDB) GetImageMeta(digest godigest.Digest) (mTypes.ImageMeta, error return imageMeta, err } - if protoImageMeta.MediaType == ispec.MediaTypeImageIndex { + if protoImageMeta.MediaType == ispec.MediaTypeImageIndex || + compat.IsCompatibleManifestListMediaType(protoImageMeta.MediaType) { _, manifestDataList, err := rc.getAllContainedMeta(ctx, protoImageMeta) if err != nil { return imageMeta, err @@ -1773,7 +1778,8 @@ func (rc *RedisDB) FilterImageMeta(ctx context.Context, return imageMetaMap, err } - if protoImageMeta.MediaType == ispec.MediaTypeImageIndex { + if protoImageMeta.MediaType == ispec.MediaTypeImageIndex || + compat.IsCompatibleManifestListMediaType(protoImageMeta.MediaType) { _, manifestDataList, err := rc.getAllContainedMeta(ctx, protoImageMeta) if err != nil { return imageMetaMap, err @@ -2168,16 +2174,26 @@ func (rc *RedisDB) getAllContainedMeta(ctx context.Context, imageIndexData *prot imageMetaList := make([]*proto_go.ImageMeta, 0, len(imageIndexData.Index.Index.Manifests)) for _, manifest := range imageIndexData.Index.Index.Manifests { + if manifest.MediaType != ispec.MediaTypeImageManifest && + manifest.MediaType != ispec.MediaTypeImageIndex && + !compat.IsCompatibleManifestMediaType(manifest.MediaType) && + !compat.IsCompatibleManifestListMediaType(manifest.MediaType) { + // filter out unexpected media types from the manifest lists, + // this could be the case of buildkit cache entries for example + continue + } + imageManifestData, err := rc.getProtoImageMeta(ctx, manifest.Digest) if err != nil { return imageMetaList, manifestDataList, err } - switch imageManifestData.MediaType { - case ispec.MediaTypeImageManifest: + if imageManifestData.MediaType == ispec.MediaTypeImageManifest || + compat.IsCompatibleManifestMediaType(imageManifestData.MediaType) { imageMetaList = append(imageMetaList, imageManifestData) manifestDataList = append(manifestDataList, imageManifestData.Manifests[0]) - case ispec.MediaTypeImageIndex: + } else if imageManifestData.MediaType == ispec.MediaTypeImageIndex || + compat.IsCompatibleManifestListMediaType(imageManifestData.MediaType) { partialImageDataList, partialManifestDataList, err := rc.getAllContainedMeta(ctx, imageManifestData) if err != nil { return imageMetaList, manifestDataList, err