Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 2 commits into from
Jun 21, 2023

Conversation

rchincha
Copy link
Contributor

@rchincha rchincha commented May 25, 2023

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

@rchincha rchincha force-pushed the artifacts branch 2 times, most recently from bc70029 to 3752917 Compare May 25, 2023 19:06
@rchincha rchincha changed the title fix: remove check for zero layers conformance: remove check for zero layers in image manifest May 25, 2023
@sajayantony
Copy link
Member

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 - opencontainers/image-spec#1025

@rchincha
Copy link
Contributor Author

rchincha commented May 26, 2023

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
Copy link
Contributor Author

A simpler variant of what we want to achieve.

@rchincha rchincha force-pushed the artifacts branch 2 times, most recently from 028d12d to 7845d34 Compare May 26, 2023 19:16
@rchincha rchincha marked this pull request as ready for review May 26, 2023 19:16
@rchincha rchincha changed the title conformance: remove check for zero layers in image manifest conformance: skip check (by default) for zero layers in image manifest May 26, 2023
Copy link
Contributor

@sudo-bmitch sudo-bmitch left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This needs another change to actually apply.

@sajayantony if we want add warnings, I'd be open to that as a separate PR.

conformance/setup.go Outdated Show resolved Hide resolved
sudo-bmitch
sudo-bmitch previously approved these changes Jun 1, 2023
@rchincha
Copy link
Contributor Author

rchincha commented Jun 7, 2023

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

@rchincha
Copy link
Contributor Author

rchincha commented Jun 8, 2023

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

@rchincha
Copy link
Contributor Author

Borrowed the Warn() from #375, also what appears to be a bugfix

Comment on lines 362 to 371
fmt.Fprintf(colorable.NewColorableStderr(), "\n")
// print message
msgcolor := color.New(color.FgMagenta).FprintfFunc()
msgcolor(colorable.NewColorableStderr(), formatter.Fi(2, "\nWARNING: "+message))
fmt.Fprintf(colorable.NewColorableStderr(), "\n")
// print file:line
_, file, line, _ := runtime.Caller(1)
flcolor := color.New(color.FgWhite).FprintfFunc()
flcolor(colorable.NewColorableStderr(), formatter.Fi(2, "\n"))
flcolor(colorable.NewColorableStderr(), formatter.Fi(2, "%s:%d\n", file, line))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wondering if we can simply do this warning with log/fmt package as not to bring in additional go mods?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could. However, the colors give important visual feedback IMO.

https://github.com/onsi/ginkgo/blob/master/formatter/formatter_test.go#L51

https://github.com/onsi/ginkgo/blob/master/formatter/formatter.go#L60

^ let me try this instead?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.


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

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

^ with the right colors still happens.

conformance/setup.go Outdated Show resolved Hide resolved
jdolitsky
jdolitsky previously approved these changes Jun 21, 2023
@rchincha rchincha requested a review from jdolitsky June 21, 2023 21:13
Comment on lines 357 to 361
// print message
fmt.Fprintf(os.Stderr, formatter.Fi(2, "\n{{magenta}}WARNING: %s\n{{/}}", message))
// print file:line
_, file, line, _ := runtime.Caller(1)
fmt.Fprintf(os.Stderr, formatter.Fi(2, "\n%s:%d\n", file, line))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

some sort of linting issue on these

Error: setup.go:358:2: SA1006: printf-style function with dynamic format string and no further arguments should use print-style function instead (staticcheck)
level=info msg="File cache stats: 1 entries of total size 12.4KiB"
	fmt.Fprintf(os.Stderr, formatter.Fi(2, "\n{{magenta}}WARNING: %s\n{{/}}", message))
	^
Error: setup.go:361:2: SA1006: printf-style function with dynamic format string and no further arguments should use print-style function instead (staticcheck)
	fmt.Fprintf(os.Stderr, formatter.Fi(2, "\n%s:%d\n", file, line))
	^
	```

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

As per image-spec, since this is a SHOULD (hence recommended) and now
turned off by default.

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.

===

One can enable this test by setting env var:
OCI_SKIP_EMPTY_LAYER_PUSH_TEST=0

Signed-off-by: Ramkumar Chinchani <rchincha@cisco.com>
emptyLayerManifest is being pushed but not deleted during teardown

Signed-off-by: Ramkumar Chinchani <rchincha@cisco.com>
@rchincha
Copy link
Contributor Author

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 rchincha requested a review from jdolitsky June 21, 2023 21:20
@rchincha
Copy link
Contributor Author

rchincha commented Jun 21, 2023

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

@jdolitsky jdolitsky merged commit c76f05b into opencontainers:main Jun 21, 2023
@jdolitsky jdolitsky mentioned this pull request Jun 27, 2023
8 tasks
@jdolitsky jdolitsky mentioned this pull request Jul 6, 2023
8 tasks
sudo-bmitch pushed a commit to sudo-bmitch/distribution-spec that referenced this pull request Aug 18, 2023
opencontainers#421)

* conformance: always run but warn if empty layer manifest not supported

As per image-spec, since this is a SHOULD (hence recommended) and now
turned off by default.

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.

===

One can enable this test by setting env var:
OCI_SKIP_EMPTY_LAYER_PUSH_TEST=0

Signed-off-by: Ramkumar Chinchani <rchincha@cisco.com>

* conformance: delete the empty manifest in teardown

emptyLayerManifest is being pushed but not deleted during teardown

Signed-off-by: Ramkumar Chinchani <rchincha@cisco.com>

---------

Signed-off-by: Ramkumar Chinchani <rchincha@cisco.com>
@sudo-bmitch sudo-bmitch mentioned this pull request Feb 1, 2024
8 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

image spec says layers should have at least one entry
5 participants