-
Notifications
You must be signed in to change notification settings - Fork 395
OCI: add a sharedBlobDir mode #369
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
Conversation
|
Looks fine to me actually 🤔 |
mtrmac
left a comment
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.
Same; having this as an opt-in feature does sound useful, especially if the feature is in the spec already.
oci/layout/oci_dest.go
Outdated
| // If stream.Read() at any time, ESPECIALLY at end of input, returns an error, PutBlob MUST 1) fail, and 2) delete any data stored so far. | ||
| func (d *ociImageDestination) PutBlob(stream io.Reader, inputInfo types.BlobInfo) (types.BlobInfo, error) { | ||
| // This should have been handled during newImageDestination, but just in case | ||
| if err := ensureDirectoryExists(d.ref.dir); err != nil { |
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.
If newImageDestination always creates it, I’d prefer dropping the redundant code. Unless there is some special reason why creating this directory again is actually needed?
oci/layout/oci_dest.go
Outdated
| if err := ensureDirectoryExists(d.ref.dir); err != nil { | ||
| return nil, err | ||
| } | ||
| // https: //github.com/opencontainers/image-spec/blame/7c889fafd04a893f5c5f50b7ab9963d5d64e5242/image-layout.md#L19 |
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.
Extra space after https:. (Preferably, quote that single sentence in the comment as well, to save future readers’ time.)
oci/layout/oci_dest.go
Outdated
| }, | ||
| } | ||
| return &ociImageDestination{ref: ref, index: index}, nil | ||
| d := &ociImageDestination{ref: ref, index: index, sharedBlobDir: ctx.OCISharedBlobDirPath} |
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.
ctx may be nil; it might be easier to pass the *types.SystemContext all the way through to blobPath.
let's add some tests if you could and I think we're both good with this. |
If supplied, this will be used instead of the `blobs` subdirectory within OCI image layouts (which, per the OCI spec, may be empty), when getting or putting blobs. Signed-off-by: Jonathan Boulle <[email protected]>
|
test added but lmk any others you'd like to see |
|
@mtrmac PTAL |
| dirRef, ok := ref.(ociReference) | ||
| require.True(t, ok) | ||
| blobPath, err := dirRef.blobPath(blobDigest) | ||
| blobPath, err := dirRef.blobPath(blobDigest, "") |
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.
Would it be possible to create a test that uses a sharedblobdir?
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.
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.
Oh Jeez Louise, ignore me. Spot on @runcom, I don't know how I managed to miss that. Obviously time to dive into my first cup of tea for the day.
Straight up LGTM.
TomSweeneyRedHat
left a comment
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.
LGTM, one small question for consideration that's not a holder for this PR.
|
Thanks! |
This is a POC/RFC for allowing users to specify an external blob directory for OCI image layout sources and destinations. The OCI image spec stipulates that image layouts must have a
blobssubdirectory, but that it may be empty and implementations may fetch blobs from other sources)For our use case, we're forced to use a Docker V2 registry as a canonical store but prefer to use OCI when building and manipulating images locally. So a typical workflow involves a
skopeo copy docker://image oci:image;umoci unpack;umoci repack;skopeo copy oci:image docker://sequence. Since we have various shared layers we want to improve the performance of the copies as much as possible by sharing blobs, but this isn't possible with the current implementation because blobs are always stored within each independent layout.Here's an example of this in action in conjunction with the corresponding umoci change (see https://github.com/openSUSE/umoci/pull/190) and a small skopeo patch (https://github.com/nstack/skopeo/commit/1854cbea233a234fe0dfb72bf97de25405dcb853):
@runcom @mtrmac would love to have some feedback on whether you would take something like this upstream. It's pretty critical for our performance requirements so we might end up maintaining a branch if not, but it would be great if there's some path we can agree on.
Also cc @cyphar