Commit Graph

289 Commits

Author SHA1 Message Date
c03bd3f5e9 Merge pull request #32468 from coolljt0725/clean_thin
devicemapper: remove thin pool if 'initDevmapper' failed
Upstream-commit: bccebdac1806d39848c6b51e9fea757e77bc2dad
Component: engine
2017-06-13 07:34:15 -05:00
03637cd7aa 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>
Upstream-commit: acdbc285e29ddd92e7a1cc99daf8b16502204d2e
Component: engine
2017-06-07 11:44:34 -04:00
d267fa757f 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>
Upstream-commit: 54dcbab25ea4771da303fa95e0c26f2d39487b49
Component: engine
2017-05-05 17:02:04 -04:00
fb69291f3e Merge pull request #31104 from cpuguy83/dm_lvmsetup
Add option to auto-configure blkdev for devmapper
Upstream-commit: 05ad14fc1bc5626895a419a991fcf8932eb91d27
Component: engine
2017-05-05 07:35:24 -04:00
24557ed762 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>
Upstream-commit: 5ef07d79c4712d5b1ff4f0c896932ea8902a129c
Component: engine
2017-05-03 13:49:15 -04:00
9432bd8249 Switch to using opencontainers/selinux for selinux bindings
Signed-off-by: Antonio Murdaca <runcom@redhat.com>
Upstream-commit: abbbf914986d6d0ea15923f9a57a99465791bc83
Component: engine
2017-04-24 21:29:47 +02:00
bde265f61b 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>
Upstream-commit: ea22d7ab91e7febc69433b979160dda8a79ad46e
Component: engine
2017-04-10 13:11:39 -04:00
96de508a38 Merge pull request #31356 from coolljt0725/fix_suspend
devicemapper: Fix suspend a removed device
Upstream-commit: 3e561e4a845592b1c23cb6d13256694983066712
Component: engine
2017-03-02 10:11:48 +01:00
3da961cb82 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>
Upstream-commit: 6e25bb2ed6560baec4b13930e673c88f1b49de34
Component: engine
2017-03-01 21:58:14 +08:00
458406a7f3 Merge pull request #31212 from fate-grand-order/fixed
use t.Fatal() to output the err message and fix typo
Upstream-commit: a6576b8a2bff0feeb67918403caa3df0c4c37673
Component: engine
2017-02-27 12:26:35 +09:00
9632b0f1e8 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>
Upstream-commit: 2a8d6368d4a930203b93f75914173ab65bf3b0bc
Component: engine
2017-02-23 10:16:22 +08:00
abadc8a614 Add more locking to storage drivers
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
Upstream-commit: fc1cf1911bb92def95f407364372992d57b11ca2
Component: engine
2017-02-17 15:50:25 -08:00
54df4712b6 Update storage driver options link
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
Upstream-commit: e9864cc0ec53ae3be250cb184274ccc9349bec2d
Component: engine
2017-02-16 18:32:17 -08:00
9122c50dc9 Merge pull request #28500 from rhvgoyal/remove-unused-param
devmapper: get rid of unused device id argument in unregisterDevice()
Upstream-commit: e880120fe25543f7f45dad5c3f1fcd43cb3acd8b
Component: engine
2017-01-12 18:02:00 +01:00
15e349bb0f devmapper: fixup error formatting
Signed-off-by: Antonio Murdaca <runcom@redhat.com>
Upstream-commit: 8bcbc6711ffa253968c30ebf1366e79dfd08e205
Component: engine
2017-01-09 16:58:09 +01:00
a480d05277 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>
Upstream-commit: 39bdf601f6bea3c189d8e189e13c7e48b6f66b43
Component: engine
2017-01-05 15:02:21 -05:00
8a1df96ade Update docker daemon to dockerd
Signed-off-by: yuexiao-wang <wang.yuexiao@zte.com.cn>
Upstream-commit: 62cc802f6160b7fbb506f5307d96a564cbfb5f1f
Component: engine
2016-12-27 17:32:15 +08:00
44fa4f8ae7 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>
Upstream-commit: ea2dd4b5d0b41552d047814d9e39ddaa3662ab41
Component: engine
2016-12-21 20:16:19 +08:00
62b7ace712 daemon: return directly without ifs where possible
Signed-off-by: Cristian Staretu <cristian.staretu@gmail.com>
Upstream-commit: 3a42518042b36ad90950a3abf0aa125c0342b2c4
Component: engine
2016-12-14 22:36:58 +02:00
163c2e9b09 First header should be a top level header
Signed-off-by: yupeng <yu.peng36@zte.com.cn>
Upstream-commit: 1e65db4206ba89af24400fbf9047b25ec98cfd02
Component: engine
2016-11-22 09:33:21 +08:00
1f1219e7ad 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>
Upstream-commit: 288f933ed57581b5d8b9abb097bf531a55774d82
Component: engine
2016-11-16 16:16:46 -05:00
459e915b2e Pass all graphdriver create() parameters in a struct
This allows for easy extension of adding more parameters to existing
parameters list. Otherwise adding a single parameter changes code
at so many places.

