Commit Graph

174 Commits

Author SHA1 Message Date
3c8e934faf Simplify and fix os.MkdirAll() usage
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.

[v2: a separate aufs commit is merged into this one]

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

Signed-off-by: Kir Kolyshkin <kir@openvz.org>
Upstream-commit: a83a76934787a20e96389d33bd56a09369f9b808
Component: engine
2015-07-30 11:48:08 -07:00
581a7026d5 daemon/graphdriver/devmapper/ fix lint errors/warnings
Addresses #14756
Signed-off-by: Srini Brahmaroutu <srbrahma@us.ibm.com>
Upstream-commit: 972a94b449ea6a68f041c47fe7bda35b5ac765a2
Component: engine
2015-07-29 01:43:34 +00:00
8a425b30fb Merge pull request #14693 from LK4D4/update_libcontainer
Update libcontainer
Upstream-commit: 98ed9a55f42f7c86c7c9cddb27f6807e7e77c889
Component: engine
2015-07-17 13:02:04 -07:00
5fc55316cd devicemapper: Change default basesize to 100G
Current default basesize is 10G. Change it to 100G. Reason being that for
some people 10G is turning out to be too small and we don't have capabilities
to grow it dyamically.

This is just overcommitting and no real space is allocated till container
actually writes data. And this is no different then fs based graphdrivers
where virtual size of a container root is unlimited.

Signed-off-by: Vivek Goyal <vgoyal@redhat.com>
Upstream-commit: 424d5e55a2f863b8eadab578e3ba647de09a4354
Component: engine
2015-07-17 11:10:23 -04:00
d9e652a366 Update libcontainer
Replaced github.com/docker/libcontainer with
github.com/opencontainers/runc/libcontaier.
Also I moved AppArmor profile generation to docker.

Main idea of this update is to fix mounting cgroups inside containers.
After updating docker on CI we can even remove dind.

