-
Notifications
You must be signed in to change notification settings - Fork 275
Make internal/ociwclayer a public API: pkg/ociwclayer, with Context for cancellation #916
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
anmaxvl
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.
seems reasonable. what do you guys think, @microsoft/containerplat ?
|
This seems fine to me. internal/ociwclayer hadn't changed in two years so the original intention of possibly iterating on it doesn't seem as relevant anymore. |
|
@TBBle - I'm not up on my latest golang best practices by why not in |
|
Sorry, I must have missed a notification from GitHub. >_< It's not in
So no good reason. Moving it would be trivial code-wise, but there's more work in the decision than the code. And naming is one of the two hardest problems in computer science. |
dcantah
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. Gonna hold off on merging until after the holidays so we can get some more opinions
|
@TBBle - So IMO there are legacy parts of this repo that are unfortunately public API we cannot undo. Namely the root go package for Docker. Given we have all learned and evolved over time with golang the best practice is to use the And yes LOL, naming and componentization. Re-use, Re-use, Re-ugh. Just copy it... |
|
I agree, and am happy to (trivially) move the APIs to So perhaps We could also add bounces for the existing (non-deprecated) APIs in the root layers.go to Note: |
Yea that should honestly be in pkg, I was just going with what we did for the hcn package. Hcn should ideally be in pkg also but that would be a little more disruptive.. |
|
I'm not asking for anything other than the ociwclayer to be in pkg since we are just now moving it. The others cant be moved because that would be breaking changes for people unfortunately. |
39dd909 to
69e25de
Compare
|
I wasn't thinking of moving other things for this PR, or in fact moving them at all. I was more thinking about the future of pkg/ociwclayer, and whether that's a good name, or if in fact these functions should be SemVer 0.8 says there's no promise of API compatibility, so deprecating and getting rid of top-level APIs is feasible, particularly if they're just API moves, since the consumers can just change the API location as part of bumping their consumed version of hcsshim. Anyway, I've repushed as pkg/ociwclayer for now, simply because it was easy, and I'm not seeing any particular interest apart from mine in renaming them. Given hcsshim is only v0.8, I'd rather have this API published and consumed in containerd and Docker, and worry about renaming it later, than have this stuck as duplicated code pending higher-level future-looking decision making. |
|
For example, it might make sense for the existing APIs in layer.go (except the deprecated ones) to be recreated in pkg/wclayer, but using the It'd also make them very similar to the computestorage APIs, where matching APIs exist, which might be helpful for migration as downstream users drop RS1 support. |
|
@TBBle - 100%. I'll let you work that out with the maintainers though to see if they are good with such a change. But I agree moving these as well as adding context's would be a huge improvement with minimal work to update Docker. |
This is to support callers cancelling these operations, or setting a deadline. Based on the same behaviour seen in the containerd implementations of these same functions. Signed-off-by: Paul "TBBle" Hampson <[email protected]>
69e25de to
0693eb0
Compare
|
@dcantah - Can we merge this? |
|
Overall this change looks good to me especially because it will remove some duplicate code from containerd & moby. However, I think the functions should be named a little differently. For two reasons:
I feel we can have names like |
|
Should we have a |
|
Yeah, I think having an enum would be a good idea but it won't make sense to add that enum now when rest of the code for cim layers is not merged. Maybe we can just keep the names of these functions as |
|
I definitely like the Would they be distinguished by the package, rather than the function name? Are there likely to be type-agnostic APIs, or will the caller always know, and if so, would they be dealing with them in separate code-paths, or will it be basically the same code-path with a local enum value being passed into each call? I've gone ahead and applied the Unrelatedly, I observe that |
This (re-)introduces ImportLayerFromTar and ExportLayerToTar into pkg/ociwclayer. Before microsoft#173, these APIS were exposed from oci/wclayer as ImportLayer and ExportLayer, but those names are too generic and already overloaded for similar but different meanings in this project. See eb0cc25 Signed-off-by: Paul "TBBle" Hampson <[email protected]>
0693eb0 to
9bb70a3
Compare
|
@TBBle - I like the name change. For the context do they really do anything? Its not like we cancel mid write or anything so is it actually likely the context would be canceled before we start the write? I'm 100% in favor of contexts I'm just wondering if we need to make them work throughout the internal methods is all |
|
The contexts came from the containerd version of this code. I'm not sure if these particular contexts can be cancelled mid-stream, but I assume they were added for a reason. I can try and track down later (when I have the code handy) if they are ever usefully cancelled, or if there was another rationale for introducing It would be more useful if the cancellation could also interrupt the |
|
I had a look, and it seems to me that a cancel can be generated from a containerd client, and I suspect So I'd leave the context there for now. I noticed the |
|
@TBBle - Works for me. At a minimum its nice because it adds the proper public api to have the context in the signature. We can always make the contexts actually work later :) |
ambarve
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. I will hold off for a few more hours if anyone has any more concerns otherwise I will merge this PR so that other PRs in containerd can be rebased on top of this.
Related work items: microsoft#173, microsoft#839, microsoft#856, microsoft#877, microsoft#881, microsoft#886, microsoft#887, microsoft#888, microsoft#889, microsoft#890, microsoft#893, microsoft#894, microsoft#896, microsoft#899, microsoft#900, microsoft#902, microsoft#904, microsoft#905, microsoft#906, microsoft#907, microsoft#908, microsoft#910, microsoft#912, microsoft#913, microsoft#914, microsoft#916, microsoft#918, microsoft#923, microsoft#925, microsoft#926, microsoft#928, microsoft#929, microsoft#932, microsoft#933, microsoft#934, microsoft#938, microsoft#939, microsoft#942, microsoft#943, microsoft#945, microsoft#946, microsoft#947, microsoft#949, microsoft#951, microsoft#952, microsoft#954
Before #173, this was exposed as oci/wclayer, but there are already a few things named 'wclayer' in this project, and they all mean different things.
The intended use-case is to remove duplication of these APIs in containerd, see containerd/containerd#4399 and particularly containerd/containerd#4415 (comment).
Holding the code up side-by-side suggests that this would also be a drop-in replacement for the nigh-identical functions in moby/moby too.
I picked the name as dumbly as possible, to allow room for bikeshedding. I'm happy to call the API something else, e.g.
pkg/wclayeroroci/wclayer, or even to implementImportLayer/ExportLayerbounce functions at the top level, as is done for other layer-manipulation APIs, e.g.,ActivateLayer.