Signed-off-by: Vivek Goyal <vgoyal@redhat.com>
Upstream-commit: b937aa8e6968d805527d163e6f477d496ceb88d7
Component: engine
2016-11-09 15:59:58 -05:00
07a831dfc2 Fix logrus formatting
This fix tries to fix logrus formatting by removing `f` from
`logrus.[Error|Warn|Debug|Fatal|Panic|Info]f` when formatting string
is not present.

Fixed issue #23459

Signed-off-by: Daehyeok Mun <daehyeok@gmail.com>
Upstream-commit: fa710e504b0e3e51d4031790c18621b02dcd2600
Component: engine
2016-10-31 22:05:01 -06:00
8fb804fc58 Fix the typo of URLs
Signed-off-by: YuPengZTE <yu.peng36@zte.com.cn>
Upstream-commit: fa378413f88054d0a336d675e7280930ddc86cb2
Component: engine
2016-10-19 17:46:27 +08:00
d85a4563ef Merge pull request #27483 from YuPengZTE/devFixLink
Fix the typo of link in devmapper
Upstream-commit: 32156e17584782ab7d08f37ec402c0d17bb2cd92
Component: engine
2016-10-18 12:45:31 -07:00
153b6651a5 Fix the typo of link in devmapper
Signed-off-by: YuPengZTE <yu.peng36@zte.com.cn>
Upstream-commit: f7701d90a94922fa6854cc80b2218392d6a4ac76
Component: engine
2016-10-18 16:02:38 +08:00
4b9781e130 all: replace loop with single append
Signed-off-by: Elena Morozova <lelenanam@gmail.com>
Upstream-commit: 64238fef8c7b739a2ae5648386cf594eb3a162e5
Component: engine
2016-10-13 13:31:52 -07:00
fa6f37076c Merge pull request #26898 from YuPengZTE/devErrorsNew
In error, the first letter is low-case letter
Upstream-commit: c2f57291ac04a1d582d7fcdedda7b1ad707543d5
Component: engine
2016-09-27 10:10:57 -04:00
ebdbeeeb36 In error, the first letter is low-case letter
Signed-off-by: YuPengZTE <yu.peng36@zte.com.cn>
Upstream-commit: 110ab746ba50e9febcdd246671f258036c71e59a
Component: engine
2016-09-27 10:40:07 +08:00
467aa61392 Optimized debug print in the 'deviceset.go'
Signed-off-by: Yanqiang Miao <miao.yanqiang@zte.com.cn>
Upstream-commit: 664ad19486b55a529ba2ba53b7d432b03dc5384a
Component: engine
2016-09-12 15:34:17 +08:00
30755d9f2c devmapper: Fail to start container if xfs_nospace_max_retries can't be enforced
We just introduced a new tunable dm.xfs_nospace_max_retries. But this tunable
will work only on new kernels where xfs supports this feature. On older
kernels xfs does not allow tuning this behavior.

There are two issues. First one is that if xfsSetNospaceRetries() fails,
it returns error but leaves the device activated and mounted. We should
be unmounting the device and deactivate it before returning.
 
Second issue is, if docker is started on older kernel, with
dm.xfs_nospace_max_retries specified, then docker will silently ignore the
fact that /sys file to tweak this behavior is not present and will continue.
But I think it might be better to fail container creation/start if kernel
does not support this feature.

This patch fixes it. After this patch, user will get an error like following
when container is run.

# docker run -ti fedora bash
docker: Error response from daemon: devmapper: user specified daemon option dm.xfs_nospace_max_retries but it does not seem to be supported on this system :open /sys/fs/xfs/dm-5/error/metadata/ENOSPC/max_retries: no such file or directory.

Signed-off-by: Vivek Goyal <vgoyal@redhat.com>
Upstream-commit: 6cc55dd65b363fe520c2ab29a9303f79afd4cadb
Component: engine
2016-09-07 14:03:01 -04:00
f9ef0edaad devmapper: Provide a knob dm.xfs_nospace_max_retries
When xfs filesystem is being used on top of thin pool, xfs can get ENOSPC
errors from thin pool when thin pool is full. As of now xfs retries the
IO and keeps on retrying and does not give up. This can result in container
application being stuck for a very long time. In fact I have seen instances
of unkillable processes. So that means once thin pool is full and process
gets stuck, container can't be stopped/killed either and only option left
seems to be power recycle of the box.

