Implement Windows snapshotter and differ#1969
Conversation
|
I'm creating this new PR as a replacement for #1613 because so much has changed since then that a new PR makes sense to clean up the noise. |
There was a problem hiding this comment.
Is something going to be done after this defer at some point in the future? Right now it is not doing anything
There was a problem hiding this comment.
I think I had something after the defer in a previous version. Removing it.
There was a problem hiding this comment.
Isn't using JSON here still problematic since the comma won't be escaped? What is the main motivation behind encoding with JSON
There was a problem hiding this comment.
The intent was just to pack the parent layer paths in a single mount in a way that would be able to get back the same list when mounting. JSON was used because it would still be readable, but any way to Marshal should be ok, as long as all characters in the path are OK.
I don't think comma is a problem, as on Windows this is not actually used by a mount syscall similar to Unix, but rather is parsed by containerd and passed as extra info to HCS to assemble the layer. I might be missing somewhere where this struct is serialized though.
There was a problem hiding this comment.
Fair enough, the serialization from go array should only go to protobuf types and back. We have a ctr command which gives the mount command, but we can just have it output something else on Windows since a Unix mount command doesn't make sense here.
There was a problem hiding this comment.
What is the expense of calculating this on Windows? Full walk?
There was a problem hiding this comment.
The size of the layer will come for free (ish) when I add the followup PR which implements Diff and redo Commit to build an actual layer that works for both process and hyperv isolation modes by diffing the current layer from the parent, and creating a new RO layer.
The size in usage is the one where I still need to work out what to do, and if we even have permission to do a full walk in all cases.
There was a problem hiding this comment.
What does a rename do on Windows?
There was a problem hiding this comment.
Just changes the name, doesn't do any actual data moves (very cheap). The intent is to have a short transaction, and do the heavy lifting outside the transaction.
There was a problem hiding this comment.
Also what is the cost of this destroy? I have some in progress work to make this asynchronous, it would probably be good to do here too
see #1833
There was a problem hiding this comment.
As I alluded to in the above comment, this is the costly part of remove. Async would be really great.
There was a problem hiding this comment.
I am curious why the parentPath gets passed in twice, once as an argument and again as the first element of the path array?
There was a problem hiding this comment.
The function is just a direct map to the platform function, and the argument is not actually used in the platform currently, but can't be changed, as changing platform function signatures without adding a new name is not fun for anyone.
So just legacy.. If I get a chance, I'd like to fix the hcsshim function to not require it, but that requires a breaking change.
There was a problem hiding this comment.
Yes, the default quota is 20GB (since it needs to be stored in a VHD, it cannot be unbounded). It can be expanded to larger than 20GB, but cannot be shrunk.
|
I am impressed with how straightforward the snapshotter is 😄 |
mlaventure
left a comment
There was a problem hiding this comment.
This is 😍!
I unfortunately don't have the capacity to test on windows anymore, but nothing wrong jumped out after my first pass through, just nits.
So glad to see this going forward :)
There was a problem hiding this comment.
Do you want to have those as metrics?
There was a problem hiding this comment.
I don't think Windows currently supports metrics in containerd. I don't think these are needed as metrics, but it is something I would love to get working on Windows!
There was a problem hiding this comment.
Using prometheus, it should just be a matter of defining and registering the metrics :)
There was a problem hiding this comment.
from memory this look like duplicated code from other places in the repo.
There was a problem hiding this comment.
Yeah, there's a chunk of shared code here. Is there a good place to store code shared between packages in containerd that might not have use outside containerd? This could be something like func IsCompressedTar(desc ocispec.Descriptor) (bool, error), but I don't see a good place to have that function exist.
There was a problem hiding this comment.
Maybe somewhere in the image package?
There was a problem hiding this comment.
nit: no need for the () version
There was a problem hiding this comment.
nit: this is only used in snashots/windows/widnows.go it could just be in that file.
There was a problem hiding this comment.
removed it, as logging the rollback failures is actually not very useful at all (it only fails if the transaction is already committed, at which point we don't care)
There was a problem hiding this comment.
I guess (from reading getFileSystemType()) root[0] is the drive letter. https://golang.org/pkg/path/filepath/#VolumeName would make this more obvious.
There was a problem hiding this comment.
Yep. That is much clearer. Didn't know about that function.
There was a problem hiding this comment.
This if is unnecessary
return info, errThere was a problem hiding this comment.
What's the purpose of tracking commited?
Looking at the implementation of Tx.Rollback I don't think this error is ever relevant. The only error is "transaction was already closed", which I think would only occur if commited == true, so this will never log anything.
Maybe remove the committed, and ignore the error from Rollback() ? Then you can always just defer tx.Rollback(), which seems to be what other implementations are doing.
There was a problem hiding this comment.
Makes sense. For some reason I thought that rollback shouldn't be called after a commit, but I don't know why. Changing this to be similar to other implementations
There was a problem hiding this comment.
Actually, the other snapshotters are doing almost the exact same thing such as https://github.com/containerd/containerd/blob/master/snapshots/overlay/overlay.go#L290 (bool rollback instead of bool committed, but the exact same idea) and https://github.com/containerd/containerd/blob/master/snapshots/overlay/overlay.go#L204 (setting t = nil to abandon the rollback instead of using a bool).
Same thing in naive. Looks like the other snapshotters should also be fixed to just use defer tx.Rollback() regardless to me.
There was a problem hiding this comment.
return errdefs.ErrNotImplemented?
0d0dc71 to
0da3e63
Compare
|
Windows tests are (sortof) passing! The cleanup is failing due to attempting to delete the root folder via |
f3d7691 to
7015486
Compare
Codecov Report
@@ Coverage Diff @@
## master #1969 +/- ##
=======================================
Coverage 45.42% 45.42%
=======================================
Files 96 96
Lines 9427 9427
=======================================
Hits 4282 4282
Misses 4435 4435
Partials 710 710
Continue to review full report at Codecov.
|
|
All current feedback is addressed, and CI is passing. Only item leftover is to move getFileSystemType to Continuity. I think this is OK to do in a followup so it doesn't block this PR. |
There was a problem hiding this comment.
nit: this can be done after m.GetParentPaths() to avoid allocating the memory if not necessary
There was a problem hiding this comment.
Using prometheus, it should just be a matter of defining and registering the metrics :)
There was a problem hiding this comment.
nit: could be a single var block with the above
There was a problem hiding this comment.
nit: would do that first to avoid loading the dll if not needed
80524e1 to
8ed6376
Compare
This implements the Windows snapshotter and diff Apply function. This allows for Windows layers to be created, and layers to be pulled from the hub. Signed-off-by: Darren Stahl <[email protected]>
This changes the Windows runtime to use the snapshotter and differ created layers, and updates the ctr commands to use the snapshotter and differ. Signed-off-by: Darren Stahl <[email protected]>
Signed-off-by: Darren Stahl <[email protected]>
Signed-off-by: Darren Stahl <[email protected]>
Signed-off-by: Darren Stahl <[email protected]>
Signed-off-by: Darren Stahl <[email protected]>
8ed6376 to
95a0b3a
Compare
estesp
left a comment
There was a problem hiding this comment.
I have no ability to test, but have reviewed the code. LGTM
|
Cool! LGTM! A question: |
|
LGTM I took a good look at this yesterday and it is looking nice and simple. |
| @@ -9,15 +16,70 @@ var ( | |||
|
|
|||
| // Mount to the provided target | |||
| func (m *Mount) Mount(target string) error { | |||
There was a problem hiding this comment.
This target is completely unused, but that makes using this function kind of awkward. The concern is that code cannot rely on calling this function to get access to the data through the mount. This could complicate builder use cases which are trying to build off the snapshot pattern. Could this code be unified with the code in windows/hcsshim.go which does mounting to provide the mount at a destination path? Doing the equivalent of a mount + bind mount to achieve this would be fine if that is even possible.
There was a problem hiding this comment.
Agreed it is awkward to not mount at target.
It is not possible to specify the mount location currently, as the layer is mounted as a volume on the host, not at a path on the host. I think it might be possible to mount the resulting volume on the host at a given path, but this would only be delaying solving the same problem again later, as LCOW layers cannot be mounted on the host regardless due to limitations in NTFS. See #1359 for more context on this.
On Windows, it makes much more sense to get the mounted path, rather than provide a path to mount at. I'm not sure if mounting the volume on the host would fix this for WCOW, but I can attempt if we think it is worth fixing it here before we deal with the LCOW situation.
There was a problem hiding this comment.
Let's discuss further later, possibly start to include @tonistiigi in our sync ups
|
LGTM |
|
@jessvalarezo Yes, there are certainly test that need to be enabled on Windows still. I think some of them can already be enabled, but I did not look at all of them yet. From the looks of it, |
This implements the snapshotter and differ for Windows container layers, and enables them for use by ctr run.
It is currently split into two commits, one to implement the snapshotter and differ, and one to start using it in ctr. I can split this into two PRs if it would be helpful.
The snapshotter View method currently creates a new layer, but it should really just use the already created layer and create Mounts to use it. This works fine currently, but is needed for DiffMounts
TODO:
Change snapshotter View to not create a new layer
Enable tests to start using snapshotter and differ
Move getFileSystemType to continuity
A followup PR needs to implement Windows layer Diff, and changes the snapshotter commit to read the changes out of the sandbox layer, and put them in a Read only layer, as the current implementation splits changes to the VHD from those to the on disk layer.
@stevvooe @dmcgowan @crosbymichael @jessvalarezo