Commit graph

1054 commits

Author SHA1 Message Date
Kir Kolyshkin
b7a95a3ce4 lcow: fix debug in startServiceVMIfNotRunning()
When go-1.11beta1 is used for building, the following error is
reported:

> 14:56:20 daemon\graphdriver\lcow\lcow.go:236: Debugf format %s reads
> arg #2, but call has 1 arg

While fixing this, let's also fix a few other things in this
very function (startServiceVMIfNotRunning):

1. Do not use fmt.Printf when not required.
2. Use `title` whenever possible.
3. Don't add `id` to messages as `title` already has it.
4. Remove duplicated colons.
5. Try to unify style of messages.
6. s/startservicevmifnotrunning/startServiceVMIfNotRunning/
...

In general, logging/debugging here is a mess and requires much more
love than I can give it at the moment. Areas for improvement:

1. Add a global var logger = logrus.WithField("storage-driver", "lcow")
and use it everywhere else in the code.
2. Use logger.WithField("id", id) whenever possible (same for "context"
and other similar fields).
3. Revise all the errors returned to be uniform.
4. Make use of errors.Wrap[f] whenever possible.

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2018-07-12 13:42:23 -07:00
Kir Kolyshkin
2e30e9e6db
aufs: fix Wrapf args
Fix the following go-1.11beta1 build error:

> daemon/graphdriver/aufs/aufs.go:376: Wrapf format %s reads arg #1, but call has 0 args

While at it, change '%s' to %q.

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2018-07-11 15:52:22 +02:00
Derek McGowan
ac5d363e67
Update overlay2 to use naive diff for changes
The archive changes function is not implemented correctly
to handle opaque directories.

Signed-off-by: Derek McGowan <derek@mcgstyle.net>
2018-06-20 11:07:36 -07:00
Vincent Demeester
3845728524
Update tests to use gotest.tools 👼
Signed-off-by: Vincent Demeester <vincent@sbr.pm>
2018-06-13 09:04:30 +02:00
fanjiyun
0e8f96e317
When id is empty for overlay2/overlay, do not remove the directories.
Signed-off-by: fanjiyun <fan.jiyun@zte.com.cn>
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2018-06-07 17:35:54 -07:00
Brian Goff
7c77df8acc Move plugin client to separate interface
This makes it a bit simpler to remove this interface for v2 plugins
and not break external projects (libnetwork and swarmkit).

Note that before we remove the `Client()` interface from `CompatPlugin`
libnetwork and swarmkit must be updated to explicitly check for the v1
client interface as is done int his PR.

This is just a minor tweak that I realized is needed after trying to
implement the needed changes on libnetwork.

Signed-off-by: Brian Goff <cpuguy83@gmail.com>
2018-05-30 15:22:10 -04:00
Brian Goff
f51a96c016 Move plugin client creation to the extension point
Signed-off-by: Brian Goff <cpuguy83@gmail.com>
2018-05-25 15:18:53 -04:00
Sebastiaan van Stijn
f23c00d870
Various code-cleanup
remove unnescessary import aliases, brackets, and so on.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2018-05-23 17:50:54 +02:00
Kir Kolyshkin
91f85d1c78
aufs: log reason why aufs is not supported.
In case aufs driver is not supported because supportsAufs() said so,
it is not possible to get a real reason from the logs.

To fix, log the error returned.

