-
Notifications
You must be signed in to change notification settings - Fork 18.7k
Fix overlay2 storage driver inside a user namespace #35794
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
The overlay2 driver was not setting up the archive.TarOptions field properly like other storage backend routes to "applyTarLayer" functionality. The InUserNS field is populated now for overlay2 using the same query function used by the other storage drivers. Signed-off-by: Phil Estes <estesp@linux.vnet.ibm.com>
Would it be able to add a test to this? |
@estesp can you please add a test case? Also, speaking of other storage drivers, I see that
if options == nil {
options = &archive.TarOptions{}
if rsystem.RunningInUserNS() {
options.InUserNS = true
}
} So, it only sets
So, based on this quick glance, it needs to be fixed as well (and a generic graphdriver test case would help to reveal the bug). The fix would be something like this: diff --git a/daemon/graphdriver/fsdiff.go b/daemon/graphdriver/fsdiff.go
index 533c5a769..5e98d980a 100644
--- a/daemon/graphdriver/fsdiff.go
+++ b/daemon/graphdriver/fsdiff.go
@@ -8,6 +8,7 @@ import (
"github.com/docker/docker/pkg/chrootarchive"
"github.com/docker/docker/pkg/idtools"
"github.com/docker/docker/pkg/ioutils"
+ rsystem "github.com/opencontainers/runc/libcontainer/system"
"github.com/sirupsen/logrus"
)
@@ -142,8 +143,11 @@ func (gdw *NaiveDiffDriver) ApplyDiff(id, parent string, diff io.Reader) (size i
defer driver.Put(id)
layerFs := layerRootFs.Path()
- options := &archive.TarOptions{UIDMaps: gdw.uidMaps,
- GIDMaps: gdw.gidMaps}
+ options := &archive.TarOptions{
+ UIDMaps: gdw.uidMaps,
+ GIDMaps: gdw.gidMaps,
+ InUserNS: rsystem.RunningInUserNS(),
+ }
start := time.Now().UTC()
logrus.Debug("Start untar layer")
if size, err = ApplyUncompressedLayer(layerFs, diff, options); err != nil { |
A testcase that tests the @brauner is there a public place to see the daily CI for LXC+Docker/moby daemon details? If @kolyshkin or @thaJeztah have ideas on how to test this with our CI setup let me know. I definitely tried when this support initially came in via @hallyn's PR but found the dependencies (e.g. run via LXC) made it not so simple to add to our current framework. |
@estesp, yeah, sure it's at https://jenkins.linuxcontainers.org/view/LXD/view/LXD%20tests/job/lxd-test-docker/ |
And the actual test script is https://github.com/lxc/lxc-ci/blob/master/bin/test-lxd-docker it's pretty crude but it does the job :) |
I still don't understand how the other graphdrivers work inside userns (if my analysis are correct and they do not set |
Should always fallback to the |
That's at least how I would've implemented it. |
@kolyshkin I think you are correct that a more airtight fix across drivers needs more investigation. To your question "how does it work anywhere?" I think there is some complexity to the layers at which This PR as it stands may only be a stopgap to fix one glaring issue, but maybe we want to clean up this overall impl across graphdrivers? |
@kolyshkin I don't have the exact reasoning down to a codepath, but just FYI, I can't test |
Thank you @stgraber, I sent a trivial PR to improve it a bit: lxc/lxc-ci#18 In particular, I am interested in what graph driver is used ( |
Just FYI: on my lxc ubuntu:16.04 instance, using the "standard" Docker CE install ( |
True, but the amount of checks a graph driver can do during its initialization to see whether it can work correctly is limited (in other words, we can not afford trying to create, mount and start a multi-layer container during every graph driver init to see if it really works). So, we do some basic checks like if the fs is supported, if needed binaries are there, if the kernel is sufficient etc, and the check if gd is working inside user ns is not performed. |
Hmm, as per #35245, I will do some tests. |
OK I found why moby/pkg/chrootarchive/diff_unix.go Line 39 in 6796e74
... moby/pkg/chrootarchive/diff_unix.go Lines 55 to 57 in 6796e74
Now it's good to figure out why overlay2 needs this option explicitly set. |
Because for whatever reason overlay2 doesn't go through applyLayer at all. It links up it's archive untar to |
OK, it's all clear to me now. Overlay call stack is:
Overlay2 call stack is:
So, overlay works because its So, this patch LGTM. As a side note, it's interesting why code paths differ so much, and what is the difference between these. |
@kolyshkin they differ because |
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
@kolyshkin would that be something you could work on? |
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
@dmcgowan was/is it related to lack of sub-second time-stamps and inability to distinguish between changed files because of that? |
@kolyshkin yes, that one. There is a work around for it now that fixes the builder issue. |
The overlay2 driver was not setting up the
archive.TarOptions
fieldfor userns properly, like other storage backend routes to "applyTarLayer"
functionality are. The
InUserNS
field is now populated for overlay2 usingthe same query function used by the other storage drivers.
Signed-off-by: Phil Estes estesp@linux.vnet.ibm.com
Fixes: #35245