Skip to content

Support helpers for label-based userns remapping#4259

Merged
dmcgowan merged 3 commits intocontainerd:masterfrom
estesp:fuse-overlayfs
Jul 6, 2020
Merged

Support helpers for label-based userns remapping#4259
dmcgowan merged 3 commits intocontainerd:masterfrom
estesp:fuse-overlayfs

Conversation

@estesp
Copy link
Copy Markdown
Member

@estesp estesp commented May 15, 2020

Carry #3885

Modified the original implementation to simply have unique helpers for the label-based approach to supporting remapping snapshotters. We don't have any callers of either of these helpers in containerd today.

Added commit: "Provide remapping helpers to add labels used by any supporting
snapshotter to handle user namespace filesystem remapping. Currently
supported by the fuse-overlayfs snapshotter, and others can use this
information as well."

@estesp
Copy link
Copy Markdown
Member Author

estesp commented May 15, 2020

ping @AkihiroSuda @dmcgowan : this is my attempt to take the comments from #3885 and modify the code to move away from special remapper flags. Given there are no callers in containerd, it seems up to custom clients to determine how to utilize the remapping helpers anyway.

@estesp estesp force-pushed the fuse-overlayfs branch 2 times, most recently from 8b73ac5 to 9ffbc69 Compare May 16, 2020 02:43
Copy link
Copy Markdown
Member

@AkihiroSuda AkihiroSuda left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, but I think function names should not contain "fuse".

Also, can we have ctr flag for this?

Comment thread container_opts_unix.go Outdated
@estesp estesp changed the title Support helpers for FUSE-overlayfs userns remapping Support helpers for label-based userns remapping May 18, 2020
Comment thread container_opts_unix.go Outdated
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How come this is mapping everything after uid?
Can we scope this down?
Also just to note, this is specifically a root remap.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

First, this isn't anything to do with the actual user namespace mapping; that's handled via the OCI spec and related options. Our filesystem "shifting" (to complement the userns mappings provided to the spec) was patterned after a more simplistic monotonic UID/GID shift (as if your /etc/sub{u,g}id files had the most default setup found in most distros--a single entry, starting at 100,000--as an example--and mapping the next 64k). You can see incrementFS in this same file showing that same simple model implementation.

This new function is to support letting a snapshotter handle the filesystem ownership mapping via non-brute force/chown methods (e.g. FUSE overlay support, experimental shiftfs support in Ubuntu, etc.), and so we are starting with the same simple idea of providing the base, offset, and a static 64k block (again, in line with defaults on most distros). I think @AkihiroSuda mentioned that future implementations will need to support more interesting use cases (e.g. just like uid maps can be non-contiguous and different sizes than the default 64k). How the actual snapshotter impl. uses the data in the label is really up to the snapshotter.

@dmcgowan
Copy link
Copy Markdown
Member

dmcgowan commented May 18, 2020

I stick with my original recommendation in
https://github.com/containerd/containerd/pull/3885/files#r363429777. To just provide the function as a snapshot option rather than a new container option. A snapshot option is the more composable type as it can be used with other snapshot options. The original remapper could not do this since it had to own the snapshot creation.

@estesp
Copy link
Copy Markdown
Member Author

estesp commented May 19, 2020

@dmcgowan clearly I should have asked since this implementation was my exact following of your comment "provide a helper which can set the labels and just use WithNewSnapshot" 😹 But I see your distinction now on the kind of helper you are talking about.

@estesp estesp force-pushed the fuse-overlayfs branch 2 times, most recently from 1e1955c to c919171 Compare June 5, 2020 20:23
@containerd containerd deleted a comment from theopenlab-ci Bot Jun 5, 2020
@containerd containerd deleted a comment from theopenlab-ci Bot Jun 5, 2020
@containerd containerd deleted a comment from theopenlab-ci Bot Jun 5, 2020
@containerd containerd deleted a comment from theopenlab-ci Bot Jun 5, 2020
@containerd containerd deleted a comment from theopenlab-ci Bot Jun 5, 2020
@estesp
Copy link
Copy Markdown
Member Author

estesp commented Jun 5, 2020

I think I have this correctly now @dmcgowan. Per @AkihiroSuda's comment I'm going to add another commit with a ctr implementation that uses the labels if the snapshotter is the fuse-overlay driver, but defaults back to the standard chown remapping helpers if not.

Copy link
Copy Markdown
Member

@dmcgowan dmcgowan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@AkihiroSuda
Copy link
Copy Markdown
Member

Can we have either ctr flag or an integration test? (having ctr would be probably easier)

@estesp
Copy link
Copy Markdown
Member Author

estesp commented Jun 26, 2020

@AkihiroSuda yes, working on it today (a ctr flag)

@estesp estesp force-pushed the fuse-overlayfs branch 2 times, most recently from 4f8ad6a to f1b1f96 Compare June 26, 2020 17:07
@containerd containerd deleted a comment from theopenlab-ci Bot Jun 26, 2020
Provide a snapshotter opt to add labels used by any supporting
snapshotter to handle user namespace filesystem remapping. Currently
supported by the fuse-overlayfs snapshotter, and others can use this
information as well.

Signed-off-by: Phil Estes <[email protected]>
@containerd containerd deleted a comment from theopenlab-ci Bot Jun 26, 2020
@containerd containerd deleted a comment from theopenlab-ci Bot Jun 26, 2020
@estesp
Copy link
Copy Markdown
Member Author

estesp commented Jun 26, 2020

@AkihiroSuda interestingly I started this branch from the PR I carried, which left me with the impression that there wasn't already support for running a container with UID/GID maps, but that PR (from the same contributor) was merged soon after this original PR was created.

Rebasing on master, I now have the uid/gid maps on ctr run, so all I've done in this PR is match on the fuse-overlayfs snapshotter name and use the labels instead of the WithRemappedSnapshot helper. Let me know if you think this should instead be a specific extra flag.

@AkihiroSuda
Copy link
Copy Markdown
Member

Let me know if you think this should instead be a specific extra flag.

Yes, I prefer the extra flag, thanks

A simple starting point for testing the remapper labels with
fuse-overlayfs snapshotter

Signed-off-by: Phil Estes <[email protected]>
@estesp
Copy link
Copy Markdown
Member Author

estesp commented Jun 29, 2020

@AkihiroSuda done!

@theopenlab-ci
Copy link
Copy Markdown

theopenlab-ci Bot commented Jun 29, 2020

Build succeeded.

}
opts = append(opts,
oci.WithUserNamespace([]specs.LinuxIDMapping{uidMap}, []specs.LinuxIDMapping{gidMap}))
if context.Bool("read-only") {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this remain as an else if?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was aligning the user ns path with the "main" path which has this comment a few lines below: "Even when "read-only" is set, we don't use KindView snapshot here. (#1495)"; this was never applied for the userns path when it was added, but I believe the same problem will exist (runc won't be able to make mount points because of a read only root fs; but is able to remount it ro once that work is completed at the runc level)

Copy link
Copy Markdown
Member

@dmcgowan dmcgowan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants