opencontainers / distribution-spec

OCI Distribution Specification
https://opencontainers.org
Apache License 2.0
792 stars 199 forks source link

conformance: skip check (by default) for zero layers in image manifest #421

Closed rchincha closed 1 year ago

rchincha commented 1 year ago

As per image-spec, since this is a SHOULD (hence recommended) ...

https://raw.githubusercontent.com/opencontainers/image-spec/main/manifest.md

===

layers array of objects

Each item in the array MUST be a descriptor. For portability, layers SHOULD have at least one entry.

===

Fixes #410

sajayantony commented 1 year ago

I really hope to see zero layers come back as a valid manifest. Is it possible to keep these cases to see in the future which registries support these without failing conformance? This matrix should be automatable - https://github.com/opencontainers/image-spec/issues/1025

rchincha commented 1 year ago

Perhaps, a way out could be to just enforce all MUSTs and warn on all SHOULDs, so we know without breaking the spirit of the conformance tests.

IINM, this particular test was enforcing that registries that don't accept zero layer manifests are not compliant, whereas the image-spec language has no such language. Also [this](https://github.com/opencontainers/image-spec/blob/main/schema/image-manifest-schema.json#LL30C1-L30C1} needs updating to 0 perhaps.

rchincha commented 1 year ago

A simpler variant of what we want to achieve.

rchincha commented 1 year ago

Updated the PR with one more commit for a different option.

rchincha commented 1 year ago

@sudo-bmitch et al, the two commits can be squashed if we agree with the warning approach.

rchincha commented 1 year ago

Borrowed the Warn() from https://github.com/opencontainers/distribution-spec/pull/375, also what appears to be a bugfix

rchincha commented 1 year ago

zot/main passes with these changes

••••••••••••••••HTML report was created: /local/rchincha/go/src/github.com/opencontainers/distribution-spec/conformance/report.html JUnit report was created: /local/rchincha/go/src/github.com/opencontainers/distribution-spec/conformance/junit.xml

Ran 63 of 68 Specs in 0.204 seconds SUCCESS! -- 63 Passed | 0 Failed | 0 Pending | 5 Skipped

rchincha commented 1 year ago

zot/main instrumented to cause warn passes but with warning

+++ b/pkg/storage/common/common.go
@@ -94,6 +94,10 @@ func ValidateManifest(imgStore storageTypes.ImageStore, repo, reference, mediaTy
                                return "", zerr.ErrBadManifest
                        }
                }
+
+               if len(manifest.Layers) == 0 {
+                       return "", zerr.ErrBadManifest
+               }

•• WARNING: image manifest with no layers is not supported

/local/rchincha/go/src/github.com/opencontainers/distribution-spec/conformance/02_push_test.go:366                                                                    ••••••••

••••••••••••••••HTML report was created: /local/rchincha/go/src/github.com/opencontainers/distribution-spec/conformance/report.html JUnit report was created: /local/rchincha/go/src/github.com/opencontainers/distribution-spec/conformance/junit.xml

Ran 63 of 68 Specs in 0.186 seconds SUCCESS! -- 63 Passed | 0 Failed | 0 Pending | 5 Skipped