In another instance, writer did not block but failed after a while. But
when I tried to exit/stop the container, unmounting xfs hanged and only
thing I could do was power cycle the machine.

Now upstream kernel has committed patches where it allows user space to
customize user space behavior in case of errors. One of the knobs is
max_retries, which specifies how many times an IO should be retried
when ENOSPC is encountered.

This patch sets provides a tunable knob (dm.xfs_nospace_max_retries) so
that user can specify value for max_retries and tune xfs behavior. If
one sets this value to 0, xfs will not retry IO when ENOSPC error is
encountered. It will instead give up and shutdown filesystem.

This knob can be useful if one is running into unkillable
processes/containers issue on top of xfs.

Signed-off-by: Vivek Goyal <vgoyal@redhat.com>
Upstream-commit: 4f0017b9ad7dfa2e9dcdee69d000b98595893e60
Component: engine
2016-09-01 11:38:09 -04:00
1e0e8f732e Fixes Issue # 23418: Race condition between device deferred removal and resume device.
Problem Description:

An example scenario that involves deferred removal
1. A new base image gets created (e.g. 'docker load -i'). The base device is activated and
mounted at some point in time during image creation.
2. While image creation is in progress, a privileged container is started
from another image and the host's mount name space is shared with this
container ('docker run --privileged -v /:/host').
3. Image creation completes and the base device gets unmounted. However,
as the privileged container still holds a reference on the base image
mount point, the base device cannot be removed right away. So it gets
flagged for deferred removal.
4. Next, the privileged container terminates and thus its reference to the
base image mount point gets released. The base device (which is flagged
for deferred removal) may now be cleaned up by the device-mapper. This
opens up an opportunity for a race between a 'kworker' thread (executing
the do_deferred_remove() function) and the Docker daemon (executing the
CreateSnapDevice() function).

This PR cancel the deferred removal, if the device is marked for it. And reschedule the
deferred removal later after the device is resumed successfully.

Signed-off-by: Shishir Mahajan <shishir.mahajan@redhat.com>
Upstream-commit: 0e633ee14aca32480ac4735675222c35f4e11d8c
Component: engine
2016-08-02 10:33:58 -04:00
e667b026a1 Add detail error logs when 'Unknown Device' error happens if devicemapper storage is used.
Signed-off-by: yuzou <zouyu7@huawei.com>
Upstream-commit: d4a2bcc9ac49d07c71822ce72b97861d5844b46d
Component: engine
2016-06-30 13:06:14 +08:00
19552d6875 Modularize dm.use_deferred_removal and dm.use_deferred_deletion logic.
Signed-off-by: Shishir Mahajan <shishir.mahajan@redhat.com>
Upstream-commit: cac6658da061f01b4abd5b4bd1a7aeb234e8401d
Component: engine
2016-06-13 12:05:46 -04:00
04ae4edf2f Fix logrus formatting
This fix tries to fix logrus formatting by removing `f` from
`logrus.[Error|Warn|Debug|Fatal|Panic|Info]f` when formatting string
is not present.

This fix fixes #23459.

Signed-off-by: Yong Tang <yong.tang.github@outlook.com>
Upstream-commit: a72b45dbec3caeb3237d1af5aedd04adeb083571
Component: engine
2016-06-11 13:16:55 -07:00
763e6c326e *: fix logrus.Warn[f]
Signed-off-by: Antonio Murdaca <runcom@redhat.com>
Upstream-commit: 44ccbb317c2ca67fd8a88147b1ff80ce83d453cc
Component: engine
2016-06-11 19:42:38 +02:00
2360dea0b4 graphtest: fix cleanup logic
device Base should not exists on failure:

--- FAIL: TestDevmapperCreateBase (0.06s)
    graphtest_unix.go:122: stat
/tmp/docker-graphtest-079240530/devicemapper/mnt/Base/rootfs/a subdir:
no such file or directory
--- FAIL: TestDevmapperCreateSnap (0.00s)
    graphtest_unix.go:219: devmapper: device Base already
exists.

it should be:

--- FAIL: TestDevmapperCreateBase (0.25s)
	graphtest_unix.go:122: stat
/tmp/docker-graphtest-828994195/devicemapper/mnt/Base/rootfs/a subdir:
no such file or directory
--- FAIL: TestDevmapperCreateSnap (0.13s)
	graphtest_unix.go:122: stat
/tmp/docker-graphtest-828994195/devicemapper/mnt/Snap/rootfs/a subdir:
no such file or directory

