8000 support for storage for rootless containers by giuseppe · Pull Request #936 · containers/podman · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

support for storage for rootless containers #936

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

Closed
wants to merge 7 commits into from

Conversation

giuseppe
Copy link
Member

continuation of: #871

@giuseppe
Copy link
Member Author

tests are probably failing for opencontainers/runc#1816

@giuseppe giuseppe force-pushed the rootless-storage branch 9 times, most recently from d56bed4 to ad2b673 Compare June 14, 2018 13:09
@giuseppe
Copy link
Member Author

@rhatdan the patch for runc got merged (b222ea4469dd5e304f3f6cf7a2482860285639a2), could we get an updated build?

@rh-atomic-bot
Copy link
Collaborator

☔ The latest upstream changes (presumably 4b4de5d) made this pull request unmergeable. Please resolve the merge conflicts.

@giuseppe giuseppe force-pushed the rootless-storage branch 2 times, most recently from 19083c3 to d67feb3 Compare June 15, 2018 14:13
@rh-atomic-bot
Copy link
Collaborator

☔ The latest upstream changes (presumably 16ea659) made this pull request unmergeable. Please resolve the merge conflicts.

@giuseppe giuseppe force-pushed the rootless-storage branch 5 times, most recently from 9d8f9cf to a8b8614 Compare June 20, 2018 13:25
@giuseppe
Copy link
Member Author

This is currently ready for review. The updated runc is used only on Travis right now (and tests are happy there). Everywhere else, we need a newer runc

@rhatdan
Copy link
Member
rhatdan commented Jun 20, 2018

LGTM
@mheon @nalind @mtrmac @baude @umohnani8 @wking PTAL