Signed-off-by: Alexander Morozov <lk4d4@docker.com>
Upstream-commit: c86189d554ba14aa04b6314970d3699e5ddbf4de
Component: engine
2015-07-16 16:02:26 -07:00
46a0415407 Fix some formatting calls
Signed-off-by: Alexander Morozov <lk4d4@docker.com>
Upstream-commit: a5142f6ac31c6c21b96c6895fff525c46e8056a6
Component: engine
2015-07-15 12:25:50 -07:00
a1ee4d8815 Merge pull request #14021 from rhvgoyal/detect-pool-loopback-devices
devicemapper: Check loop devices of existing pool
Upstream-commit: 5ca3e7c54c9140f2b8553060fdd75d3986e6db6e
Component: engine
2015-07-13 21:15:23 -04:00
a095147db9 Fix panic on devicemapper initialization
The ability to save and verify base device UUID (#13896) introduced a
situation where the initialization would panic when removing the device
returns EBUSY.

Functions `verifyBaseDeviceUUID` and `saveBaseDeviceUUID` now take the
lock on the `DeviceSet`, which solves the problem as `removeDevice`
assumes it owns the lock.

Signed-off-by: Arnaud Porterie <arnaud.porterie@docker.com>
Upstream-commit: f08989902374a517b1f8e5e0bfd3b4ea59e5ba27
Component: engine
2015-07-08 09:10:20 -07:00
682ea83bb3 Warn when udev_sync is not supported.
Signed-off-by: David Calavera <david.calavera@gmail.com>
Upstream-commit: e27131519f610178fd8adfc4b87c7bc2521a562f
Component: engine
2015-07-07 15:10:24 -06:00
c17c7fce57 Revert "Fix implicit DeviceMapper selection"
This reverts commit 0a376291b2213699f986a7bca1cc8c4f4ed00f8d.

Signed-off-by: David Calavera <david.calavera@gmail.com>
Upstream-commit: 9af7afb9eb138bdba33c22445f36f41e5aa26bd1
Component: engine
2015-07-07 12:27:19 -07:00
5ce830016b devicemapper: Check loop devices of existing pool
Often it happens that docker is not able to shutdown/remove the thin
pool it created because some device has leaked into some mount name
space. That means device is in use and that means pool can't be removed.

Docker will leave pool as it is and exit. Later when user starts the
docker, it finds pool is already there and docker uses it. But docker
does not know it is same pool which is using the loop devices. Now
docker thinks loop devices are not being used. That means it does not
display the data correctly in "docker info", giving user wrong information.

This patch tries to detect if loop devices as created by docker are
being used for pool and fills in the right details in "docker info".

Signed-off-by: Vivek Goyal <vgoyal@redhat.com>
Upstream-commit: bebf53443981c70a6a714ea518dc966a0e2b6558
Component: engine
2015-07-07 14:13:29 -04:00
740b021c6a Fix implicit DeviceMapper selection
DeviceMapper must be explicitly selected because the Docker binary might not be linked to the right devmapper library.

With this change, Docker fails fast if the driver detection finds the devicemapper directory but the driver is not the default option.
The option `override_udev_sync_check` doesn't make sense anymore, since the user must be explicit to select devicemapper, so it's being removed.
Docker fails to use devicemapper only if Docker has been built statically unless the option was explicit.

Signed-off-by: David Calavera <david.calavera@gmail.com>
Upstream-commit: 0a376291b2213699f986a7bca1cc8c4f4ed00f8d
Component: engine
2015-07-02 09:21:27 -07:00
4f74d3f3bd Closes #13323 and carries
Entering comments

Signed-off-by: Mary Anthony <mary@docker.com>
Upstream-commit: 078b23a37daf95101bf31bafc7f8396af7ad7d98
Component: engine
2015-06-29 06:18:41 -07:00
94d7dd0cf8 Merge pull request #13896 from rhvgoyal/verify-base-uuid
devicemapper: Compare uuid of base device on startup
Upstream-commit: 85d3b75dfddde62bf1c934afd1cd41ee12309223
Component: engine
2015-06-17 11:30:04 -07:00
f21492c649 devicemapper: Compare uuid of base device on startup
It is easy for one to use docker for a while, shut it down and restart
docker with different set of storage options for device mapper driver
which will effectively change the thin pool. That means any of the
metadata stored in /var/lib/docker/devicemapper/metadata/ is not valid
for the new pool and user will run into various kind of issues like
container not found in the pool etc.

Users think that their images or containers are lost but it might just
be the case of configuration issue. People might use wrong metadata
with wrong pool.

To detect such situations, save UUID of base image and once docker
starts later, query and compare the UUID of base image with the
stored one. If they don't match, fail the initialization with the
error that UUID failed to match.

That way user will be forced to cleanup /var/lib/docker/ directory
and start docker again.

Signed-off-by: Vivek Goyal <vgoyal@redhat.com>
Upstream-commit: c06b05b11e6bbe48ae3ca140096d7862e5e312f8
Component: engine
2015-06-16 21:12:27 -04:00
4a6f8e2e63 docker-inspect: Extend docker inspect to export image/container metadata related to graph driver
Export image/container metadata stored in graph driver. Right now 3 fields
DeviceId, DeviceSize and DeviceName are being exported from devicemapper.
Other graph drivers can export fields as they see fit.

This data can be used to mount the thin device outside of docker and tools
can look into image/container and do some kind of inspection.

Signed-off-by: Vivek Goyal <vgoyal@redhat.com>
Upstream-commit: 407a626be62996cd6385ea4d80e669ab83f5f04d
Component: engine
2015-06-15 14:05:10 -04:00
57eb64c9c0 Carry of PR #13520
Removinig files

Signed-off-by: Mary Anthony <mary@docker.com>
Upstream-commit: cd44018856be421497a35d96f88dd0eec42fae43
Component: engine
2015-06-13 09:27:30 -07:00
55843a6210 Fix incorrect document storage-opt
Signed-off-by: Lei Jitang <leijitang@huawei.com>
Upstream-commit: 0204ecdf707bdbb3caa76548e576f4ff0706fc46
Component: engine
2015-05-15 19:13:07 +08:00
11e5be135f Merge pull request #12190 from rhvgoyal/deferred-removal
Devicemapper: Provide deferred device removal capability
Upstream-commit: 56c991781564e8cc292166d3b3e27e304c240468
Component: engine
2015-05-04 14:22:52 -07:00
a580a2dfa9 Merge pull request #12903 from rhvgoyal/disable-discards
devmapper: Disable mount option "discard" by default
Upstream-commit: 2e49281bd085d84babe8b3243de1e97c2d12dac1
Component: engine
2015-05-04 18:35:25 +03:00
63fe58e0de devmapper: Disable mount option "discard" by default
Right now devicemapper mounts thin device using online discards by default
and passes mount option "discard". Generally people discourage usage of
online discards as they can be a drain on performance. Instead it is 
recommended to use fstrim once in a while to reclaim the space.

In case of  containers, we recommend to keep data volumes separate. So
there might not be lot of rm, unlink operations going on and there might
not be lot of space being freed by containers. So it might not matter
much if we don't reclaim that free space in pool.

User can still pass mount option explicitly using dm.mountopt=discard to
enable discards if they would like to.

So this is more like setting the containers by default for better performance
instead of better space efficiency in pool. And user can change the behavior
if they don't like default behavior.

Reported-by: Mike Snitzer <snitzer@redhat.com>
Signed-off-by: Vivek Goyal <vgoyal@redhat.com>
Upstream-commit: 04adaaf1ee1688ff48cb8f541dcb80e965f45080
Component: engine
2015-05-01 09:16:31 -04:00
954f940156 Small if err cleaning
Signed-off-by: Antonio Murdaca <me@runcom.ninja>
Upstream-commit: 844538142d95c1b7dda1bb2903179510105fe9b5
Component: engine
2015-04-27 21:50:33 +02:00
c9ef8ab72d devmapper: Cancel deferred deactivation if device is reactivated
If device is being reactivated before it could go away and deferred 
deactivation is scheduled on it, cancel it.

Signed-off-by: Vivek Goyal <vgoyal@redhat.com>
Upstream-commit: ddc8acebecfdc7dbc0357f5c009fb3ee0a2ae906
Component: engine
2015-04-21 18:14:59 -04:00
be8151e80b devmapper: Export deferred removal status in status
This will help with debugging as one could just do "docker info" and figure
out of deferred removal is enabled or not.

Signed-off-by: Vivek Goyal <vgoyal@redhat.com>
Upstream-commit: 66a53819aea2ab1ab0d50be1f8d32fcb2427cd78
Component: engine
2015-04-21 18:14:59 -04:00
807639ca3d devmapper: Use deferred removal
Make use of deferred removal of devices.

Signed-off-by: Vivek Goyal <vgoyal@redhat.com>
Upstream-commit: e37c7203bb1d840e9383ac08bf87afda3e722344
Component: engine
2015-04-21 18:14:59 -04:00
de64b1affe devmapper: Provide a new parameter dm.deferred_device_removal
Provide a new command line knob dm.deferred_device_removal which will enable
deferred device deactivation if driver and library support it.

This patch also checks for library support and driver version.

Signed-off-by: Vivek Goyal <vgoyal@redhat.com>
Upstream-commit: 15c158b20725fd62e2ee0a72ffaf1617852cd0d9
Component: engine
2015-04-21 18:14:59 -04:00
44fddcaf4b Merge pull request #11412 from vbatts/vbatts-dm_sync_is_required
devmapper: udev sync is a requirement
Upstream-commit: 23c12dabbdb7f895f606bbf2438599d29c53df3a
Component: engine
2015-04-10 16:52:38 -04:00
d89c51c3b5 devmapper: storage-opt override for udev sync
This provides an override for forcing the daemon to still attempt
running the devicemapper driver even when udev sync is not supported.

Intended to be a very clear impairment for those choosing to use it. If
udev sync is false, there will still be an error in the daemon logs,
even when the override is in place. The docs have an explicit WARNING.

Including link to the docs for users that encounter this daemon error
during an upgrade.

Signed-off-by: Vincent Batts <vbatts@redhat.com>
Upstream-commit: 0e21782de5c038dfa3cfdfc7655b9e6b143baa7b
Component: engine
2015-04-10 15:43:16 -04:00
25835c875f devmapper: udev sync is a requirement
closes #10664
closes #4036

Signed-off-by: Vincent Batts <vbatts@redhat.com>
Upstream-commit: ca628c6216ade64790dfbfe388fe4769433ec4aa
Component: engine
2015-04-06 15:17:57 -04:00
68a3810b3c devmapper: Retry device removal after 100ms instead of 10ms
Right now we try device removal at the interval of 10ms and keep on trying
till either device is removed or 10 seconds are over. That means if device
is busy, we will try 1000 times in those 10 seconds.

Sounds too high a frequency of deivce removal retrial. All the logs are
filled easily. I think it is a good idea to slow down a bit and retry at
the interval of 100ms instead of 10ms.

Signed-off-by: Vivek Goyal <vgoyal@redhat.com>
Upstream-commit: c737800b7faced4b53854c8cb6766ebe58a3c3e9
Component: engine
2015-04-02 16:47:14 -04:00
a0411faab2 devmapper: Remove call to waitClose()
During device removal, we are first waiting for device to close() in a tight
loop for 10 seconds. I am not sure why do we need it. First of all we come
here once the umount() is successful so device should be free. For some reason
of device is temporarily busy, then removeDevice() logic retries device removal
logic in a loop for 10 seconds and that should cover it. Can't see why one
more 10 seoncds loop is required before attempting device removal.

One loop should be able to cover all the temporary device busy conditions and
if condition is not temporary then 10 seconds loop is not going to help anyway.

So instead of two loops of 10 seconds each, I am converting it to a single
loop of 20 seconds. May be 10 second loop is good enough but for now I am
keeping it 20 seconds to avoid any regressions.

Signed-off-by: Vivek Goyal <vgoyal@redhat.com>
Upstream-commit: f74d12012c21349b2bd51d9c395a99331ff0a9a5
Component: engine
2015-04-02 16:47:14 -04:00
12beb9b276 devmapper: Remove extra wait after device removal
Currently in device removal path (device deactivation), we wait
for 10 seconds for devive to actually go away. waitRemove().

In current code this is not required. If dm removal task has completed
and one has done the wait on udev cookie, then device is gone and there
is no need to write another loop to wait for device removal.

This patch removes the waitRemove() which waits for 10 seconds after
device removal. This seems unnecessary.

Signed-off-by: Vivek Goyal <vgoyal@redhat.com>
Upstream-commit: dbf04ec4e2a6b4fe73f7f300918a906c0ff1a37b
Component: engine
2015-04-02 16:47:14 -04:00
cb8a2764e5 devicemapper: Remove debug messages from RemoveDevice()
devmapper graph driver retries device removal 1000 times in case of failure
and if this fills up console with 1000 messages (when daemon is running in
debug mode). So remove these debug messages.
 
Signed-off-by: Vivek Goyal <vgoyal@redhat.com>
Upstream-commit: cb7c893275c32ddfa775c3f22869a9c211024c71
Component: engine
2015-04-02 16:47:14 -04:00
2b212c76e7 devmapper: Fix libdm logging
There are issues with libdm logging. Right now if docker daemon is run
in debug mode, logging by libdm is too verbose. And if a device can't 
be removed, thousands of messages fill the console and one can not see
what's going on.

This patch removes devicemapper.LogInitVerbose() call as that call will
only work if docker was not registering its own log handler with libdm.
For some reason docker registers one with libdm and libdm hands over
all the messages to docker (including debug ones). And now it is up to
devmapper backend to figure out which ones should go to console and
which ones should not.

So by default log only fatal messages from libdm. One can easily modify
the code to change it for debugging purposes.

Signed-off-by: Vivek Goyal <vgoyal@redhat.com>
Upstream-commit: e07d3cd9acf14219f33e12375fb8c2e3fe02ad0c
Component: engine
2015-04-02 16:47:14 -04:00
e5b36a723c Replace aliased imports of logrus, fixes #11762
Signed-off-by: Antonio Murdaca <me@runcom.ninja>
Upstream-commit: 6f4d847046cb4e072de61d042c0266190d73a8c9
Component: engine
2015-03-26 23:22:04 +01:00
ac917d33bd Fixed redundant else in GetDeviceStatus
Signed-off-by: Anes Hasicic <anes.hasicic@gmail.com>
Upstream-commit: e479e1c9f7d327f396eebc46d446cf4ee34513f7
Component: engine
2015-03-25 09:53:04 +01:00
b3678f8418 Merge pull request #11076 from hqhq/hq_use_warning_in_sysinfo
use type WARN for warning
Upstream-commit: 82f390e139e611b97911c19dd1be2a98264cf4b9
Component: engine
2015-03-15 21:13:23 -07:00
b951eb79db Fix minor typo
Signed-off-by: Deng Guangxing <dengguangxing@huawei.com>
Upstream-commit: ce1a0b612d300210fadf12556e1b38885f098197
Component: engine
2015-03-11 11:13:39 +08:00
ad6ee8ec46 fix warning messages
Use log.Warnf instead of log.Infof, and remove redundant `WARNING` prefix.

Signed-off-by: Qiang Huang <h.huangqiang@huawei.com>
Upstream-commit: bffe04b582d143f074297b260a359dfb54a7763b
Component: engine
2015-03-11 08:47:45 +08:00
5506a9a27c Remove subdirectories MAINTAINERS files
Signed-off-by: Arnaud Porterie <arnaud.porterie@docker.com>
Upstream-commit: 89bdaa35e04b74b7c6528783e0f7b8154b2a3d31
Component: engine
2015-03-06 18:21:51 -08:00
2d25573473 Merge pull request #11106 from MabinGo/fix_log_info
Fix some revision about log output
Upstream-commit: 32ccde46dde5130adcfb170c846c8f0317761aee
Component: engine
2015-03-02 13:55:43 -08:00
d0e86ebf79 Merge pull request #11054 from MabinGo/checkfileoper1
Add the file close operation before function return to advoid resource leaking
Upstream-commit: 82aa950f4e10dbd45b16ecfc144f8d4b450ad1ff
Component: engine
2015-03-02 10:44:26 -08:00
aeb9a73d60 Merge pull request #11083 from MabinGo/minor_typo
Modify the minor typo in deviceset.go
Upstream-commit: 738bdec4908755761b27b7d15baeefb1a824f770
Component: engine
2015-03-02 13:11:14 -05:00
4a59461365 Fix some revision about log output
Signed-off-by: Mabin <bin.ma@huawei.com>
Upstream-commit: adfd1ddfc6e094295d07ff2b36fb6e91cf7878dd
Component: engine
2015-03-02 17:06:38 +08:00
f3df541809 fix typo of comments in daemon/graphdriver/devmapper/deviceset.go
Signed-off-by: Mabin <bin.ma@huawei.com>
Upstream-commit: f4ac86de84c25bf1793d1e934695b7119dc51b70
Component: engine
2015-03-02 02:11:15 +08:00
5e225bf426 Modify the minor typo in deviceset.go
Signed-off-by: Mabin <bin.ma@huawei.com>
Upstream-commit: 5c1559a754f7b1fba45be01a6f1a4b3c7c6c4c68
Component: engine
2015-02-28 18:04:10 +08:00
0fd505f748 Add the file close operation before function return to advoid resource leaking
Signed-off-by: Mabin <bin.ma@huawei.com>
Upstream-commit: b5eeab6e061d183be050143426dd7fd774c89a20
Component: engine
2015-02-28 00:24:41 +08:00
009380c706 Merge pull request #10474 from petervo/10473-availble-space
Add available space to devicemapper status output
Upstream-commit: f4dc496d36d31cf9ca1b3508f10954066ff7f8bc
Component: engine
2015-02-10 16:32:51 +01:00
7fe8a53e1c Detail available space behavior on loop devices
Signed-off-by: Peter Volpe <petervo@redhat.com>
Upstream-commit: 6816d27591a24b7a3a5b2e4c85294abffda977a2
Component: engine
2015-02-09 14:51:48 -08:00
5c8d4a0091 Merge pull request #10440 from rhvgoyal/skip-dot-prefix-files
devicemapper: Skip the files with prefix "." during device map construct...
Upstream-commit: 67a4f1db103ac726f6e3d1fe388214ba41062b78
Component: engine
2015-02-09 10:26:27 +01:00