-
Notifications
You must be signed in to change notification settings - Fork 82
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
image/cas: Add a generic CAS interface #40
base: master
Are you sure you want to change the base?
Conversation
ae2075b
to
23d8fb7
Compare
Great job! IMO, we should add
This is needed for GC in the future. |
And more, I'd like to add
|
On Thu, Nov 17, 2016 at 07:49:24PM -0800, Ye Yin wrote:
Listing is expensive, and I'd rather have GC be an opaque function |
On Thu, Nov 17, 2016 at 08:25:25PM -0800, Ye Yin wrote:
Is this for “I want to put this blob, whose hash I already know, but |
Yeah, exactly:) |
IMO, |
On Thu, Nov 17, 2016 at 10:46:44PM -0800, Ye Yin wrote:
Listing all references is a necessary evil ;). To collect statistics,
For a small, local, directory-backed CAS engine, blob-list performance And again, the CAS API I'm proposing here covers all the use-cases we |
@wking I'm reading it but not debug yet. Can we use targetName := fmt.Sprintf("./blobs/%s/%s", algorithm, hash)
if header.Name == targetName{
} Some variables in |
On Fri, Nov 18, 2016 at 12:20:55AM -0800, xiekeyang wrote:
I've avoided going with the image-spec Descriptor because while size
In a later #5 commit I add blobPath 1 and refPath 2 helpers to |
Good! |
I think CAS engine interface is great, but I'm not sure that command |
On Fri, Nov 18, 2016 at 03:34:16AM -0800, xiekeyang wrote:
Is that “yes, squash those into this commit”? Or is it “ah, then this |
Sorry, I mean could you please squash those of |
On Fri, Nov 18, 2016 at 03:40:35AM -0800, xiekeyang wrote:
As #5 continues, oci-cas fills in to cover the rest of the interface
“Really need” is hard to put a finger on. None of our Go code shells |
23d8fb7
to
fbae6d9
Compare
On Fri, Nov 18, 2016 at 03:57:19AM -0800, xiekeyang wrote:
blobPath shifted in with 23d8fb7 → fbae6d9. The ref interface is in a |
In general I agree this PR. cc @stevvooe, WDYT? |
@xiekeyang I don't think this is the right model. It doesn't have a transaction interface for verifying and setting blobs. Half of the interface is useless for the application of tar files and I am not sure what problems this solves for image-tools. For this to be useful, we'd have to refactor the entire thing. As I said when this PR was in image, please use the docker/distribution repo, and the myriad other Go CAS projects, to inform the API. |
On Wed, Nov 30, 2016 at 03:21:10PM -0800, Stephen Day wrote:
It doesn't have a transaction interface for verifying and setting
blobs.
What sort of interface are you looking for? Setting blobs seems like
it would be covered by Engine.Put [1], and you don't need a
transactional *interface* for a CAS engine (although you do want a
transactional *implementation*).
Half of the interface is useless for the application of tar files…
Which half? I can split Engine into CASReader and CASWriter or some
such if that would make the tar backing more appealing.
… and I am not sure what problems this solves for image-tools.
It abstracts away the details of the CAS engine so we don't need to
bake it in (like we currently do, including walker-based lookup for
directory-backed CAS [2,3]!).
For this to be useful, we'd have to refactor the entire thing.
I'm happy to refactor. I've looked at the docker/distribution and
camlistore interfaces [4], and this is where I ended up. But if you'd
like the interface methods modified, let me know what you'd like
changed and why.
[1]: https://github.com/opencontainers/image-tools/pull/40/files#diff-a372a96ac413817b9f8f567e310b60bcR27
[2]: https://github.com/opencontainers/image-tools/blob/421458f7e467ac86175408693a07da6d29817bf7/image/walker.go#L90-L97
[3]: https://github.com/opencontainers/image-tools/blob/421458f7e467ac86175408693a07da6d29817bf7/image/image.go#L28-L32
[4]: opencontainers/image-spec#159 (comment)
|
What's the progress on this? I could really use this right about now. |
@PointMicro This approach has some major design problems. What are you trying to do exactly? Maybe I can point your towards something useful. |
fbae6d9
to
a44de0d
Compare
On Wed, Feb 15, 2017 at 07:42:08PM -0800, Stephen Day wrote:
This approach has some _major_ design problems.
|
a44de0d
to
ccab818
Compare
And I am not going to sit down and reiterate them again. I have provided several examples, there are multiple projects to draw from (umoci, containerd, docker/distribution, camlistore, etc.) that all have addressed these issues. Furthermore, it treats tar archives as a random access storage medium and makes multiple poor assumptions. |
On Thu, Feb 16, 2017 at 02:57:16PM -0800, Stephen Day wrote:
… there are multiple projects to draw from (umoci…
umoci has addressed tar access by erroring out when pointed at a
tar-backed image-layout [1]. It's CAS Get interface [2] is identical
to mine [3].
… containerd,…
I see no image-layout support in containerd:
containerd $ git grep blobs v0.2.5
v0.2.5:vendor/src/golang.org/x/sys/unix/syscall_linux.go: // to be uninterpreted fixed-size binary blobs--but
v0.2.5:vendor/src/golang.org/x/sys/unix/syscall_solaris.go: // to be uninterpreted fixed-size binary blobs -- but
Very recently (with docker/containerd#452) you gave containerd a
fetcher which adds a hints argument and makes the ID more generic [4],
but is otherwise identical to my interface.
… docker/distribution, …
distribution has the same interface, except that it returns
ReadSeekClosers instead of my ReadClosers [5]. It also supports a
getter that returns a byte array [6], but that's clearly the
convenient special case because it would be very expensive for large
blobs.
I couldn't find any image-layout support in docker/distribution (which
isn't surprising, since it's basically an alternative store
format/service).
… camlistore,…
camlistore seems to dispense with the Context, and it also returns a
size (in addition to the ReadCloser and error) [7].
Furthermore, it treats tar archives as a random access storage
medium and makes multiple poor assumptions.
So as far as I can tell, I'm doing the same thing as everyone else,
unless you're really missing camlistore's returned size or
containerd's hints.
Or are you fine with my API, and just concerned with the
implementation? I don't see anyone else implementing tar-backed
image-layout support, but please point me at them if I've missed them.
[1]: https://github.com/openSUSE/umoci/blob/v0.1.0/oci/cas/cas.go#L133-L137
[2]: https://github.com/openSUSE/umoci/blob/v0.1.0/oci/cas/cas.go#L89-L91
[3]: https://github.com/opencontainers/image-tools/pull/40/files#diff-a372a96ac413817b9f8f567e310b60bcR33
[4]: https://github.com/docker/containerd/pull/452/files#diff-aba5bb73e69236c8e862c4a985731536R9
[5]: https://github.com/docker/distribution/blob/v2.6.0/blobs.go#L147-L150
[6]: https://github.com/docker/distribution/blob/v2.6.0/blobs.go#L144-L145
[7]: https://github.com/camlistore/camlistore/blob/dc66fe281ecd848a12bc102ffdf491033b0454fd/pkg/client/get.go#L47
|
@wking The problem here is that you are too focused on "image layout" which is a minor part of the image format.
No. You're API is naive, racy and memory intensive.
Exactly. This makes no sense. The only way to do this with a CAS store would be to have a transactional addition of blobs. Effectively, you have a transaction for each blob addition, then a transaction that creates the tar file. |
ccab818
to
38fe4fc
Compare
On Thu, Feb 16, 2017 at 03:34:29PM -0800, Stephen Day wrote:
> Or are you fine with my API, and just concerned with the
> implementation?
No. You're API is naive, racy and memory intensive.
The Get API? It's basically the same as everyone else's [1].
The only way to do this with a CAS store would be to have a
transactional addition of blobs.
There is no blob addition going on in this PR. I've just pushed
ccab818 → 5df5883 which drops the Put and Delete stubs in case they
were what you were pushing back against.
[1]: #40 (comment)
|
38fe4fc
to
5df5883
Compare
5df5883
to
fe6a35b
Compare
I've just pushed 5df5883 → fe6a35b rebasing this work onto master, since @q384566678 expressed renewed interest in #5, of which this PR is the next component. I didn't make any changes to |
fe6a35b
to
cda19fe
Compare
And I've just pushed fe6a35b → cda19fe fixing some |
And implement that interface for tarballs based on the specs image-layout. I plan on adding other backends and methods later, but this is enough for a proof of concept getter. Also add a new 'oci-image-tool cas get ...' subcommand so folks can access the new read functionality from the command line. In a subsequent commit, I'll replace the image/walker.go functionality with this new API. The Context interface follows the pattern recommended in [1], allowing callers to cancel long running actions (e.g. push/pull over the network for engine implementations that communicate with a remote store). Passing a Context instance along to NewEngine gives us a way to cancel engine initialization which happens to take too long. That's unlikely to happen for NewTarEngine, but it's easy enough to pass it on down just in case. blobPath's separator argument will allow us to use string(os.PathSeparator)) once we add directory support. [1]: https://blog.golang.org/context Signed-off-by: W. Trevor King <[email protected]>
cda19fe
to
0c9e84e
Compare
I've pushed cda19fe → 0c9e84e fixing a missing error check. |
And implement that interface for tarballs based on the specs image-layout.
Also add a new
oci-cas
command so folks can access the new read functionality from the command line.The
Context
interface follows the pattern recommended here, allowing callers to cancel long running actions (e.g. push/pull over the network for engine implementations that communicate with a remote store).This is the current first commit in #5, to see if nibbling away at that PR one commit at a time makes review any easier. I have a directory-based backend in #5 if you want to see what that looks like. In another commit in #5 I replace the
image/walker.go
functionality with this new API.