func BecomeRootInUserNS() (bool, error) {
runtime.LockOSThread()

if os.Getuid() == 0 || os.Getenv("_LIBPOD_USERNS_CONFIGURED") != "" {
Copy link
Member

Choose a reason for hiding this comment

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

Should this happen before LockOSThread()? Seems like it doesn't need to be guaranteed to run in a single thread, and this should be the typical case, so we can save some time by not calling LockOSThread() in this case

Copy link
Member Author

Choose a reason for hiding this comment

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

changed

@wking
Copy link
Contributor
wking commented Jun 20, 2018

The updated runc is used only on Travis right now (and tests are happy there). Everywhere else, we need a newer runc

Having different runc versions in different places makes me jumpy. Is there something that's blocking us bumping to a single new version of runc in all of our locations (Dockerfile, vendor.conf, other places?)?

The global user namespace approach you have here is just mapping a single user and group to 0 (e.g. you're not using subuid(5) to map multiple UIDs). Is that really sufficient for unpacking images? I'd expect at least some images to require more than one user or group ID. A more robust fix might be possible if we handled this with shiftfs, or if containers/storage grew an API for specifying ID translations (like GNU tar's --owner-map, etc.), or if it could use something like umoci's unpriv package. And regardless of how we handle ID mapping, there's probably no way an unprivileged user will be able to usefully unpack an image that contains device nodes, etc.

@giuseppe
Copy link
Member Author

@wking, there are multiple users mapped when the user has additional uids/gids defined in /etc/subuid and /etc/subgid, this is done from tryMappingTool.
The Go Runtime has support for launching a process in a new userNS but it supports only one mapping as it writes directly to /proc/PID/[gu]id_map, if the mapping is not specified the process is left unconfigured. That is why I needed the C part to create a new process and configure the multiple mappings with newuidmap/newgidmap.

I think we are not vendoring runc but using the version from the host, that is why we are dealing with different versions on different systems :-(

@giuseppe
Copy link
Member Author

I've kept the implementation in a new pkg so that it can be more easily re-used. @nalind could this be useful for Buildah?

giuseppe added 5 commits June 26, 2018 19:11
When running podman as non root user always create an userNS and let
the OCI runtime use it.

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
Additional groups are not allowed in an userNS.

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
If the file exists, use it to read the configuration.

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
if dataDir != "" {
opts.GraphRoot = filepath.Join(dataDir, "containers", "storage")
} else {
home := os.Getenv("HOME")
if home == "" {
return opts, fmt.Errorf("HOME not specified")
}
opts.GraphRoot = filepath.Join(home, ".containers", "storage")
opts.GraphRoot = filepath.Join(home, ".local", "share", "containers", "storage")
Copy link
Contributor

Choose a reason for hiding this comment

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

The spec has:

If $XDG_DATA_HOME is either not set or empty, a default equal to $HOME/.local/share should be used.

A simpler implementation of that would be:

dataDir := os.Getenv("XDG_DATA_HOME")
if dataDir == "" {
  home := os.Getenv("HOME")
  if home == "" {
    return opts, fmt.Errorf("neither XDG_DATA_HOME nor HOME was set non-empty")
  }
  dataDir = filepath.Join(home, ".local", "share")
}
// then append to dataDir to construct GraphRoot

This sort of generic XDG support is something that you can get from XDG libraries as well. For example, here.

Once you have dataDir populated, I think we should be using a single containers-storage instead of two directories. Again from the spec:

Other specifications may reference this specification by specifying the location of a data file as $XDG_DATA_DIRS/subdir/filename. This implies that:

  • Such file should be installed to $datadir/subdir/filename with $datadir defaulting to /usr/share.

  • A user specific version of the data file may be created in $XDG_DATA_HOME/subdir/filename, taking into account the default value for $XDG_DATA_HOME if $XDG_DATA_HOME is not set.

  • Lookups of the data file should search for ./subdir/filename relative to all base directories specified by $XDG_DATA_HOME and $XDG_DATA_DIRS. If an environment variable is either not set or empty, its default value as defined by this specification should be used instead.

containers-storage would be the subdir specific to the containers/storage library. I don't see a need to group all of the container data under a containers/ directory, because it makes managing that shared directory more complicated. dataDir will still be a shared directory potentially consumed by several packages, so sharing directories is obviously something that can work, but I think containers/storage is unnecessarily deep.

Finally, the chained-lookup point at the end of the XDG quote above is something that we'd have to approach by patching containers/storage itself. If we end up patching containers/storage to support the XDG spec (which seems useful to me), we probably won't need any code here. We can just leave GraphRoot empty, and let containers/storage pull it in from the XDG variables and its internal subdir/filename, etc. defaults.

Copy link
Member

Choose a reason for hiding this comment

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

Lets open a PR for containers/storage and see what @nalind thinks, but for now, we can handle this here, and just get this PR merged, when it is ready.

Copy link
Member Author

Choose a reason for hiding this comment

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

I am in favour of keeping the two levels containers/storage as we also have containers/atomic

Copy link
Contributor

Choose a reason for hiding this comment

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

... but for now, we can handle this here, and just get this PR merged, when it is ready.

The dataDir unification in my earlier comment (which DRYs up the current two lines with "containers", "storage") can happen in this PR without blocking on upstream containers/storage work.

@rhatdan
Copy link
Member
rhatdan commented Jun 26, 2018

Yes lets keep them separate directories.

giuseppe added 2 commits June 27, 2018 14:51
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
@giuseppe
Copy link
Member Author

I addressed all the comments above, is there anything more blocking it?

@mheon
Copy link
Member
mheon commented Jun 27, 2018

Now that #1001 is in, I have no more objections. LGTM.

@rhatdan
< 9E88 summary data-view-component="true" class="timeline-comment-action Link--secondary Button--link Button--medium Button"> Copy link
Member
rhatdan commented Jun 27, 2018

@rh-atomic-bot r+

@rh-atomic-bot
Copy link
Collaborator

📌 Commit 2bc4eb0 has been approved by rhatdan

@rh-atomic-bot
Copy link
Collaborator

⌛ Testing commit 2bc4eb0 with merge 19f5a50...

rh-atomic-bot pushed a commit that referenced this pull request Jun 27, 2018
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>

Closes: #936
Approved by: rhatdan
rh-atomic-bot pushed a commit that referenced this pull request Jun 27, 2018
Additional groups are not allowed in an userNS.

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>

Closes: #936
Approved by: rhatdan
rh-atomic-bot pushed a commit that referenced this pull request Jun 27, 2018
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>

Closes: #936
Approved by: rhatdan
rh-atomic-bot pushed a commit that referenced this pull request Jun 27, 2018
If the file exists, use it to read the configuration.

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>

Closes: #936
Approved by: rhatdan
rh-atomic-bot pushed a commit that referenced this pull request Jun 27, 2018
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>

Closes: #936
Approved by: rhatdan
rh-atomic-bot pushed a commit that referenced this pull request Jun 27, 2018
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>

Closes: #936
Approved by: rhatdan
@rh-atomic-bot
Copy link
Collaborator

☀️ Test successful - status-papr
Approved by: rhatdan
Pushing 19f5a50 to master...

@lukasheinrich
Copy link

thanks a lot @giuseppe !

@giuseppe giuseppe deleted the rootless-storage branch February 26, 2019 10:32
@github-actions github-actions bot added the locked - please file new issue/PR Assist humans wanting to comment on an old issue or PR with locked comments. label Sep 27, 2023
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 27, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
locked - please file new issue/PR Assist humans wanting to comment on an old issue or PR with locked comments.
Projects
None yet
Development

Successfully merging this pull request may close thes 4094 e issues.

8 participants
0