Note we're not using WithError here as the error message itself is the
sole message we want to print (i.e. there's nothing to add to it).

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2018-05-20 12:02:41 +02:00
Kir Kolyshkin
c6e2af5425
aufs: use a single logger
Simplify the code by using a single logger instance.

While at it, use WithError in Umount.

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2018-05-20 12:02:12 +02:00
Sebastiaan van Stijn
f9dd74deee
Merge pull request #37022 from cgxu519/overlayutils-addmsg
Add additional message when backendfs is extfs without d_type support
2018-05-19 22:38:45 +02:00
Chengguang Xu
8a21b128d4 Add additional message when backendfs is extfs without d_type support
ext4 support d_type by default, but filetype feature is a tunable so
there is still a chance to disable it for some reasons. In this case,
print additional message to explicitly tell how to support d_type.

Signed-off-by: Chengguang Xu <cgxu519@gmx.com>
2018-05-18 10:32:47 +08:00
Sebastiaan van Stijn
4f8c870d62
Fix some linting issues
These showed locally when running `make validate`. CI doesn't seem to have the
same (possibly it's disabled in the configuration)

    builder/fscache/fscache.go:618::error: github.com/docker/docker/vendor/github.com/tonistiigi/fsutil.StatInfo composite literal uses unkeyed fields (vet)
    client/swarm_unlock_test.go:44::error: github.com/docker/docker/api/types/swarm.UnlockRequest composite literal uses unkeyed fields (vet)
    client/swarm_unlock_test.go:20::error: github.com/docker/docker/api/types/swarm.UnlockRequest composite literal uses unkeyed fields (vet)
    cmd/dockerd/daemon_unix.go:113::error: github.com/docker/docker/cmd/dockerd/hack.MalformedHostHeaderOverride composite literal uses unkeyed fields (vet)
    cmd/dockerd/daemon_unix.go:110::error: github.com/docker/docker/cmd/dockerd/hack.MalformedHostHeaderOverride composite literal uses unkeyed fields (vet)
    daemon/graphdriver/overlay/overlay.go:171::error: github.com/docker/docker/pkg/idtools.IDPair composite literal uses unkeyed fields (vet)
    daemon/graphdriver/overlay/overlay.go:413::error: github.com/docker/docker/pkg/idtools.IDPair composite literal uses unkeyed fields (vet)
    daemon/graphdriver/overlay2/overlay.go:203::error: github.com/docker/docker/pkg/idtools.IDPair composite literal uses unkeyed fields (vet)
    daemon/graphdriver/overlay2/overlay.go:584::error: github.com/docker/docker/pkg/idtools.IDPair composite literal uses unkeyed fields (vet)
    daemon/graphdriver/zfs/zfs.go:109::error: github.com/docker/docker/pkg/idtools.IDPair composite literal uses unkeyed fields (vet)
    daemon/graphdriver/zfs/zfs.go:388::error: github.com/docker/docker/pkg/idtools.IDPair composite literal uses unkeyed fields (vet)
    daemon/volumes_windows.go:27::error: github.com/docker/docker/pkg/idtools.IDPair composite literal uses unkeyed fields (vet)
    integration/service/network_test.go:31::error: github.com/docker/docker/api/types/network.NetworkingConfig composite literal uses unkeyed fields (vet)
    api/server/server.go:129:10⚠️ should not use basic type string as key in context.WithValue (golint)
    integration/service/network_test.go:54::error: github.com/docker/docker/api/types/network.NetworkingConfig composite literal uses unkeyed fields (vet)
    libcontainerd/client_daemon_linux.go:61::error: github.com/docker/docker/pkg/idtools.IDPair composite literal uses unkeyed fields (vet)
    libcontainerd/client_daemon_linux.go:74::error: github.com/docker/docker/pkg/idtools.IDPair composite literal uses unkeyed fields (vet)
    pkg/archive/archive_windows.go:76::error: github.com/docker/docker/pkg/idtools.IDPair composite literal uses unkeyed fields (vet)
    plugin/manager_linux.go:56::error: github.com/docker/docker/pkg/idtools.IDPair composite literal uses unkeyed fields (vet)

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2018-05-17 19:28:27 +02:00
weipeng
f781ec45b5 Fix typos
Signed-off-by: weipeng <weipeng@tuscloud.io>
2018-05-16 09:15:43 +08:00
Vincent Demeester
a79d04ae55
Merge pull request #37040 from thaJeztah/error_on_unsupported_options
overlay: do not ignore invalid storage-driver options
2018-05-14 15:37:33 +02:00
Sebastiaan van Stijn
8a8ec00c1f
overlay2: remove unused cdMountFrom() helper function
This function was added in 23e5c94cfb but never used

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2018-05-11 13:51:50 +02:00
Sebastiaan van Stijn
30f15d2bdc
overlay: do not ignore invalid storage-driver options
The overlay storage driver currently does not support any option, but was silently
ignoring any option that was passed.

This patch verifies that no options are passed, and if they are passed will produce
an error.

Before this change:

    dockerd --storage-driver=overlay --storage-opt dm.thinp_percent=95
    INFO[2018-05-11T11:40:40.996597152Z] libcontainerd: started new docker-containerd process  pid=256
    ....
    INFO[2018-05-11T11:40:41.135392535Z] Daemon has completed initialization
    INFO[2018-05-11T11:40:41.141035093Z] API listen on /var/run/docker.sock

After this change:

    dockerd --storage-driver=overlay --storage-opt dm.thinp_percent=95
    INFO[2018-05-11T11:39:21.632610319Z] libcontainerd: started new docker-containerd process  pid=233
    ....
    Error starting daemon: error initializing graphdriver: overlay: unknown option dm.thinp_percent

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2018-05-11 13:40:46 +02:00
Anusha Ragunathan
65c575f592
Merge pull request #36599 from Microsoft/jjh/dockersave
LCOW: Implement `docker save`
2018-04-24 11:14:32 -07:00
Vincent Demeester
53982e3fc1
Merge pull request #36091 from kolyshkin/mount
pkg/mount improvements
2018-04-21 11:03:54 +02:00
Vincent Demeester
c4ba5be6af
Merge pull request #36492 from alejgh/36478-log-standardization
36478 storage-drivers log format standardization
2018-04-20 12:11:14 +02:00
Kir Kolyshkin
bb934c6aca pkg/mount: implement/use filter for mountinfo parsing
Functions `GetMounts()` and `parseMountTable()` return all the entries
as read and parsed from /proc/self/mountinfo. In many cases the caller
is only interested only one or a few entries, not all of them.

One good example is `Mounted()` function, which looks for a specific
entry only. Another example is `RecursiveUnmount()` which is only
interested in mount under a specific path.

This commit adds `filter` argument to `GetMounts()` to implement
two things:
 1. filter out entries a caller is not interested in
 2. stop processing if a caller is found what it wanted

`nil` can be passed to get a backward-compatible behavior, i.e. return
all the entries.

A few filters are implemented:
 - `PrefixFilter`: filters out all entries not under `prefix`
 - `SingleEntryFilter`: looks for a specific entry

Finally, `Mounted()` is modified to use `SingleEntryFilter()`, and
`RecursiveUnmount()` is using `PrefixFilter()`.

Unit tests are added to check filters are working.

[v2: ditch NoFilter, use nil]
[v3: ditch GetMountsFiltered()]
[v4: add unit test for filters]
[v5: switch to gotestyourself]

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2018-04-19 14:48:09 -07:00
Yong Tang
5c2e6064a1
Merge pull request #36738 from Microsoft/jjh/getlayerpath
Windows: Add GetLayerPath implementation in graphdriver
2018-04-14 09:59:38 -07:00
Anusha Ragunathan
a8260058e3
Merge pull request #36728 from darrenstahlmsft/LayerLeak
Fix Windows layer leak when write fails
2018-04-04 19:05:59 -07:00
Darren Stahl
1f28844d78 Fix Windows layer leak when write fails
Signed-off-by: Darren Stahl <darst@microsoft.com>
2018-04-04 12:31:23 -07:00
Maxim Ivanov
6f084f2929 Fix FIFO, sockets and device files when run in user NS
commit 617c352e92 "Don't create devices if in a user namespace"

introduced check, which meant to skip mknod operation when run
in user namespace, but instread skipped FIFO and socket files
copy.

Signed-off-by: Maxim Ivanov <ivanov.maxim@gmail.com>
2018-04-01 12:33:59 +01:00
Vincent Demeester
6c948b562d
Merge pull request #36736 from tonistiigi/remove-test-kernel-version
copy: remove kernel version test
2018-03-30 10:53:40 +02:00
Brian Goff
9d46c4c138 Support cancellation in directory.Size()
Makes sure that if the user cancels a request that the daemon stops
trying to traverse a directory.

Signed-off-by: Brian Goff <cpuguy83@gmail.com>
2018-03-29 15:49:15 -04:00
John Howard (VM)
3aab84803d Windows: GetLayerPath in graphdriver
Signed-off-by: John Howard (VM) <jhoward@ntdev.microsoft.com>
2018-03-29 11:45:45 -07:00
Tonis Tiigi
4d6b8f73a8 copy: remove kernel version test
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2018-03-29 10:45:43 -07:00
Alejandro González Hevia
9392838150 Standardized log messages accross the different storage drivers.
Now all of the storage drivers use the field "storage-driver" in their log
messages, which is set to name of the respective driver.
Storage drivers changed:
- Aufs
- Btrfs
- Devicemapper
- Overlay
- Overlay 2
- Zfs

Signed-off-by: Alejandro GonzÃlez Hevia <alejandrgh11@gmail.com>
2018-03-27 14:37:30 +02:00
Daniel Nephin
c9e52bd0da Post migration assertion fixes
Signed-off-by: Daniel Nephin <dnephin@docker.com>
2018-03-16 11:03:46 -04:00
Daniel Nephin
6be0f70983 Automated migration using
gty-migrate-from-testify --ignore-build-tags

Signed-off-by: Daniel Nephin <dnephin@docker.com>
2018-03-16 11:03:43 -04:00
John Howard
6b4f989bc2 LCOW: Graphdriver DiffGetter implementation
Signed-off-by: John Howard <jhoward@microsoft.com>
2018-03-14 11:55:06 -07:00
Tõnis Tiigi
bc7424b443
Merge pull request #36307 from kolyshkin/dm-misc
devmapper cleanup improvements
2018-03-07 12:57:21 -08:00
Brian Goff
a6b1d2ea29
Merge pull request #36437 from kolyshkin/dm-unused
devmapper.Mounted: remove
2018-03-05 18:14:36 -08:00
Kir Kolyshkin
f1a4592297 devmapper.shutdown: optimize
Move the "unmount and deactivate" code into a separate method, and
optimize it a bit:

1. Do not use filepath.Walk() as there's no requirement to recursively
   go into every directory under home/mnt; a list of directories in mnt
   is sufficient. With filepath.Walk(), in case some container will fail
   to unmount, it'll go through the whole container filesystem which is
   excessive and useless.

2. Do not use GetMounts() and check if a directory is mounted; just
   unmount it and ignore "not mounted" error. Note the same error
   is returned in case of wrong flags set, but as flags are hardcoded
   we can safely ignore such case.

While at it, promote "can't unmount" log level from debug to warning.

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2018-03-05 10:08:56 -08:00
Kir Kolyshkin
9d00aedebc devmapper cleanup: improve error msg
1. Make sure it's clear the error is from unmount.

2. Simplify the code a bit to make it more readable.

[v2: use errors.Wrap]
[v3: use errors.Wrapf]
[v4: lowercase the error message]

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2018-03-05 10:08:56 -08:00
Kir Kolyshkin
732dd9b848 devmapper/Remove(): use Rmdir, ignore errors
1. Replace EnsureRemoveAll() with Rmdir(), as here we are removing
   the container's mount point, which is already properly unmounted
   and is therefore an empty directory.

2. Ignore the Rmdir() error (but log it unless it's ENOENT). This
   is a mount point, currently unmounted (i.e. an empty directory),
   and an older kernel can return EBUSY if e.g. the mount was
   leaked to other mount namespaces.

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2018-03-02 18:10:57 -08:00
Kir Kolyshkin
0450f61cb9 devmapper.Mounted: remove
It looks like no one uses this function.

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2018-02-27 19:13:46 -08:00
Yong Tang
742d4506bd Golint fix up
This fix fixes a golint issue.

Signed-off-by: Yong Tang <yong.tang.github@outlook.com>
2018-02-23 16:40:37 +00:00
Sebastiaan van Stijn
20028325da
Merge pull request #35829 from cpuguy83/no_private_mount_for_plugins
Perform plugin mounts in the runtime
2018-02-21 12:28:13 +01:00
Tõnis Tiigi
733ed2ddd3
Merge pull request #36256 from wcwxyz/fix-refcounter-memory-leak
graphdriver: Fix RefCounter memory leak
2018-02-19 10:32:14 -08:00
Brian Goff
68c3201626
Merge pull request #36237 from cpuguy83/zfs_do_not_unmount
Do not recursive unmount on cleanup of zfs/btrfs
2018-02-14 09:49:17 -05:00
bin liu
b00a67be6e Fix typos in daemon
Signed-off-by: bin liu <liubin0329@gmail.com>
2018-02-10 19:42:54 +08:00
WANG Chao
9015a05606 graphdriver: Fix RefCounter memory leak
Signed-off-by: WANG Chao <chao.wang@ucloud.cn>
2018-02-09 10:26:06 +08:00
Brian Goff
0e5eaf8ee3 Ensure plugin returns correctly scoped paths
Before this change, volume management was relying on the fact that
everything the plugin mounts is visible on the host within the plugin's
rootfs. In practice this caused some issues with mount leaks, so we
changed the behavior such that mounts are not visible on the plugin's
rootfs, but available outside of it, which breaks volume management.

To fix the issue, allow the plugin to scope the path correctly rather
than assuming that everything is visible in `p.Rootfs`.
In practice this is just scoping the `PropagatedMount` paths to the
correct host path.

Signed-off-by: Brian Goff <cpuguy83@gmail.com>
2018-02-07 15:48:27 -05:00
Brian Goff
a53930a04f Plugins perform propagated mount in runtime spec
Setting up the mounts on the host increases chances of mount leakage and
makes for more cleanup after the plugin has stopped.
With this change all mounts for the plugin are performed by the
container runtime and automatically cleaned up when the container exits.

Signed-off-by: Brian Goff <cpuguy83@gmail.com>
2018-02-07 15:48:27 -05:00
Brian Goff
2fe4f888be Do not recursive unmount on cleanup of zfs/btrfs
This was added in #36047 just as a way to make sure the tree is fully
unmounted on shutdown.

For ZFS this could be a breaking change since there was no unmount before.
Someone could have setup the zfs tree themselves. It would be better, if
we really do want the cleanup to actually the unpacked layers checking
for mounts rather than a blind recursive unmount of the root.

BTRFS does not use mounts and does not need to unmount anyway.
These was only an unmount to begin with because for some reason the
btrfs tree was being moutned with `private` propagation.

For the other graphdrivers that still have a recursive unmount here...
these were already being unmounted and performing the recursive unmount
shouldn't break anything. If anyone had anything mounted at the
graphdriver location it would have been unmounted on shutdown anyway.

Signed-off-by: Brian Goff <cpuguy83@gmail.com>
2018-02-07 15:08:17 -05:00
Daniel Nephin
4f0d95fa6e Add canonical import comment
Signed-off-by: Daniel Nephin <dnephin@docker.com>
2018-02-05 16:51:57 -05:00
Yong Tang
03a1df9536
Merge pull request #36114 from Microsoft/jjh/fixdeadlock-lcowdriver-hotremove
LCOW: Graphdriver fix deadlock in hotRemoveVHDs
2018-01-29 09:57:43 -08:00
Michael Crosby
2c05aefc99
Merge pull request #36047 from cpuguy83/graphdriver_improvements
Do not make graphdriver homes private mounts.
2018-01-26 13:54:30 -05:00
John Howard
a44fcd3d27 LCOW: Graphdriver fix deadlock
Signed-off-by: John Howard <jhoward@microsoft.com>
2018-01-26 08:57:52 -08:00
Sebastiaan van Stijn
a8d0e36d03
Merge pull request #36052 from Microsoft/jjh/no-overlay-off-only-one-disk
LCOW: Regular mount if only one layer
2018-01-25 15:46:16 -08:00
Vincent Demeester
3c9d023af3
Merge pull request #36051 from Microsoft/jjh/remotefs-read-return-error
LCOW remotefs - return error in Read() implementation
2018-01-19 11:27:13 -08:00
John Howard
6112ad6e7d LCOW remotefs - return error in Read() implementation
Signed-off-by: John Howard <jhoward@microsoft.com>
2018-01-18 17:46:58 -08:00
John Howard
420dc4eeb4 LCOW: Regular mount if only one layer
Signed-off-by: John Howard <jhoward@microsoft.com>
2018-01-18 12:01:58 -08:00
John Howard
afd305c4b5 LCOW: Refactor to multiple layer-stores based on feedback
Signed-off-by: John Howard <jhoward@microsoft.com>
2018-01-18 08:31:05 -08:00
Brian Goff
9803272f2d Do not make graphdriver homes private mounts.
The idea behind making the graphdrivers private is to prevent leaking
mounts into other namespaces.
Unfortunately this is not really what happens.

There is one case where this does work, and that is when the namespace
was created before the daemon's namespace.
However with systemd each system servie winds up with it's own mount
namespace. This causes a race betwen daemon startup and other system
services as to if the mount is actually private.

This also means there is a negative impact when other system services
are started while the daemon is running.

Basically there are too many things that the daemon does not have
control over (nor should it) to be able to protect against these kinds
of leakages. One thing is certain, setting the graphdriver roots to
private disconnects the mount ns heirarchy preventing propagation of
unmounts... new mounts are of course not propagated either, but the
behavior is racey (or just bad in the case of restarting services)... so
it's better to just be able to keep mount propagation in tact.

It also does not protect situations like `-v
/var/lib/docker:/var/lib/docker` where all mounts are recursively bound
into the container anyway.

Signed-off-by: Brian Goff <cpuguy83@gmail.com>
2018-01-18 09:34:00 -05:00
John Howard
141b9a7471 LCOW: Fix OpenFile parameters
Signed-off-by: John Howard <jhoward@microsoft.com>
2018-01-17 07:58:18 -08:00
Drew Hubl
27b002f4a0 Improve zfs init log message for zfs
Signed-off-by: Drew Hubl <drew.hubl@gmail.com>
Signed-off-by: Brian Goff <cpuguy83@gmail.com>
2018-01-16 21:42:05 -05:00
Yong Tang
c36274da83
Merge pull request #35638 from cpuguy83/error_helpers2
Add helpers to create errdef errors
2018-01-15 10:56:46 -08:00
Sebastiaan van Stijn
b4a6313969
Golint: remove redundant ifs
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2018-01-15 00:42:25 +01:00
Brian Goff
d453fe35b9 Move api/errdefs to errdefs
Signed-off-by: Brian Goff <cpuguy83@gmail.com>
2018-01-11 21:21:43 -05:00
Daniel Nephin
e3a6323419 Cleanup graphdriver/quota test
Signed-off-by: Daniel Nephin <dnephin@docker.com>
2018-01-08 13:41:45 -05:00
Tõnis Tiigi
daded8da91
Merge pull request #35674 from kolyshkin/zfs-rmdir
zfs: fix ebusy on umount etc
2017-12-28 15:35:19 -08:00
Yong Tang
3e1df952b7
Merge pull request #35827 from kolyshkin/vfs-quota
Fix VFS vs quota regression
2017-12-22 12:32:03 -06:00
Kir Kolyshkin
1e8a087850 vfs gd: ignore quota setup errors
This is a fix to regression in vfs graph driver introduced by
commit 7a1618ced3 ("add quota support to VFS graphdriver").

On some filesystems, vfs fails to init with the following error:

> Error starting daemon: error initializing graphdriver: Failed to mknod
> /go/src/github.com/docker/docker/bundles/test-integration/d6bcf6de610e9/root/vfs/backingFsBlockDev:
> function not implemented

As quota is not essential for vfs, let's ignore (but log as a warning) any error
from quota init.

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2017-12-19 13:55:04 -08:00
Kir Kolyshkin
2dd39b7841 projectquota: treat ENOSYS as quota unsupported
If mknod() returns ENOSYS, it most probably means quota is not supported
here, so return the appropriate error.

This is a conservative* fix to regression in vfs graph driver introduced
by commit 7a1618ced3 ("add quota support to VFS graphdriver").
On some filesystems, vfs fails to init with the following error:

> Error starting daemon: error initializing graphdriver: Failed to mknod
> /go/src/github.com/docker/docker/bundles/test-integration/d6bcf6de610e9/root/vfs/backingFsBlockDev:
> function not implemented

Reported-by: Brian Goff <cpuguy83@gmail.com>
Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2017-12-18 10:32:36 -08:00
Sebastiaan van Stijn
6ed1163c98
Remove redundant build-tags
Files that are suffixed with `_linux.go` or `_windows.go` are
already only built on Linux / Windows, so these build-tags
were redundant.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2017-12-18 17:41:53 +01:00
Phil Estes
05b8d59015
Fix overlay2 storage driver inside a user namespace
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>
2017-12-13 23:38:22 -05:00
Vivek Goyal
f728d74ac5 devmapper: Log fstype and mount options during mount error
Right now we only log source and destination (and demsg) if mount operation
fails. fstype and mount options are available easily. It probably is a good
idea to log these as well. Especially sometimes failures can happen due to
mount options.

Signed-off-by: Vivek Goyal <vgoyal@redhat.com>
2017-12-11 13:27:14 -05:00
Victor Vieux
bd8a9c25ee
Merge pull request #35514 from thaJeztah/disable-overlay-without-d_type
Remove support for overlay/overlay2 without d_type
2017-12-06 14:13:58 -08:00
Jihyun Hwang
518c50c9b2 fixed typo (reliablity -> reliability)
Signed-off-by: Jihyun Hwang <jhhwang@telcoware.com>
2017-12-06 09:51:53 +09:00
Sebastiaan van Stijn
0a4e793a3d
Allow existing setups to continue using d_type
Even though it's highly discouraged, there are existing
installs that are running overlay/overlay2 on filesystems
without d_type support.

This patch allows the daemon to start in such cases, instead of
refusing to start without an option to override.

For fresh installs, backing filesystems without d_type support
will still cause the overlay/overlay2 drivers to be marked as
"unsupported", and skipped during the automatic selection.

This feature is only to keep backward compatibility, but
will be removed at some point.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2017-12-04 18:41:25 -08:00
Yong Tang
4047cede65
Merge pull request #35537 from sargun/vfs-use-copy_file_range
Have VFS graphdriver use accelerated in-kernel copy
2017-12-04 19:34:56 -06:00
Sebastiaan van Stijn
0abb8dec3f
Remove support for overlay/overlay2 without d_type
Support for running overlay/overlay2 on a backing filesystem
without d_type support (most likely: xfs, as ext4 supports
this by default), was deprecated for some time.

Running without d_type support is problematic, and can
lead to difficult to debug issues ("invalid argument" errors,
or unable to remove files from the container's filesystem).

This patch turns the warning that was previously printed
into an "unsupported" error, so that the overlay/overlay2
drivers are not automatically selected when detecting supported
storage drivers.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2017-12-04 17:10:20 -08:00
Sebastiaan van Stijn
f9c8fa305e
Perform fsmagic detection on driver's home-dir if it exists
The fsmagic check was always performed on "data-root" (`/var/lib/docker`),
not on the storage-driver's home directory (e.g. `/var/lib/docker/<somedriver>`).

This caused detection to be done on the wrong filesystem in situations
where `/var/lib/docker/<somedriver>` was a mount, and a different
filesystem than `/var/lib/docker` itself.

This patch checks if the storage-driver's home directory exists, and only
falls back to `/var/lib/docker` if it doesn't exist.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2017-12-04 17:10:07 -08:00
Kir Kolyshkin
a450a575a6 zfs: fix ebusy on umount
This commit is a set of fixes and improvement for zfs graph driver,
in particular:

1. Remove mount point after umount in `Get()` error path, as well
   as in `Put()` (with `MNT_DETACH` flag). This should solve "failed
   to remove root filesystem for <ID> .... dataset is busy" error
   reported in Moby issue 35642.

To reproduce the issue:

   - start dockerd with zfs
   - docker run -d --name c1 --rm busybox top
   - docker run -d --name c2 --rm busybox top
   - docker stop c1
   - docker rm c1

Output when the bug is present:
```
Error response from daemon: driver "zfs" failed to remove root
filesystem for XXX : exit status 1: "/sbin/zfs zfs destroy -r
scratch/docker/YYY" => cannot destroy 'scratch/docker/YYY':
dataset is busy
```

Output when the bug is fixed:
```
Error: No such container: c1
```
(as the container has been successfully autoremoved on stop)

2. Fix/improve error handling in `Get()` -- do not try to umount
   if `refcount` > 0

3. Simplifies unmount in `Get()`. Specifically, remove call to
   `graphdriver.Mounted()` (which checks if fs is mounted using
   `statfs()` and check for fs type) and `mount.Unmount()` (which
   parses `/proc/self/mountinfo`). Calling `unix.Unmount()` is
   simple and sufficient.

4. Add unmounting of driver's home to `Cleanup()`.

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2017-12-01 13:46:47 -08:00
Sargun Dhillon
77a2bc3e5b Fix setting mtimes on directories
Previously, the code would set the mtime on the directories before
creating files in the directory itself. This was problematic
because it resulted in the mtimes on the directories being
incorrectly set. This change makes it so that the mtime is
set only _after_ all of the files have been created.

Signed-off-by: Sargun Dhillon <sargun@sargun.me>
2017-12-01 09:12:43 -08:00
Michael Crosby
72e45fd54e
Merge pull request #35618 from kolyshkin/mkdir-all
Fix MkdirAll* and its usage
2017-11-30 11:19:29 -05:00
Tõnis Tiigi
bdd9668b48
Merge pull request #35483 from thaJeztah/disallow-nfs-backing-for-overlay
Disallow overlay/overlay2 on top of NFS
2017-11-29 19:24:58 -08:00
Victor Vieux
11e07e7da6
Merge pull request #35527 from thaJeztah/feature-detect-overlay2
Detect overlay2 support on pre-4.0 kernels
2017-11-29 13:51:26 -08:00
Akihiro Suda
09eb7bcc36
Merge pull request #34948 from euank/public-mounts
Fix EBUSY errors under overlayfs and v4.13+ kernels
2017-11-29 12:48:39 +09:00
Sargun Dhillon
0eac562281 Fix bug, where copy_file_range was still calling legacy copy
There was a small issue here, where it copied the data using
traditional mechanisms, even when copy_file_range was successful.

Signed-off-by: Sargun Dhillon <sargun@sargun.me>
2017-11-28 14:59:56 -08:00
Sargun Dhillon
d2b71b2660 Have VFS graphdriver use accelerated in-kernel copy
This change makes the VFS graphdriver use the kernel-accelerated
(copy_file_range) mechanism of copying files, which is able to
leverage reflinks.

Signed-off-by: Sargun Dhillon <sargun@sargun.me>
2017-11-28 14:59:56 -08:00
Sargun Dhillon
b467f8b2ef Fix copying hardlinks in graphdriver/copy
Previously, graphdriver/copy would improperly copy hardlinks as just regular
files. This patch changes that behaviour, and instead the code now keeps
track of inode numbers, and if it sees the same inode number again
during the copy loop, it hardlinks it, instead of copying it.

Signed-off-by: Sargun Dhillon <sargun@sargun.me>
2017-11-28 14:59:56 -08:00
Sebastiaan van Stijn
955c1f881a
Detect overlay2 support on pre-4.0 kernels
The overlay2 storage-driver requires multiple lower dir
support for overlayFs. Support for this feature was added
in kernel 4.x, but some distros (RHEL 7.4, CentOS 7.4) ship with
an older kernel with this feature backported.

This patch adds feature-detection for multiple lower dirs,
and will perform this feature-detection on pre-4.x kernels
with overlayFS support.

With this patch applied, daemons running on a kernel
with multiple lower dir support will now select "overlay2"
as storage-driver, instead of falling back to "overlay".

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2017-11-28 13:55:33 -08:00
Victor Vieux
9ae697167c
Merge pull request #35528 from thaJeztah/ignore-empty-graphdirs
Skip empty directories on prior graphdriver detection
2017-11-27 17:37:39 -08:00
Kir Kolyshkin
516010e92d Simplify/fix MkdirAll usage
This subtle bug keeps lurking in because error checking for `Mkdir()`
and `MkdirAll()` is slightly different wrt to `EEXIST`/`IsExist`:

 - for `Mkdir()`, `IsExist` error should (usually) be ignored
   (unless you want to make sure directory was not there before)
   as it means "the destination directory was already there"

 - for `MkdirAll()`, `IsExist` error should NEVER be ignored.

Mostly, this commit just removes ignoring the IsExist error, as it
should not be ignored.

Also, there are a couple of cases then IsExist is handled as
"directory already exist" which is wrong. As a result, some code
that never worked as intended is now removed.

NOTE that `idtools.MkdirAndChown()` behaves like `os.MkdirAll()`
rather than `os.Mkdir()` -- so its description is amended accordingly,
and its usage is handled as such (i.e. IsExist error is not ignored).

For more details, a quote from my runc commit 6f82d4b (July 2015):

    TL;DR: check for IsExist(err) after a failed MkdirAll() is both
    redundant and wrong -- so two reasons to remove it.

    Quoting MkdirAll documentation:

    > MkdirAll creates a directory named path, along with any necessary
    > parents, and returns nil, or else returns an error. If path
    > is already a directory, MkdirAll does nothing and returns nil.

    This means two things:

    1. If a directory to be created already exists, no error is
    returned.

    2. If the error returned is IsExist (EEXIST), it means there exists
    a non-directory with the same name as MkdirAll need to use for
    directory. Example: we want to MkdirAll("a/b"), but file "a"
    (or "a/b") already exists, so MkdirAll fails.

    The above is a theory, based on quoted documentation and my UNIX
    knowledge.

    3. In practice, though, current MkdirAll implementation [1] returns
    ENOTDIR in most of cases described in #2, with the exception when
    there is a race between MkdirAll and someone else creating the
    last component of MkdirAll argument as a file. In this very case
    MkdirAll() will indeed return EEXIST.

    Because of #1, IsExist check after MkdirAll is not needed.

    Because of #2 and #3, ignoring IsExist error is just plain wrong,
    as directory we require is not created. It's cleaner to report
    the error now.

    Note this error is all over the tree, I guess due to copy-paste,
    or trying to follow the same usage pattern as for Mkdir(),
    or some not quite correct examples on the Internet.

    [1] https://github.com/golang/go/blob/f9ed2f75/src/os/path.go

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2017-11-27 17:32:12 -08:00
Euan Kemp
af0d589623 graphdriver/overlay{,2}: remove 'merged' on umount
This removes and recreates the merged dir with each umount/mount
respectively.
This is done to make the impact of leaking mountpoints have less
user-visible impact.

It's fairly easy to accidentally leak mountpoints (even if moby doesn't,
other tools on linux like 'unshare' are quite able to incidentally do
so).

As of recently, overlayfs reacts to these mounts being leaked (see

One trick to force an unmount is to remove the mounted directory and
recreate it. Devicemapper now does this, overlay can follow suit.

Signed-off-by: Euan Kemp <euan.kemp@coreos.com>
2017-11-22 14:32:30 -08:00
Euan Kemp
1e214c0952 graphdriver/overlay: minor doc comment cleanup
Signed-off-by: Euan Kemp <euan.kemp@coreos.com>
2017-11-22 14:17:08 -08:00
Sebastiaan van Stijn
1262c57714
Skip empty directories on prior graphdriver detection
When starting the daemon, the `/var/lib/docker` directory
is scanned for existing directories, so that the previously
selected graphdriver will automatically be used.

In some situations, empty directories are present (those
directories can be created during feature detection of
graph-drivers), in which case the daemon refuses to start.

This patch improves detection, and skips empty directories,
so that leftover directories don't cause the daemon to
fail.

Before this change:

    $ mkdir /var/lib/docker /var/lib/docker/aufs /var/lib/docker/overlay2
    $ dockerd
    ...
    Error starting daemon: error initializing graphdriver: /var/lib/docker contains several valid graphdrivers: overlay2, aufs; Please cleanup or explicitly choose storage driver (-s <DRIVER>)

With this patch applied:

    $ mkdir /var/lib/docker /var/lib/docker/aufs /var/lib/docker/overlay2
    $ dockerd
    ...
    INFO[2017-11-16T17:26:43.207739140Z] Docker daemon                                 commit=ab90bc296 graphdriver(s)=overlay2 version=dev
    INFO[2017-11-16T17:26:43.208033095Z] Daemon has completed initialization

And on restart (prior graphdriver is still picked up):

    $ dockerd
    ...
    INFO[2017-11-16T17:27:52.260361465Z] [graphdriver] using prior storage driver: overlay2

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2017-11-21 15:42:04 +01:00
Sebastiaan van Stijn
38b3af567f
Remove deprecated MkdirAllAs(), MkdirAs()
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2017-11-21 13:53:54 +01:00
Victor Vieux
edc204b1ff
Merge pull request #35522 from kolyshkin/gd-custom
graphdriver: custom build-time priority list
2017-11-17 15:48:26 -08:00
Christian Brauner
7e35df0e04
Skip further checks for quota in user namespaces
Commit 7a1618ced3 regresses running Docker
in user namespaces. The new check for whether quota are supported calls
NewControl() which in turn calls makeBackingFsDev() which tries to
mknod(). Skip quota tests when we detect that we are running in a user
namespace and return ErrQuotaNotSupported to the caller. This just
restores the status quo.

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2017-11-17 12:57:27 +01:00
Kir Kolyshkin
17708e72a7 graphdriver: custom build-time priority list
Add a way to specify a custom graphdriver priority list
during build. This can be done with something like

  go build -ldflags "-X github.com/docker/docker/daemon/graphdriver.priority=overlay2,devicemapper"

As ldflags are already used by the engine build process, and it seems
that only one (last) `-ldflags` argument is taken into account by go,
an envoronment variable `DOCKER_LDFLAGS` is introduced in order to
be able to append some text to `-ldflags`. With this in place,
using the feature becomes

  make DOCKER_LDFLAGS="-X github.com/docker/docker/daemon/graphdriver.priority=overlay2,devicemapper" dynbinary

The idea behind this is, the priority list might be different
for different distros, so vendors are now able to change it
without patching the source code.

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2017-11-16 19:43:34 -08:00
Kir Kolyshkin
d014be5426 daemon/graphdriver/register: separate overlay2
Make it possible to disable overlay and overlay2 separately.

With this commit, we now have `exclude_graphdriver_overlay` and
`exclude_graphdriver_overlay2` build tags for the engine, which
is in line with any other graph driver.

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2017-11-15 00:06:00 -08:00
Justin Cormack
0defc69813
Merge pull request #35231 from sargun/add-vfs-quota-support
Add vfs quota support
2017-11-14 15:05:02 +00:00
Sebastiaan van Stijn
90dfb1d0cc
Disallow overlay/overlay2 on top of NFS
From https://www.kernel.org/doc/Documentation/filesystems/overlayfs.txt:

> The lower filesystem can be any filesystem supported by Linux and does
> not need to be writable. The lower filesystem can even be another
> overlayfs. The upper filesystem will normally be writable and if it
> is it must support the creation of trusted.* extended attributes, and
> must provide valid d_type in readdir responses, so NFS is not suitable.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2017-11-13 23:24:23 +01:00
Vincent Demeester
bbc4f78ba9
Merge pull request #34573 from cyphar/dm-dos-prevention-remove-mountpoint
devicemapper: remove container rootfs mountPath after umount
2017-11-08 17:08:07 +01:00
Aleksa Sarai
1af8ea681f
devmapper: add a test for mount leak workaround
In order to avoid reverting our fix for mount leakage in devicemapper,
add a test which checks that devicemapper's Get() and Put() cycle can
survive having a command running in an rprivate mount propagation setup
in-between. While this is quite rudimentary, it should be sufficient.

We have to skip this test for pre-3.18 kernels.

Signed-off-by: Aleksa Sarai <asarai@suse.de>
2017-11-08 11:02:11 +11:00
Sargun Dhillon
7a1618ced3 Add quota support to VFS graphdriver
This patch adds the capability for the VFS graphdriver to use
XFS project quotas. It reuses the existing quota management
code that was created by overlay2 on XFS.

It doesn't rely on a filesystem whitelist, but instead
the quota-capability detection code.

Signed-off-by: Sargun Dhillon <sargun@sargun.me>
2017-11-06 15:53:51 -08:00
Yong Tang
4785f1a7ab Remove solaris build tag and `contrib/mkimage/solaris
Signed-off-by: Yong Tang <yong.tang.github@outlook.com>
2017-11-02 00:01:46 +00:00
Sebastiaan van Stijn
226eb8004e
Merge pull request #35177 from sargun/add-quota-tests
Add tests to project quotas and detection mechanism
2017-10-30 21:08:38 +01:00
Sargun Dhillon
6966dc0aa9 Add tests to project quotas and detection mechanism
This adds a mechanism (read-only) to check for project quota support
in a standard way. This mechanism is leveraged by the tests, which
test for the following:
 1. Can we get a quota controller?
 2. Can we set the quota for a particular directory?
 3. Is the quota being over-enforced?
 4. Is the quota being under-enforced?
 5. Can we retrieve the quota?

Signed-off-by: Sargun Dhillon <sargun@sargun.me>
2017-10-27 11:07:37 -07:00
Sebastiaan van Stijn
8f702de9b7
Improve devicemapper driver-status output
Do not print "Data file" and "Metadata file" if they're
not used, and sort/group output.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2017-10-27 10:12:39 +02:00
Sebastiaan van Stijn
ce5800c329 Merge pull request #34670 from sargun/use_copy_file_range
Use In-kernel File Copy for Overlayfs and VFS on Linux
2017-10-25 17:10:44 +02:00
Sargun Dhillon
3ec4ec2857 Add zero-copy support to copy module
This changeset allows Docker's VFS, and Overlay to take advantage of
Linux's zerocopy APIs.

The copy function first tries to use the ficlone ioctl. Reason being:
 - they do not allow partial success (aka short writes)
 - clones are expected to be a fast metadata operation
See: http://oss.sgi.com/archives/xfs/2015-12/msg00356.html

If the clone fails, we fall back to copy_file_range, which internally
may fall back to splice, which has an upper limit on the size
of copy it can perform. Given that, we have to loop until the copy
is done.

For a given dirCopy operation, if the clone fails, we will not try
it again during any other file copy. Same is true with copy_file_range.

If all else fails, we fall back to traditional copy.

Signed-off-by: Sargun Dhillon <sargun@sargun.me>
2017-10-24 13:14:40 -07:00
Sargun Dhillon
5298785b8e Separate daemon/graphdriver/overlay/copy into its own package
Signed-off-by: Sargun Dhillon <sargun@sargun.me>
2017-10-24 13:14:40 -07:00
Michael Crosby
5a9b5f10cf Remove solaris files
For obvious reasons that it is not really supported now.

Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
2017-10-24 15:39:34 -04:00
John Howard
0380fbff37 LCOW: API: Add platform to /images/create and /build
Signed-off-by: John Howard <jhoward@microsoft.com>

This PR has the API changes described in https://github.com/moby/moby/issues/34617.
Specifically, it adds an HTTP header "X-Requested-Platform" which is a JSON-encoded
OCI Image-spec `Platform` structure.

In addition, it renames (almost all) uses of a string variable platform (and associated)
methods/functions to os. This makes it much clearer to disambiguate with the swarm
"platform" which is really os/arch. This is a stepping stone to getting the daemon towards
fully multi-platform/arch-aware, and makes it clear when "operating system" is being
referred to rather than "platform" which is misleadingly used - sometimes in the swarm
meaning, but more often as just the operating system.
2017-10-06 11:44:18 -07:00
Yong Tang
595b929c57 Merge pull request #34342 from coolljt0725/fallback_to_naive_diff
Fallback to use naive diff driver if enable CONFIG_OVERLAY_FS_REDIRECT_DIR
2017-10-03 06:45:17 -07:00
Yuhao Fang
c673319dea fix typo
Signed-off-by: Yuhao Fang <fangyuhao@gmail.com>
2017-10-01 23:11:58 +08:00
Lei Jitang
49c3a7c4ba Fallback to use naive diff driver if enable CONFIG_OVERLAY_FS_REDIRECT_DIR
When use overlay2 as the graphdriver and the kernel enable
`CONFIG_OVERLAY_FS_REDIRECT_DIR=y`, rename a dir in lower layer
will has a xattr to redirct its dir to source dir. This make the
image layer unportable. This patch fallback to use naive diff driver
when kernel enable CONFIG_OVERLAY_FS_REDIRECT_DIR

Signed-off-by: Lei Jitang <leijitang@huawei.com>
2017-09-22 09:40:18 +08:00
Yong Tang
777d4a1bf4 Merge pull request #34861 from tklauser/fix-cstring-leaks
Fix CString memory leaks
2017-09-21 09:14:07 -07:00
Yong Tang
48cce22933 Merge pull request #34914 from euank/000003-percent
overlay2: fix faulty errcheck
2017-09-20 19:52:10 -07:00
Euan Kemp
639ab92f01 overlay2: fix faulty errcheck
The change in 7a7357dae1 inadvertently
changed the `defer` error code into a no-op. This restores its behavior
prior to that code change, and also introduces a little more error
logging.

Signed-off-by: Euan Kemp <euan.kemp@coreos.com>
2017-09-20 15:25:57 -07:00
Yong Tang
e40d5e665c Merge pull request #34863 from keloyang/close-pipe
Close pipe in overlay2 graphdriver
2017-09-20 09:37:15 -07:00
Yong Tang
3fa72d38ec Merge pull request #34721 from kinvolk/iaguis/add-missing-ecryptfs-string
Add missing eCryptfs translation to FsNames
2017-09-19 05:45:24 -07:00
Sebastiaan van Stijn
13e8a7a006 Merge pull request #34891 from Microsoft/jjh/fixcomment
LCOW: Fix comment in graphdriver code
2017-09-19 14:43:35 +02:00
John Howard
f9fc269c20 LCOW: Fix comment in graphdriver code
Signed-off-by: John Howard <jhoward@microsoft.com>
2017-09-18 19:52:55 -07:00
Shukui Yang
9f38923901 Close pipe if mountFrom failed.
Signed-off-by: Shukui Yang <yangshukui@huawei.com>
2017-09-19 01:25:39 +00:00
Yong Tang
65e88d996a Merge pull request #34759 from kolyshkin/gometalinter
Gometalinter fixups for non-x86
2017-09-18 13:44:15 -07:00
Iago López Galeiras
ddb31b4fdf Add missing eCryptfs translation to FsNames
It was causing the error message to be

    'overlay' is not supported over <unknown>

instead of

    'overlay' is not supported over ecryptfs

Signed-off-by: Iago López Galeiras <iago@kinvolk.io>
2017-09-18 19:06:13 +02:00
Kir Kolyshkin
b569f57890 overlay gd: fix build for 32-bit ARM
This commit reverts a hunk of commit 2f5f0af3f ("Add unconvert linter")
and adds a hint for unconvert linter to ignore excessive conversion as
it is required on 32-bit platforms (e.g. armhf).

The exact error on armhf is this:

	19:06:45 ---> Making bundle: dynbinary (in bundles/17.06.0-dev/dynbinary)
	19:06:48 Building: bundles/17.06.0-dev/dynbinary-daemon/dockerd-17.06.0-dev
	19:10:58 # github.com/docker/docker/daemon/graphdriver/overlay
	19:10:58 daemon/graphdriver/overlay/copy.go:161: cannot use stat.Atim.Sec (type int32) as type int64 in argument to time.Unix
	19:10:58 daemon/graphdriver/overlay/copy.go:161: cannot use stat.Atim.Nsec (type int32) as type int64 in argument to time.Unix
	19:10:58 daemon/graphdriver/overlay/copy.go:162: cannot use stat.Mtim.Sec (type int32) as type int64 in argument to time.Unix
	19:10:58 daemon/graphdriver/overlay/copy.go:162: cannot use stat.Mtim.Nsec (type int32) as type int64 in argument to time.Unix

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2017-09-17 22:04:31 -07:00
Kir Kolyshkin
c21245c920 devmapper: tell why xfs is not supported
Instead of providing a generic message listing all possible reasons
why xfs is not available on the system, let's be specific.

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2017-09-17 22:04:31 -07:00
Kir Kolyshkin
46833ee1c3 devmapper: show dmesg if mount fails
If mount fails, the reason might be right there in the kernel log ring buffer.
Let's include it in the error message, it might be of great help.

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2017-09-17 22:04:31 -07:00
Kir Kolyshkin
6b01bc5adb devmapper: don't create too new xfs
Since the update to Debian Stretch, devmapper unit test fails. One
reason is, the combination of somewhat old (less than 3.16) kernel and
relatively new xfsprogs leads to creating a filesystem which is not supported
by the kernel:

> [12206.467518] XFS (dm-1): Superblock has unknown read-only compatible features (0x1) enabled.
> [12206.472046] XFS (dm-1): Attempted to mount read-only compatible filesystem read-write.
> Filesystem can only be safely mounted read only.
> [12206.472079] XFS (dm-1): SB validate failed with error 22.

Ideally, that would be automatically and implicitly handled by xfsprogs.
In real life, we have to take care about it here. Sigh.

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2017-09-17 22:04:31 -07:00
Kir Kolyshkin
84f1c054e6 devmapper gd: disable for static build
Static build with devmapper is impossible now since libudev is required
and no static version of libudev is available (as static libraries are
not supported by systemd which udev is part of).

This should not hurt anyone as "[t]he primary user of static builds
is the Editions, and docker in docker via the containers, and none
of those use device mapper".

Also, since the need for static libdevmapper is gone, there is no need
to self-compile libdevmapper -- let's use the one from Debian Stretch.

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2017-09-17 22:04:31 -07:00
Tobias Klauser
593dbfd144 Fix CString memory leaks
Make sure to call C.free on C string allocated using C.CString in every
exit path.

C.CString allocates memory in the C heap using malloc. It is the callers
responsibility to free them. See
https://golang.org/cmd/cgo/#hdr-Go_references_to_C for details.

Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
2017-09-15 09:57:26 +02:00
Akash Gupta
7a7357dae1 LCOW: Implemented support for docker cp + build
This enables docker cp and ADD/COPY docker build support for LCOW.
Originally, the graphdriver.Get() interface returned a local path
to the container root filesystem. This does not work for LCOW, so
the Get() method now returns an interface that LCOW implements to
support copying to and from the container.

Signed-off-by: Akash Gupta <akagup@microsoft.com>
2017-09-14 12:07:52 -07:00
Kir Kolyshkin
21b2c278cc overlay gd: fix build for 32-bit ARM
This commit reverts a hunk of commit 2f5f0af3f ("Add unconvert linter")
and adds a hint for unconvert linter to ignore excessive conversion as
it is required on 32-bit platforms (e.g. armhf).

The exact error on armhf is this:

	19:06:45 ---> Making bundle: dynbinary (in bundles/17.06.0-dev/dynbinary)
	19:06:48 Building: bundles/17.06.0-dev/dynbinary-daemon/dockerd-17.06.0-dev
	19:10:58 # github.com/docker/docker/daemon/graphdriver/overlay
	19:10:58 daemon/graphdriver/overlay/copy.go:161: cannot use stat.Atim.Sec (type int32) as type int64 in argument to time.Unix
	19:10:58 daemon/graphdriver/overlay/copy.go:161: cannot use stat.Atim.Nsec (type int32) as type int64 in argument to time.Unix
	19:10:58 daemon/graphdriver/overlay/copy.go:162: cannot use stat.Mtim.Sec (type int32) as type int64 in argument to time.Unix
	19:10:58 daemon/graphdriver/overlay/copy.go:162: cannot use stat.Mtim.Nsec (type int32) as type int64 in argument to time.Unix

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2017-09-12 18:44:55 -07:00
Daniel Nephin
f7f101d57e Add gosimple linter
Update gometalinter

Signed-off-by: Daniel Nephin <dnephin@docker.com>
2017-09-12 12:09:59 -04:00
wangguoliang
94cefa2145 Optimize some wrong usage and spelling
Signed-off-by: wgliang <liangcszzu@163.com>
2017-09-07 09:44:08 +08:00
Aleksa Sarai
92e45b81e0
devicemapper: remove container rootfs mountPath after umount
libdm currently has a fairly substantial DoS bug that makes certain
operations fail on a libdm device if the device has active references
through mountpoints. This is a significant problem with the advent of
mount namespaces and MS_PRIVATE, and can cause certain --volume mounts
to cause libdm to no longer be able to remove containers:

  % docker run -d --name testA busybox top
  % docker run -d --name testB -v /var/lib/docker:/docker busybox top
  % docker rm -f testA
  [fails on libdm with dm_task_run errors.]

This also solves the problem of unprivileged users being able to DoS
docker by using unprivileged mount namespaces to preseve mounts that
Docker has dropped.

Signed-off-by: Aleksa Sarai <asarai@suse.de>
2017-09-06 20:11:01 +10:00
Daniel Nephin
2f5f0af3fd Add unconvert linter
Signed-off-by: Daniel Nephin <dnephin@docker.com>
2017-08-24 15:08:31 -04:00
Brian Goff
0a98025d4b Add more detailed logging to aufs init
Addresses some comments on 276b44608b

Signed-off-by: Brian Goff <cpuguy83@gmail.com>
2017-08-22 14:19:03 -04:00
Victor Vieux
bbcdc7df34 Merge pull request #34587 from cpuguy83/aufs_rm_errors
Fix error removing diff path
2017-08-22 11:02:30 -07:00
Brian Goff
276b44608b Fix error removing diff path
In d42dbdd3d4 the code was re-arranged to
better report errors, and ignore non-errors.
In doing so we removed a deferred remove of the AUFS diff path, but did
not replace it with a non-deferred one.

This fixes the issue and makes the code a bit more readable.

Signed-off-by: Brian Goff <cpuguy83@gmail.com>
2017-08-22 12:51:58 -04:00
Daniel Nephin
62c1f0ef41 Add deadcode linter
Signed-off-by: Daniel Nephin <dnephin@docker.com>
2017-08-21 18:18:50 -04:00
Daniel Nephin
372670b507 Add goimports to linters.
Signed-off-by: Daniel Nephin <dnephin@docker.com>
2017-08-21 18:15:08 -04:00
Daniel Nephin
9b47b7b151 Fix golint errors.
Signed-off-by: Daniel Nephin <dnephin@docker.com>
2017-08-18 14:23:44 -04:00
Kir Kolyshkin
58a453f3f0 devmapper autosetup: add check for thin_check
I was able to successfully use device mapper autoconfig feature
(commit 5ef07d79c) but it stopped working after a reboot.

Investigation shown that the dm device was not activated because of
a missing binary, that is not used during initial setup, but every
following time. Here's an error shown when trying to manually activate
the device:

> kir@kd:~/go/src/github.com/docker/docker$ sudo lvchange -a y /dev/docker/thinpool
> /usr/sbin/thin_check: execvp failed: No such file or directory
> Check of pool docker/thinpool failed (status:2). Manual repair required!

Surely, there is no solution to this other than to have a package that
provides the thin_check binary installed beforehand. Due to the fact
the issue revealed itself way later than DM setup was performed, it was
somewhat harder to investigate.

With this in mind, let's check for binary presense before setting up DM,
refusing to proceed if the binary is not there, saving a user from later
frustration.

While at it, eliminate repeated binary checking code. The downside is
that the binary lookup is happening more than once now -- I think the
clarity of code overweights this minor de-optimization.

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2017-08-14 13:25:28 +03:00
Kir Kolyshkin
8b7bd58869 devmapper: refer to dockerd man page
...not the docker one.

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2017-08-14 10:09:58 +03:00
Kir Kolyshkin
6ca20ec771 devmapper autoconfig: add mkdir
I tried using dm.directlvm_device but it ended up with the following
error:

> Error starting daemon: error initializing graphdriver: error
> writing docker thinp autoextend profile: open
> /etc/lvm/profile/docker-thinpool.profile: no such file or directory

The reason is /etc/lvm/profile directory does not exist. I think it is
better to try creating it beforehand.

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2017-08-14 10:09:34 +03:00
Sebastiaan van Stijn
2e38c07814 Merge pull request #34430 from AkihiroSuda/promote-overlay2
graphdriver: promote overlay2 over aufs
2017-08-09 21:41:36 +02:00
John Howard
ee0587a45d jhoward/opengcs --> Microsoft/opengcs
Signed-off-by: John Howard <jhoward@microsoft.com>
2017-08-08 14:43:43 -07:00
Akihiro Suda
fd6ffc2337 graphdriver: promote overlay2 over aufs
Signed-off-by: Akihiro Suda <suda.akihiro@lab.ntt.co.jp>
2017-08-08 10:17:37 +00:00
Sebastiaan van Stijn
d4f6db83c2 Merge pull request #34396 from Microsoft/jjh/movescratch
LCOW: Move toolsScratchPath to /tmp
2017-08-05 11:37:15 +01:00
John Howard
993f407287 LCOW: Move toolsScratchPath to /tmp
Signed-off-by: John Howard <jhoward@microsoft.com>
2017-08-03 15:48:53 -07:00
John Howard
8c279ef3ad LCOW: Graphdriver dynamic sandbox management
Signed-off-by: John Howard <jhoward@microsoft.com>

This changes the graphdriver to perform dynamic sandbox management.
Previously, as a temporary 'hack', the service VM had a prebuilt
sandbox in it. With this change, management is under the control
of the client (docker) and executes a mkfs.ext4 on it. This enables
sandboxes of non-default sizes too (a TODO previously in the code).

It also addresses https://github.com/moby/moby/pull/33969#discussion_r127287887

Requires:
- go-winio: v0.4.3
- opengcs:  v0.0.12
- hcsshim:  v0.6.x
2017-08-03 09:06:45 -07:00
John Howard
45e2dd123b Revendor microsoft/go-winio @ v0.4.4
Signed-off-by: John Howard <jhoward@microsoft.com>
2017-08-03 09:06:26 -07:00
John Howard
8af4db6f00 Merge pull request #34272 from dmcgowan/update-logrus
Update logrus to v1.0.1 (Sirupsen -> sirupsen)
2017-08-01 18:53:33 -07:00
Kir Kolyshkin
aab2450e25 graphdriver/devmapper: clarify a message
Make sure user understands this is about the in-kernel driver
(not the dockerd driver or smth).

While at it, amend the comment as well.

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2017-07-31 20:01:02 -07:00
Derek McGowan
1009e6a40b
Update logrus to v1.0.1
Fixes case sensitivity issue

Signed-off-by: Derek McGowan <derek@mcgstyle.net>
2017-07-31 13:16:46 -07:00
Tobias Klauser
01f70b028e Switch Stat syscalls to x/sys/unix
Switch some more usage of the Stat function and the Stat_t type from the
syscall package to golang.org/x/sys. Those were missing in PR #33399.

Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
2017-07-27 10:09:02 +02:00
Sebastiaan van Stijn
67eeb0490d Merge pull request #33960 from cpuguy83/ignore_not_exist_err
Fix error handling with not-exist errors on remove
2017-07-21 13:52:27 +02:00
Brian Goff
d42dbdd3d4 Fix error handling with not-exist errors on remove
Specifically, none of the graphdrivers are supposed to return a
not-exist type of error on remove (or at least that's how they are
currently handled).

Found that AUFS still had one case where a not-exist error could escape,
when checking if the directory is mounted we call a `Statfs` on the
path.

This fixes AUFS to not return an error in this case, but also
double-checks at the daemon level on layer remove that the error is not
a `not-exist` type of error.

Signed-off-by: Brian Goff <cpuguy83@gmail.com>
2017-07-20 12:26:27 -04:00
Sebastiaan van Stijn
f22cecf929 Merge pull request #33969 from Microsoft/jjh/lifetime
LCOW: Service VM lifetime changes
2017-07-13 15:51:21 -07:00
John Howard
76b0d4819a LCOW: Service VM lifetime changes
Signed-off-by: John Howard <jhoward@microsoft.com>

This changes the LCOW driver to support both global SVM lifetime and
per-instance lifetime. It also corrects the scratch implementation.
2017-07-13 11:09:43 -07:00
Sebastiaan van Stijn
00b218216d Merge pull request #33845 from cyphar/devicemapper-show-me-your-logs
devicemapper: rework logging and add --storage-opt dm.libdm_log_level
2017-07-12 17:46:14 -07:00
Sebastiaan van Stijn
e04dbe5ac2 Merge pull request #33877 from rhvgoyal/sync-removal
devicemapper: Wait for device removal if deferredRemoval=true and deferredDeletion=…
2017-07-12 17:35:45 -07:00
Christopher Jones
069fdc8a08
[project] change syscall to /x/sys/unix|windows
Changes most references of syscall to golang.org/x/sys/
Ones aren't changes include, Errno, Signal and SysProcAttr
as they haven't been implemented in /x/sys/.

Signed-off-by: Christopher Jones <tophj@linux.vnet.ibm.com>

[s390x] switch utsname from unsigned to signed

per 33267e036f
char in s390x in the /x/sys/unix package is now signed, so
change the buildtags

Signed-off-by: Christopher Jones <tophj@linux.vnet.ibm.com>
2017-07-11 08:00:32 -04:00
Josh Soref
39bcaee47b
Spelling fixes
* additional
* ambiguous
* anonymous
* anything
* application
* because
* before
* building
* capabilities
* circumstances
* commit
* committer
* compresses
* concatenated
* config
* container
* container's
* current
* definition
* delimiter
* disassociates
* discovery
* distributed
* doesnotexist
* downloads
* duplicates
* either
* enhancing
* enumerate
* escapable
* exactly
* expect
* expectations
* expected
* explicitly
* false
* filesystem
* following
* forbidden
* git with
* healthcheck
* ignore
* independent
* inheritance
* investigating
* irrelevant
* it
* logging
* looking
* membership
* mimic
* minimum
* modify
* mountpoint
* multiline
* notifier
* outputting
* outside
* overridden
* override
* parsable
* plugins
* precedence
* propagation
* provided
* provides
* registries
* repositories
* returning
* settings
* should
* signals
* someone
* something
* specifically
* successfully
* synchronize
* they've
* thinking
* uninitialized
* unintentionally
* unmarshaling
* unnamed
* unreferenced
* verify

Signed-off-by: Josh Soref <jsoref@gmail.com>
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2017-07-03 13:13:09 -07:00
Aleksa Sarai
198f83bba1
devicemapper: add --storage-opt dm.libdm_log_level=X option
Because we use our own logging callbacks in order to use libdm
effectively, it is quite difficult to debug complicated devicemapper
issues (because any warnings or notices from libdm are muted by our own
callback function). e07d3cd9a ("devmapper: Fix libdm logging") further
reduced the ability of this debugging by only allowing _LOG_FATAL errors
to be passed to the output.

Unfortunately libdm is very chatty, so in order to avoid making the logs
even more crowded, add a dm.libdm_log_level storage option that allows
people who are debugging the lovely world of libdm to be able to dive in
without recompiling binaries.

The valid values of dm.libdm_log_level map directly to the libdm logging
levels, and are in the range [2,7] as of the time of writing with 7
being _LOG_DEBUG and 2 being _LOG_FATAL. The default is _LOG_FATAL.

Signed-off-by: Aleksa Sarai <asarai@suse.de>
2017-07-04 02:04:26 +10:00
Aleksa Sarai
cfd39e8d6d
devicemapper: change LogInit and move all callbacks to pkg
LogInit used to act as a manual way of registering the *necessary*
pkg/devicemapper logging callbacks. In addition, it was used to split up
the logic of pkg/devicemapper into daemon/graphdriver/devmapper (such
that some things were logged from libdm).

The manual aspect of this API was completely non-sensical and was just
begging for incorrect usage of pkg/devicemapper, so remove that semantic
and always register our own libdm callbacks.

In addition, recombine the split out logging callbacks into
pkg/devicemapper so that the default logger is local to the library and
also shown to be the recommended logger. This makes the code
substantially easier to read. Also the new DefaultLogger now has
configurable upper-bound for the log level, which allows for dynamically
changing the logging level.

Signed-off-by: Aleksa Sarai <asarai@suse.de>
2017-07-04 02:04:26 +10:00
Vivek Goyal
36cb6efebc Wait for device removal if deferredRemoval=true and deferredDeletion=false
There have been some cases where umount, a device can be busy for a very
short duration. Maybe its udev rules, or maybe it is runc related races
or probably it is something else. We don't know yet.

If deferred removal is enabled but deferred deletion is not, then for the
case of "docker run -ti --rm fedora bash", a container will exit, device
will be deferred removed and then immediately a call will come to delete
the device. It is possible that deletion will fail if device was busy
at that time.

A device can't be deleted if it can't be removed/deactivated first. There
is only one exception and that is when deferred deletion is on. In that
case graph driver will keep track of deleted device and try to delete it
later and return success to caller.

Always make sure that device deactivation is synchronous when device is
being deleted (except the case when deferred deletion is enabled).

This should also take care of small races when device is busy for a short
duration and it is being deleted.

Signed-off-by: Vivek Goyal <vgoyal@redhat.com>
2017-06-30 14:27:26 -04:00
Sebastiaan van Stijn
8b29ba59cc Merge pull request #33809 from Microsoft/jjh/svmdedicatedscratch
LCOW: Dedicated scratch space for service VM utilities
2017-06-28 11:06:46 -07:00
John Howard
950d472c9c Merge pull request #33826 from Microsoft/jjh/lcownits
LCOW: Fix nits from 33241
2017-06-27 22:56:38 -07:00
John Howard
4ec9766a27 LCOW: Fix nits from 33241
Signed-off-by: John Howard <jhoward@microsoft.com>
2017-06-27 11:59:49 -07:00
John Howard
d1d649c891 LCOW: Dedicated scratch space for global service VM
Signed-off-by: John Howard <jhoward@microsoft.com>
2017-06-27 10:55:16 -07:00
Dhawal Yogesh Bhanushali
a63d5bc035 Add overlay2.size daemon storage-opt
This commit adds the overlay2.size option to the daemon daemon
storage opts.

The user can override this option by the "docker run --storage-opt"
options.

Signed-off-by: Dhawal Yogesh Bhanushali <dbhanushali@vmware.com>
2017-06-27 01:07:48 -07:00
Sebastiaan van Stijn
5b54e78947 Merge pull request #33698 from cpuguy83/dm_deferred_delete_default
Enable dm deferred_* with version check
2017-06-23 19:30:05 -07:00
John Stephens
930e689668 Merge pull request #33241 from Microsoft/jjh/multi-layerstore
LCOW: Support most operations excluding remote filesystem
2017-06-21 15:45:23 -07:00
John Howard
bdabc76a53 LCOW: Coherency - ensure windowsfilter driver is not used
Signed-off-by: John Howard <jhoward@microsoft.com>
2017-06-20 19:50:13 -07:00
John Howard
ed10ac6ee9 LCOW: Create layer folders with correct ACL
Signed-off-by: John Howard <jhoward@microsoft.com>
2017-06-20 19:50:12 -07:00
John Howard
3aa4a00715 LCOW: Move daemon stores to per platform
Signed-off-by: John Howard <jhoward@microsoft.com>
2017-06-20 19:49:52 -07:00
John Howard
ed4d2aa981 LCOW: Graphdriver
Signed-off-by: John Howard <jhoward@microsoft.com>

Adds the graphdriver for Linux containers on Windows
2017-06-20 19:49:24 -07:00
Brian Goff
226bf3e0d9 Merge pull request #33587 from bergwolf/aufs
fix aufs mount option length calculation
2017-06-20 15:51:42 -07:00
Brian Goff
0dc1a80565 Enable dm deferred_* with version check
This enables deferred device deletion/removal by default if the driver
version in the kernel is new enough to support the feature.

Signed-off-by: Brian Goff <cpuguy83@gmail.com>
2017-06-15 13:13:42 -04:00
Brian Goff
bccebdac18 Merge pull request #32468 from coolljt0725/clean_thin
devicemapper: remove thin pool if 'initDevmapper' failed
2017-06-13 07:34:15 -05:00
Lei Jitang
f65fa1f115 Use lazy umount on Put for overlay2 and overlay
we see a lot of
```
level=debug msg="Failed to unmount a03b1bb6f569421857e5407d73d89451f92724674caa56bfc2170de7e585a00b-init overlay: device or resource busy"
```
in daemon logs and there is a lot of mountpoint leftover.
This cause failed to remove container.

Signed-off-by: Lei Jitang <leijitang@huawei.com>
2017-06-12 09:07:25 -04:00
Peng Tao
1a6bf8248a fix aufs mount option length calculation
We add ",dirperm1" but only increase length by len("dirperm1").

Signed-off-by: Peng Tao <bergwolf@gmail.com>
2017-06-08 19:21:52 +08:00
Daniel Nephin
93fbdb69ac Remove error return from RootPair
There is no case which would resolve in this error. The root user always exists, and if the id maps are empty, the default value of 0 is correct.

Signed-off-by: Daniel Nephin <dnephin@docker.com>
2017-06-07 11:45:33 -04:00
Daniel Nephin
acdbc285e2 Fix vfs unit test and port VFS to the new IDMappings
The test was failing because TarOptions was using a non-pointer for
ChownOpts, which meant the check for nil was never true, and
createTarFile was never using the hdr.UID/GID

Signed-off-by: Daniel Nephin <dnephin@docker.com>
2017-06-07 11:44:34 -04:00
Daniel Nephin
967ef7e6d2 Remove unused functions from archive.
Signed-off-by: Daniel Nephin <dnephin@docker.com>
2017-06-07 11:44:33 -04:00
Yong Tang
16328cc207 Persist the quota size for btrfs so that daemon restart keeps quota
This commit is an extension of fix for 29325 based on the review comment.
In this commit, the quota size for btrfs is kept in `/var/lib/docker/btrfs/quotas`
so that a daemon restart keeps quota.

Signed-off-by: Yong Tang <yong.tang.github@outlook.com>
2017-06-01 21:15:51 -07:00
Yong Tang
e907c6418a Remove btrfs quota groups after containers destroyed
This fix tries to address the issue raised in 29325 where
btrfs quota groups are not clean up even after containers
have been destroyed.

The reason for the issue is that btrfs quota groups have
to be explicitly destroyed. This fix fixes this issue.

This fix is tested manually in Ubuntu 16.04,
with steps specified in 29325.

This fix fixes 29325.

Signed-off-by: Yong Tang <yong.tang.github@outlook.com>
2017-06-01 20:24:26 -07:00
Derek McGowan
f64a4ad008
Support overlay2 on btrfs
OverlayFS is supported on top of btrfs as of Linux Kernel 4.7.
Skip the hard enforcement when on kernel 4.7 or newer and
respect the kernel check override flag on older kernels.
https://btrfs.wiki.kernel.org/index.php/Changelog#By_feature

Signed-off-by: Derek McGowan <derek@mcgstyle.net>
2017-05-18 15:26:03 -07:00
Brian Goff
54dcbab25e Do not remove containers from memory on error
Before this, if `forceRemove` is set the container data will be removed
no matter what, including if there are issues with removing container
on-disk state (rw layer, container root).

In practice this causes a lot of issues with leaked data sitting on
disk that users are not able to clean up themselves.
This is particularly a problem while the `EBUSY` errors on remove are so
prevalent. So for now let's not keep this behavior.

Signed-off-by: Brian Goff <cpuguy83@gmail.com>
2017-05-05 17:02:04 -04:00
Brian Goff
05ad14fc1b Merge pull request #31104 from cpuguy83/dm_lvmsetup
Add option to auto-configure blkdev for devmapper
2017-05-05 07:35:24 -04:00
Brian Goff
5ef07d79c4 Add option to auto-configure blkdev for devmapper
Instead of forcing users to manually configure a block device to use
with devmapper, this gives the user the option to let the devmapper
driver configure a device for them.

Adds several new options to the devmapper storage-opts:

- dm.directlvm_device="" - path to the block device to configure for
  direct-lvm
- dm.thinp_percent=95 - sets the percentage of space to use for
  storage from the passed in block device
- dm.thinp_metapercent=1 - sets the percentage of space to for metadata
  storage from the passed in block device
- dm.thinp_autoextend_threshold=80 - sets the threshold for when `lvm`
  should automatically extend the thin pool as a percentage of the total
  storage space
- dm.thinp_autoextend_percent=20 - sets the percentage to increase the
  thin pool by when an autoextend is triggered.

Defaults are taken from
[here](https://docs.docker.com/engine/userguide/storagedriver/device-mapper-driver/#/configure-direct-lvm-mode-for-production)

The only option that is required is `dm.directlvm_device` for docker to
set everything up.

Changes to these settings are not currently supported and will error
out.
Future work could support allowing changes to these values.

Signed-off-by: Brian Goff <cpuguy83@gmail.com>
2017-05-03 13:49:15 -04:00
Vincent Demeester
4219156a62 Merge pull request #32687 from runcom/oci-selinux
Switch to using opencontainers/selinux for selinux bindings
2017-04-29 19:05:32 +02:00
Antonio Murdaca
abbbf91498
Switch to using opencontainers/selinux for selinux bindings
Signed-off-by: Antonio Murdaca <runcom@redhat.com>
2017-04-24 21:29:47 +02:00
Darren Stahl
5e4e357f6e Windows: Do not attempt to clean empty windowsfilter folder
Signed-off-by: Darren Stahl <darst@microsoft.com>
2017-04-17 13:10:15 -07:00
Victor Vieux
a6746e6ca5 Merge pull request #31954 from darrenstahlmsft/GraphdriverReference
Windows: Fix reference counting in graphdriver
2017-04-10 20:23:15 -07:00
Darren Stahl
7fab9b8a60 Windows: Fix reference counting in graphdriver
Signed-off-by: Darren Stahl <darst@microsoft.com>
2017-04-10 17:13:17 -07:00
Lei Jitang
ea22d7ab91 devicemapper: remove thin pool if 'initDevmapper' failed
if initDevmapper failed after creating thin-pool, the thin-pool will not be removed,
this would cause we can't use the same lvm to create another thin-pool.

Signed-off-by: Lei Jitang <leijitang@huawei.com>
2017-04-10 13:11:39 -04:00
Alfred Landrum
aa96c3176b
Let graphdrivers declare diff stream fidelity
This allows graphdrivers to declare that they can reproduce the original
diff stream for a layer. If they do so, the layer store will not use
tar-split processing, but will still verify the digest on layer export.
This makes it easier to experiment with non-default diff formats.

Signed-off-by: Alfred Landrum <alfred.landrum@docker.com>
2017-03-31 08:32:00 -07:00
John Howard (VM)
9910b9a7f0 Windows: graph cleanup '-removing'
Signed-off-by: John Howard (VM) <jhoward@ntdev.microsoft.com>
2017-03-20 09:15:27 -07:00
Kenfe-Mickael Laventure
eac66b67be Remove aufs debugEBusy()
Since it was introduced no reports were made and lsof seems to cause
issues on some systems.

Signed-off-by: Kenfe-Mickael Laventure <mickael.laventure@gmail.com>
2017-03-09 14:35:13 -08:00
Sebastiaan van Stijn
57fd478169 Merge pull request #31083 from xulike666/fight-for-readability
fix some typos from module contrib to man
2017-03-03 15:13:01 +01:00
Brian Goff
55b955d9ff Merge pull request #31409 from yuexiao-wang/fix-version
'docker daemon' deprecation message doesn't use the new version
2017-03-02 22:02:09 -05:00
yuexiao-wang
5a9cee7bb5 'docker daemon' deprecation message doesn't use the new versioning scheme
Signed-off-by: yuexiao-wang <wang.yuexiao@zte.com.cn>
2017-03-03 17:26:49 +08:00
Vincent Demeester
3e561e4a84 Merge pull request #31356 from coolljt0725/fix_suspend
devicemapper: Fix suspend a removed device
2017-03-02 10:11:48 +01:00
Lei Jitang
6e25bb2ed6 devicemapper: fix suspend removed device
when doing devices.cancelDeferredRemoval, the device could have been removed
and return ErrEnxio, but it continue to check if it is need to do suspend.
doSuspend := devinfo != nil && devinfo.Exists != 0 uses a devinfo which is
get before devices.cancelDeferredRemoval(baseInfo), it is outdate, the device
has been removed and there is no need to do suspend. If do suspend it will return
devicemapper: Error running deviceSuspend dm_task_run failed.

Signed-off-by: Lei Jitang <leijitang@huawei.com>
2017-03-01 21:58:14 +08:00
Vincent Demeester
f7819fcb25
Refactor cpu-realtime file creation to remove duplication
Signed-off-by: Vincent Demeester <vincent@sbr.pm>
2017-02-28 11:12:06 +01:00
Vincent Demeester
2028d8698d
Reduce duplication in graphdriver
Removes some duplication in counter.go and proxy.go

Signed-off-by: Vincent Demeester <vincent@sbr.pm>
2017-02-28 11:12:02 +01:00
Akihiro Suda
a6576b8a2b Merge pull request #31212 from fate-grand-order/fixed
use t.Fatal() to output the err message and fix typo
2017-02-27 12:26:35 +09:00
fate-grand-order
2a8d6368d4 use t.Fatal() to output the err message where the values used for formatting
text does not appear to contain a placeholder

Signed-off-by: Helen Xie <chenjg@harmonycloud.cn>
2017-02-23 10:16:22 +08:00
Alexander Morozov
1ad165dba1 Merge pull request #31136 from tonistiigi/more-locks
Add more locking to storage drivers
2017-02-21 07:39:33 -08:00
Aaron.L.Xu
e0577d5fe8 fix some typos from module contrib to man
Signed-off-by: Aaron.L.Xu <likexu@harmonycloud.cn>
2017-02-18 10:08:55 +08:00
Victor Vieux
7761c69e23 Merge pull request #31055 from Microsoft/jjh/fix30278
Windows: Retry workaround for RS1/RS2 compute system enumeration
2017-02-17 16:53:16 -08:00
Tonis Tiigi
fc1cf1911b Add more locking to storage drivers
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2017-02-17 15:50:25 -08:00
Vincent Demeester
146bc072a9 Merge pull request #31069 from tonistiigi/fix-overlay2-unmount
overlay2: fix unmounting layer without merge dir
2017-02-17 10:21:47 +01:00
Tonis Tiigi
e9864cc0ec Update storage driver options link
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2017-02-16 18:32:17 -08:00
Tonis Tiigi
e1af6c8a57 overlay2: fix unmounting layer without merge dir
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2017-02-15 17:58:12 -08:00
John Howard
83a2db2097 Windows: Retry loop to fix HCS race condition enumerating containers
Signed-off-by: John Howard <jhoward@microsoft.com>

This fixes https://github.com/docker/docker/issues/30278 where
there is a race condition in HCS for RS1 and RS2 builds, and enumeration
of compute systems can return access is denied if a silo is being
torn down in the kernel while HCS is attempting to enumerate them.
2017-02-15 11:16:24 -08:00
Alfred Landrum
874a502b1d
Fix RefCounter count return
Signed-off-by: Alfred Landrum <alfred.landrum@docker.com>
2017-02-03 08:47:55 -08:00
Brian Goff
93e322f5be Merge pull request #29835 from yongtang/29810-btrfs-rescan
Run btrfs rescan only if userDiskQuota is enabled
2017-01-26 15:55:51 -08:00
Aaron Lehmann
062f2a3eae Merge pull request #30139 from Microsoft/jjh/sequential
Windows: Use sequential file access
2017-01-23 12:46:06 -08:00
John Howard
c98e77c77c Windows: Use sequential file access
Signed-off-by: John Howard <jhoward@microsoft.com>
2017-01-23 10:25:36 -08:00
Aaron.L.Xu
40af569164 fix typo
fix typo I found AMAP in integration-cli/*

fix typo mentioned by Allencloud

Signed-off-by: Aaron.L.Xu <likexu@harmonycloud.cn>
2017-01-19 15:52:28 +08:00
Tõnis Tiigi
27695cd751 Merge pull request #27903 from kim0/master
zfs: expose mountpoint/dataset on inspection
2017-01-12 11:28:07 -08:00
Vincent Demeester
e880120fe2 Merge pull request #28500 from rhvgoyal/remove-unused-param
devmapper: get rid of unused device id argument in unregisterDevice()
2017-01-12 18:02:00 +01:00
Vincent Demeester
9c96768eae Merge pull request #29564 from aaronlehmann/getter-types
plugingetter: Avoid all caps for constant declarations
2017-01-10 09:35:19 +01:00
Antonio Murdaca
8bcbc6711f
devmapper: fixup error formatting
Signed-off-by: Antonio Murdaca <runcom@redhat.com>
2017-01-09 16:58:09 +01:00
Vivek Goyal
39bdf601f6 devmapper: Return device id in error message
I often get complains that container removal failed and users got following
error message.

"Driver devicemapper failed to remove root filesystem 18a69ba82aaf7a039ce7d44156215012d703001643079775190ac7dd6c6acf56:Device is Busy"

This error message talks about container id but does not give any info
about which particular device id is busy. Most likely device is mounted
in some other mount namespace and if one knows the device id, they
can try to do some debugging figuring which process and which mount
namespace is keeping the device busy and how did we reach that stage.

Without that information, it becomes almost impossible to debug the
problem.

So to improve the debuggability, when device removal fails, also return
device id in error message. Now new message looks as follows.

"Driver devicemapper failed to remove root filesystem 18a69ba82aaf7a039ce7d44156215012d703001643079775190ac7dd6c6acf56: Failed to remove device dbc15bdf9994a17c613d8ef9e924f3cffbf67f91e4f709295c901ad628377991:Device is Busy"

Signed-off-by: Vivek Goyal <vgoyal@redhat.com>
2017-01-05 15:02:21 -05:00
Yong Tang
b36e613d9f Run btrfs rescan only if userDiskQuota is enabled
This fix tries to address the issue raised in 29810
where btrfs subvolume removal failed when docker
is in an unprivileged lxc container. The failure
was caused by `Failed to rescan btrfs quota` with
`operation not permitted`.

However, if disk quota is not enabled, there is no
need to run a btrfs rescan at the first place.

This fix checks for `quotaEnabled` and only run btrfs
rescan if `quotaEnabled` is true.

This fix fixes 29810.

Signed-off-by: Yong Tang <yong.tang.github@outlook.com>
2017-01-05 05:18:11 -08:00
Aaron Lehmann
428600108c plugingetter: Avoid all caps for constant declarations
Go style calls for mixed caps instead of all caps:
https://golang.org/doc/effective_go.html#mixed-caps

Change LOOKUP, ACQUIRE, and RELEASE to Lookup, Acquire, and Release.

This vendors a fork of libnetwork for now, to deal with a cyclic
dependency issue. The change will be upstream to libnetwork once this is
merged.

Signed-off-by: Aaron Lehmann <aaron.lehmann@docker.com>
2017-01-04 10:19:04 -08:00
Vincent Demeester
6129e6ce3e Merge pull request #29697 from yuexiao-wang/fix-docker-daemon
Update docker daemon to dockerd
2017-01-04 11:55:38 +01:00
yuexiao-wang
62cc802f61 Update docker daemon to dockerd
Signed-off-by: yuexiao-wang <wang.yuexiao@zte.com.cn>
2016-12-27 17:32:15 +08:00
Brian Goff
677fa03654 Moves graphdriver plugn docs out of experimental
Also updates some of the structures being sent so plugins are getting
all the new options.

Signed-off-by: Brian Goff <cpuguy83@gmail.com>
2016-12-22 15:30:25 -05:00
Jie Luo
ea2dd4b5d0 duplicated the
Signed-off-by: Jie Luo <luo612@zju.edu.cn>

typo

Signed-off-by: Jie Luo <luo612@zju.edu.cn>

fix some typos

Signed-off-by: Jie Luo <luo612@zju.edu.cn>
2016-12-21 20:16:19 +08:00
Brian Goff
500210475f Make graphdriver plugin use plugin BasePath
Also enables `PropagatedMount` for graphdrivers.

Signed-off-by: Brian Goff <cpuguy83@gmail.com>
2016-12-15 16:22:13 -05:00
unclejack
3a42518042 daemon: return directly without ifs where possible
Signed-off-by: Cristian Staretu <cristian.staretu@gmail.com>
2016-12-14 22:36:58 +02:00
Brian Goff
f29bbd16f5 Refcount graphdriver plugins properly
Adds 2 new methods to v2 plugin `Acquire` and `Release` which allow
refcounting directly at the plugin level instead of just the store.
Since a graphdriver is initialized exactly once, and is really managed
by a separate object, it didn't really seem right to call
`getter.Get()` to refcount graphdriver plugins.
On shutdown it was particularly weird where we'd either need to keep a
driver reference in daemon, or keep a reference to the pluggin getter in
the layer store, and even then still store extra details on if the
graphdriver is a plugin or not.

Instead the plugin proxy itself will handle calling the neccessary
refcounting methods directly on the plugin object.

Also adds a new interface in `plugingetter` to account for these new
functions which are not going to be implemented by v1 plugins.

Changes terms `plugingetter.CREATE` and `plugingetter.REMOVE` to
`ACQUIRE` and `RELEASE` respectively, which seems to be better
adjectives for what we're doing.

Signed-off-by: Brian Goff <cpuguy83@gmail.com>
2016-12-09 19:46:28 -05:00
Ahmed Kamal
4addda3f07 zfs: expose mountpoint/dataset on inspection
Signed-off-by: Ahmed Kamal <email.ahmedkamal@googlemail.com>
2016-11-30 23:20:42 +02:00
Tõnis Tiigi
5c1826ec4d Merge pull request #28683 from darrenstahlmsft/SystemDLL
Swap usage of LazyDLL and LoadDLL to LazySystemDLL
2016-11-22 16:58:30 -08:00
Darren Stahl
22c83c567f Swap usage of LazyDLL and LoadDLL to LazySystemDLL.
Signed-off-by: Darren Stahl <darst@microsoft.com>
2016-11-22 14:57:11 -08:00
yupeng
1e65db4206 First header should be a top level header
Signed-off-by: yupeng <yu.peng36@zte.com.cn>
2016-11-22 09:33:21 +08:00
Doug Davis
96f50e9b70 Merge pull request #28611 from vieux/fix_golint
fix a few golint errors
2016-11-19 07:16:44 -05:00
Victor Vieux
9c559e6d0b fix a few golint errors
Signed-off-by: Victor Vieux <victorvieux@gmail.com>
2016-11-18 18:32:02 -08:00
Brian Goff
020b051dfb Allow graphdriver plugins to use v2
Currently the plugin initialization is too late for a loaded v2 plugin
to be usable as a graph driver.

This moves the initialization up before we create the graph driver.

Signed-off-by: Brian Goff <cpuguy83@gmail.com>
2016-11-18 17:23:59 -05:00
Vivek Goyal
288f933ed5 devmapper: get rid of unused device id argument in unregisterDevice()
There is no need to populate device id during unregisterDevice(). Nobody
makes use of this information. We just need to remove file associated
with device and that file is looked up using the hash and not the
device id which is used for thin pool operations.

So get rid of device id argument to unregisterDevice().

Signed-off-by: Vivek Goyal <vgoyal@redhat.com>
2016-11-16 16:16:46 -05:00
wefine
f78f7de96a fix t.Errorf to t.Error in serveral _test.go
Signed-off-by: wefine <wang.xiaoren@zte.com.cn>
2016-11-14 17:54:43 +08:00
Tõnis Tiigi
d54f4472fd Merge pull request #28229 from darrenstahlmsft/FixUnexpectedResult
Fix failure to get containers when deleting a layer
2016-11-10 17:10:05 -08:00
Vincent Demeester
f3f9b3dac9 Merge pull request #28264 from dmcgowan/fix-overlay2-naivediff-unittest
Skip overlay2 diff tests when using naivediff
2016-11-11 00:24:06 +01:00
Darren Stahl
d4095a5902 Fix failure to get containers when deleting a layer
Signed-off-by: Darren Stahl <darst@microsoft.com>
2016-11-10 14:07:11 -08:00
Derek McGowan
5a1b557281
Skip overlay2 diff tests when using naivediff
Naivediff fails when layers are created directly on top of
each other. Other graphdrivers which use naivediff already
skip these tests. Until naivediff is fixed, skip with overlay2
when running tests on a kernel which causes naivediff fallback.
Fix applydiff to never use the naivediff size when not applying
changes with naivediff.

Signed-off-by: Derek McGowan <derek@mcgstyle.net> (github: dmcgowan)
2016-11-10 13:52:22 -08:00