Signed-off-by: Antonio Murdaca <runcom@redhat.com>
Upstream-commit: b18062122d76a9f53822889874aa12103d491372
Component: engine
2016-05-31 20:08:57 +02:00
bd261166b3 Fixes Issue # 22992: docker commit failing.
1) docker create / run / start: this would create a snapshot device and mounts it onto the filesystem.
So the first time GET operation is called. it will create the rootfs directory and return the path to rootfs
2) Now when I do docker commit. It will call the GET operation second time. This time the refcount will check
that the count > 1 (count=2). so the rootfs already exists, it will just return the path to rootfs.

Earlier it was just returning the mp: /var/lib/docker/devicemapper/mnt/{ID} and hence the inconsistent paths error.

Signed-off-by: Shishir Mahajan <shishir.mahajan@redhat.com>
Upstream-commit: 09d0720e2fb6e30ee018887399f353f93ac2d421
Component: engine
2016-05-27 14:35:46 -04:00
987aa6f79e Add reference counting to aufs
Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
Upstream-commit: 5b6b8df0c1b5a54ae9a717810eedf9fc971e1321
Component: engine
2016-05-23 15:57:23 -07:00
50e99151eb Add fast path for fsmagic supported drivers
For things that we can check if they are mounted by using their fsmagic
we should use that and for others do it the slow way.

Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
Upstream-commit: 1ba05cdb6ade7e3abd4c4c3221b5e27645460111
Component: engine
2016-05-23 15:57:23 -07:00
2b52cbdf3e Restore ref count
Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
Upstream-commit: 009ee16beff4f6d3607fa251019908cc72ce0a34
Component: engine
2016-05-23 15:57:23 -07:00
dab6ceb6f9 Merge pull request #21945 from rhvgoyal/export-min-free-space
Export Mininum Thin Pool Free Space through docker info
Upstream-commit: 227c83826aafbbcb3235d75cf7ab58392e552a83
Component: engine
2016-05-02 20:20:08 -04:00
76c8648306 Merge pull request #22168 from cpuguy83/22116_hack_in_layer_refcounts
Add refcounts to graphdrivers that use fsdiff
Upstream-commit: 8a0d2d8e57a4825fb21c0f8ef91bef513beebc35
Component: engine
2016-04-22 15:17:12 -07:00
f8ddc00d73 Add refcounts to graphdrivers that use fsdiff
This makes sure fsdiff doesn't try to unmount things that shouldn't be.

**Note**: This is intended as a temporary solution to have as minor a
change as possible for 1.11.1. A bigger change will be required in order
to support container re-attach.

Signed-off-by: Brian Goff <cpuguy83@gmail.com>
Upstream-commit: 7342060b070df67481f8da4f394a57cac1671d56
Component: engine
2016-04-21 12:19:57 -04:00
4847a4f337 Export Mininum Thin Pool Free Space through docker info
Right now there is no way to know what's the minimum free space threshold
daemon is applying. It would be good to export it through docker info and
then user knows what's the current value. Also this could be useful to
higher level management tools which can look at this value and setup their
own internal thresholds for image garbage collection etc.

Signed-off-by: Vivek Goyal <vgoyal@redhat.com>
Upstream-commit: 55a9b8123d7e89692b5c25c846cf6707a8ce463a
Component: engine
2016-04-21 15:42:23 +00:00
897c0b707e Grow the container rootfs when it is necessary
Signed-off-by: mYmNeo <thomassong@tencent.com>
Upstream-commit: 34a66a14af326a259d4ff9fb84db6f678f116a17
Component: engine
2016-04-12 09:27:47 +08:00
0e63dec985 parseStorageOpt: return size rather than updating devInfo.Size field
Signed-off-by: Shishir Mahajan <shishir.mahajan@redhat.com>
Upstream-commit: 45dc5b46e2018d0a8c2d15c6b2917f3581211a6e
Component: engine
2016-04-11 10:34:13 -04:00
d4ec9845eb Adding readOnly parameter to graphdriver Create method
Since the layer store was introduced, the level above the graphdriver
now differentiates between read/write and read-only layers.  This
distinction is useful for graphdrivers that need to take special steps
when creating a layer based on whether it is read-only or not.
Adding this parameter allows the graphdrivers to differentiate, which
in the case of the Windows graphdriver, removes our dependence on parsing
the id of the parent for "-init" in order to infer this information.

This will also set the stage for unblocking some of the layer store
unit tests in the next preview build of Windows.

Signed-off-by: Stefan J. Wernli <swernli@microsoft.com>
Upstream-commit: ef5bfad3210a9e9c8b761f2c11c0c6289490ebff
Component: engine
2016-04-06 13:52:53 -07:00
9b4fb715c9 Improve udev unsupported error message
Show a different message if a dynamic binary
is running, but doesn't have udev sync support.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
Upstream-commit: b8f38747e60eb76e19f08129ab27cb808d21c22a
Component: engine
2016-04-01 13:31:44 -07:00