-
Notifications
You must be signed in to change notification settings - Fork 383
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
OCI layout extensions #2633
base: main
Are you sure you want to change the base?
OCI layout extensions #2633
Conversation
In draft for now. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a quick skim; I’m afraid I didn’t read the added tests yet.
ae7457e
to
234b45f
Compare
I'd love to have some explicit test condition on Linux to make sure that the reflinking works. We're using the function from c/storage which is e2e tested. The unit tests run on tmp, so we have to create the test dirs in $HOME ... not sure we should though. |
234b45f
to
6481647
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actual detailed review still pending, I’m afraid.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A full review now.
@@ -148,11 +148,17 @@ func testParseReference(t *testing.T, fn func(string) (types.ImageReference, err | |||
"relativepath", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Holding the line at “all of *_transport.go
should have test coverage”, please port the two test cases added to TestGetManifestDescriptor
from #1677 (and then see if more need to be added).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isn't that already being tested now with fixtures/two_images_manifest
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tooling says that case ref.image != "" && ref.sourceIndex != -1:
and case ref.sourceIndex != -1:
is not covered by tests.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah. These cases cannot be covered by TestGetManifestDescriptor
where sourceIndex
is always -1
AFAICS.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can case ref.image != "" && ref.sourceIndex != -1:
ever be executed by the code at all?
// NewIndexReference returns an OCI reference for a path and a zero-based source manifest index.
func NewIndexReference(dir string, sourceIndex int) (types.ImageReference, error) {
return newReference(dir, "", sourceIndex)
}
// NewReference returns an OCI reference for a directory and a image.
//
// We do not expose an API supplying the resolvedDir; we could, but recomputing it
// is generally cheap enough that we prefer being confident about the properties of resolvedDir.
func NewReference(dir, image string) (types.ImageReference, error) {
return newReference(dir, image, -1)
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TestNewIndexReference
seems to cover those cases
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- You’re right,
case ref.image != "" && ref.sourceIndex != -1:
should be unreachable. We could manually manufacture an invalid value, but that would be rather excessive. Please only add a comment documenting how this code is expected to be unreachable, similar toimage/docker/daemon/daemon_transport.go
Line 170 in 75e4f15
default: // Coverage: Should never happen, NewReference above should refuse such values. case ref.sourceIndex != -1:
is legitimate and should be reachable. Yes, that does not fit the current loop inTestGetManifestDescriptor
— adding code outside of that loop is an option. OCI-archive multi-manifest support POC #1677 contains a smoke test for the success case, please add also a test for an out-of-bounds index.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done ✅
…
Tests writing to non-test directories , and possibly leaving them around on aborts/failures, seems rather unexpected to me, some might consider it (or, at least, be worried that it is) hostile. So I’d prefer to leave this to e2e tests, maybe the future tests of the Podman artifact CLI. (Just because I was looking it up, Google says reflinks don’t work on ext4. That’s not really a blocker, we could gate this behind a filesystem type check.) |
Vendor containers/image/pull/2633 and update the code so we can start testing it. Signed-off-by: Valentin Rothberg <[email protected]>
30a132d
to
8565739
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! ACK overall.
Ideally, I’d prefer sharing the reflink call with c/storage, but the logic (usage of c/storage/pkg/pools
requires c/storage to explicitly special-case CopyFileRange
, which is otherwise automatic) is just different enough to make that awkward, and anyway it’s ~10 lines, so not worth worrying about.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Images in the index can now be referenced via the @sourceIndex syntax. Signed-off-by: Miloslav Trmač <[email protected]> Signed-off-by: Valentin Rothberg <[email protected]>
The new API allows for listing all manifests in an OCI layout's index. Signed-off-by: Miloslav Trmač <[email protected]> Signed-off-by: Valentin Rothberg <[email protected]>
Try to reflink the file and restort to copying it in case of failure. Also add an Options struct to be future proof. Signed-off-by: Miloslav Trmač <[email protected]> Signed-off-by: Valentin Rothberg <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
One last thing, feel free to merge afterwards.
if sourceIndex != -1 && sourceIndex < 0 { | ||
return nil, fmt.Errorf("Invalid oci: layout reference: index @%d must not be negative", sourceIndex) | ||
} | ||
if sourceIndex != -1 && image != "" { // Coverage: New*Reference do not pass down that condition |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please move that comment to the uncovered getManifestDescriptor
(line 222).
We do actually test this line, so it does not need a comment justifying missing test coverage.
Taken over from #2567 but: