-
Notifications
You must be signed in to change notification settings - Fork 3.8k
[WIP] Implement Windows snapshotter and differ #1613
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
38400c4 to
9b3b782
Compare
snapshot/windows/windows.go
Outdated
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 s := strings.ToLower(fsType); s != "ntfs" {
return nil, errors.Wrapf(errdefs.ErrInvalidArgument, "%s is on an non-NTFS volume (%s) - only NTFS volumes are supported", root, s)
}
mount/mount_windows.go
Outdated
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.
Question: why single-mount is unimplementable?
If unimplementable, please add a comment to the source code?
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.
I'll add a comment. This is due to the filesystem filter on Windows. When accessing a file in an underlying layer, there needs to be a target in the current layer, so a hardlink is created, pointing to the lower layer file (essentially). This means that without the lower layers, the current layer would be full of dead links. As a result, mounting a single layer would be all but useless, so the only API exposed to mount layers on Windows requires all layers.
snapshot/windows/windows.go
Outdated
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.
Is this constant can be defined in hccshim package?
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 not, can we have it exported to use outside of this package (I've left a comment a bit above asking to add a constant)
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.
Yes, this will be a constant in hcsshim package and not hard coded.
mlaventure
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.
Looks like a promising start! 🎉
client_windows_test.go
Outdated
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 can just remove that function, it does nothing on other platforms either.
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
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.
nit: merge in the var () block below
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. FYI I plan to move some of the responsibility here to hcsshim, so the differ will still be undergoing some largeish changes
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.
nit: s/NewWindowsDiff/It/
also, is that true even unix FS? (e.g. zfs)?
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.
copy paste error. This is expected to only work on NTFS (and is not a generic implementation, but a Windows container specific one)
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.
nit: just a preference, I think a switch construct here would make it easier to read (feel free to ignore if you like it that way 😇)
snapshot/windows/windows.go
Outdated
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.
do we need to call t.Rollback() here? maybe put it in a defer.
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.
I think a Rollback is needed. Other snapshotters have the same function without a rollback (I see a few missing Rollbacks in Naive and Overlay actually). I think we might need to do a pass on all snapshotters.
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.
I'm not sure I like the defer, as some functions have a return t.Commit(), which looks fine, and could easily be introduced again if changed to err = t.Commit(); return err but would not trigger the defer on failure. I'm not sure what the pattern should be. Maybe a defer with an explicit variable such as doNotRollback which must be set on a Commit succeeding?
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.
I think that if the function returned are named, you should be able to rely on this and only rollback if err != nil.
snapshot/windows/windows.go
Outdated
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.
remove?
snapshot/windows/windows.go
Outdated
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.
shouldn't this be done later? Otherwise we're not going to rollback the transaction here.
snapshot/windows/windows.go
Outdated
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.
todo missing?
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.
ID is only needed to get the disk usage. Removed.
snapshot/windows/windows.go
Outdated
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.
return "", errors....
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.
Why is there another fork of the tar package?
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.
I'll get back to you on this. There was something that needed to be forked due to layer implementation on Windows IIRC, but this was done a long time ago
snapshot/windows/windows.go
Outdated
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.
Could you leave the type definition near the New function?
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.
will do
snapshot/windows/windows.go
Outdated
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.
Do we want to upstream this to continuity?
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.
That sounds good to me.
|
@darrenstahlmsft This is a really solid start! The snapshotter model seems to be holding up, although we may need to rethink how the related mounts work. Would it be possible to get the whole structure into a single mount call? |
mount/mount_windows.go
Outdated
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.
Afaics this function doesn't actually mount anything and the actual mount is in https://github.com/containerd/containerd/pull/1613/files#diff-c3cba80ac2b534161f3d1259da272c21R80 and doesn't have really much to do with snapshots as all the inputs come from a spec. This makes the API very inconsistent for anything that calls this function directly instead of just creating a container what internally calls here and atm there isn't a public method for mounting a snapshot.
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.
This does do the mount to host (PrepareLayer mounts the layers), but on Windows, you cannot specify a target location. Instead, the layers are exposed as a VHD mounted on the host. The linked code just retrieves the already mounted path from HCS.
I agree that this function does not do what it says on the box here on Windows. We'll need to work out a way to expose what this really does via a different function, or otherwise make it do what it says. Having target as a parameter to the mount does not really make sense on Windows layer mounting.
4633a57 to
30b412e
Compare
|
Running tests is timing out on Windows waiting for start. I'm not sure why yet. |
|
Pushed an update to address most of the feeback, and rebased Next step: Moving archive logic around into more permanent locations |
Signed-off-by: Darren Stahl <[email protected]>
30b412e to
3d04e90
Compare
This is a work in progress (nearly finished) implementation of snapshotter and differ on Windows and the corresponding changes in ctr and Windows runtime to use the new snapshotter/differ.
Work left to be done is as follows:
cc @mlaventure @dmcgowan @stevvooe @crosbymichael
Signed-off-by: Darren Stahl [email protected]