Commit Graph

91 Commits

Author SHA1 Message Date
98d864eefe devmapper: Avoid AB-BA deadlock
We currently drop the global lock while holding a per-device lock when
waiting for device removal, and then we re-aquire it when the sleep is done.
This is causing a AB-BA deadlock if anyone at the same time tries to do any
operation on that device like this:

thread A:             thread B
grabs global lock
grabs device lock
releases global lock
sleeps
                      grabs global lock
                      blocks on device lock
wakes up
blocks on global lock

To trigger this you can for instance do:

ID=`docker run -d fedora sleep 5`
cd /var/lib/docker/devicemapper/mnt/$ID
docker wait $ID
docker rm $ID &
docker rm $ID

The unmount will fail due to the mount being busy thus causing the
timeout and the second rm will then trigger the deadlock.

We fix this by adding a lock ordering such that the device locks
are always grabbed before the global lock. This is safe since the
device lookups now have a separate lock.

Docker-DCO-1.1-Signed-off-by: Alexander Larsson <alexl@redhat.com> (github: alexlarsson)
Upstream-commit: 2ffef1b7eb618162673c6ffabccb9ca57c7dfce3
Component: engine
2014-04-02 09:05:00 +02:00
bd0bcefa7f devmapper: Add lock to protext Devices map
Currently access to the Devices map is serialized by the main
DeviceSet lock, but we need to access it outside that lock, so we
add a separate lock for this and grab that everywhere we modify
or read the map.

Docker-DCO-1.1-Signed-off-by: Alexander Larsson <alexl@redhat.com> (github: alexlarsson)
Upstream-commit: 70826e8b3fee27b971852aad89053507c6866d3e
Component: engine
2014-04-02 09:05:00 +02:00
1544c3baed devmapper: Add lookupDevice() helper
This centralizes the lookup of devices so it is only done in one place.
This will be needed later when we change the locking for it.

Docker-DCO-1.1-Signed-off-by: Alexander Larsson <alexl@redhat.com> (github: alexlarsson)
Upstream-commit: e01b71cebeb96755641a18762dea5b843f107bee
Component: engine
2014-04-02 09:05:00 +02:00
be8cb2a3bc devmapper: Pass info rather than hash to setInitialized
We already have this at the caller, no need to look up again.

Docker-DCO-1.1-Signed-off-by: Alexander Larsson <alexl@redhat.com> (github: alexlarsson)
Upstream-commit: 74edcaf1e84aa8bf35e496b2bead833172a79fca
Component: engine
2014-04-02 09:05:00 +02:00
3fc0d17ed6 devmapper: Pass info rather than hash to deactivateDevice()
We already have the info in most cases, no need to look this up multiple times.

Docker-DCO-1.1-Signed-off-by: Alexander Larsson <alexl@redhat.com> (github: alexlarsson)
Upstream-commit: 5955846774c9b43291d6de0584fa8c3f62414c43
Component: engine
2014-04-02 09:05:00 +02:00
cca3f27ce9 devmapper: Pass info rather than hash to deleteDevice
All the callers already have the info, no need for an extra lookup.

Docker-DCO-1.1-Signed-off-by: Alexander Larsson <alexl@redhat.com> (github: alexlarsson)
Upstream-commit: 8e39b35c7cd02bbb644b7faf2a434de0098e6dea
Component: engine
2014-04-02 09:05:00 +02:00
d51d0846f3 devmapper: Pass info rather than hash to activateDeviceIfNeeded
There is no need to look this up again, we have it already in all callers.

Docker-DCO-1.1-Signed-off-by: Alexander Larsson <alexl@redhat.com> (github: alexlarsson)
Upstream-commit: e5394e35c7a8f730ac76d24dee74d769049a0428
Component: engine
2014-04-02 09:05:00 +02:00
d7e849e505 Merge pull request #4931 from crosbymichael/gen-mac-addr-for-bridge
Set bridge mac addr on supported kernels
Upstream-commit: ceed9382d0b361018a57ec96e163c3c30198cbd0
Component: engine
2014-04-02 02:47:56 +03:00
4675670b52 Merge pull request #4867 from crosbymichael/clean-shutdown
Cleanly shutdown docker
Upstream-commit: 30ff3fa954676bfc8f48b73093f3afa1473d146e
Component: engine
2014-04-02 01:48:03 +03:00
45bf7e9540 Update test to reallocate port
Docker-DCO-1.1-Signed-off-by: Michael Crosby <michael@crosbymichael.com> (github: crosbymichael)
Upstream-commit: 6b7cfc9e95af8510abc801a02cda7879e4f82518
Component: engine
2014-04-01 07:27:34 +00:00
f2838447fa Merge pull request #4949 from tjmehta/4908-fix_dynamic_port_allocation_limit
Fix dynamic port allocation limit
Upstream-commit: 7462cc6479c3a5c2f572bf9fe2bfc60a4f1e2506
Component: engine
2014-04-01 13:49:21 -07:00
b924033920 Merge pull request #4833 from crosbymichael/pluginflag
Add opts flag for fine grained control over drivers
Upstream-commit: b4b87413d8d3fd20073975bcc84603fa7853d316
Component: engine
2014-04-01 13:34:08 -07:00
e4f0a4813f Do not error when trying to start a started container
Docker-DCO-1.1-Signed-off-by: Guillaume J. Charmes <guillaume@charmes.net> (github: creack)
Upstream-commit: a03f83e3370f3859ebff172d504cc29817863b17
Component: engine
2014-04-01 10:26:53 -07:00
2ec7753394 Send sigterm and wait forever
Docker-DCO-1.1-Signed-off-by: Michael Crosby <michael@crosbymichael.com> (github: crosbymichael)
Upstream-commit: 93779cc7fee4ee0690d9dd28eed478a418e79577
Component: engine
2014-04-01 07:12:50 +00:00
8169d6ecd6 Ensure state is saved to disk after we kill the ghost
Docker-DCO-1.1-Signed-off-by: Michael Crosby <michael@crosbymichael.com> (github: crosbymichael)
Upstream-commit: e36d89b0f9c8ba5b071374310ca632f6b2fdb7a1
Component: engine
2014-04-01 07:12:50 +00:00
5f13c09028 Ensure a reliable way to kill ghost containers on reboot
Docker-DCO-1.1-Signed-off-by: Michael Crosby <michael@crosbymichael.com> (github: crosbymichael)
Upstream-commit: 5bb82f6313d7f789783ffac854be85a44a56617e
Component: engine
2014-04-01 07:11:41 +00:00
b36db3b674 Add kill for other drivers on restart
Docker-DCO-1.1-Signed-off-by: Michael Crosby <michael@crosbymichael.com> (github: crosbymichael)
Upstream-commit: 5b9069bd990dca0a35d8e490c6f6b56d27163bb8
Component: engine
2014-04-01 07:11:41 +00:00
357e0a3599 Ensure that all containers are stopped cleanly at shutdown
Docker-DCO-1.1-Signed-off-by: Michael Crosby <michael@crosbymichael.com> (github: crosbymichael)
Upstream-commit: f067e263677fc86f9610ca61fbe42f63efad91f2
Component: engine
2014-04-01 07:11:41 +00:00
0595bffeac Update imports to be consistent
Docker-DCO-1.1-Signed-off-by: Michael Crosby <michael@crosbymichael.com> (github: crosbymichael)
Upstream-commit: 40c6d00c97c737d9d3827f159518007803affcc7
Component: engine
2014-04-01 07:07:42 +00:00
69f1eddd56 make findNextPort circular, add all-ports-allocated error
Docker-DCO-1.1-Signed-off-by: Tejesh Mehta <tejesh.mehta@gmail.com> (github: tjmehta)
Upstream-commit: 739d1244807bc3522a0af4dc3490305d6f037601
Component: engine
2014-03-31 22:21:52 -07:00
a4e4b56b6e Set bridge mac addr on supported kernels
Fixes #3200
Docker-DCO-1.1-Signed-off-by: Michael Crosby <michael@crosbymichael.com> (github: crosbymichael)
Upstream-commit: 4cdcea20474a9f42291fe6b6c6dee348343a7c05
Component: engine
2014-03-31 22:56:23 +00:00
91181125c8 Force abs paths for host volumes
Docker-DCO-1.1-Signed-off-by: Michael Crosby <michael@crosbymichael.com> (github: crosbymichael)
Upstream-commit: 904bf049c1626567ee28a21bde4b68ab82c5ce77
Component: engine
2014-03-31 19:10:19 +00:00
cbbfe30c09 Allow volumes from to be individual files
Fixes #4741
Right now volumes from expected a dir and not a file so when the drivers
 tried to do the bind mount, the destination was a dir, not a file so it
 fails to run.
Docker-DCO-1.1-Signed-off-by: Michael Crosby <michael@crosbymichael.com> (github: crosbymichael)
Upstream-commit: a57900e35f2c30026a070fdfdbdb0ce99b35e1ff
Component: engine
2014-03-31 17:27:38 +00:00
9b7d158e2c Merge pull request #4884 from rhatdan/remount-var-lib-docker
Remount /var/lib/docker as --private to fix scaling issue
Upstream-commit: c705e4a80bd93fac7af38f5384ca61cb884bd22f
Component: engine
2014-03-28 17:15:32 -07:00
8d7581c203 devmapper: Ensure we shut down thin pool cleanly.
The change in commit a9fa1a13c3b0a654a96be01ff7ec19e8009b2094
made us only deactivate devices that were mounted. Unfortunately
this made us not deactivate the base device. Which caused
us to not be able to deactivate the pool.

This fixes that by always just deactivating the base device.

Docker-DCO-1.1-Signed-off-by: Alexander Larsson <alexl@redhat.com> (github: alexlarsson)
Upstream-commit: 66c5e19f9bd057644fab475499ea45bb428ba2b2
Component: engine
2014-03-28 15:58:14 +01:00
6d04587343 Remount /var/lib/docker as --private to fix scaling issue
If an admin mounts all file systems as -rshared (Default on RHEL and Fedora)
we see a scaling problem as the number of container increase.

Basically every new container needs to have it new mounts in /var/lib/docker
shared to all other containers, this ends up with us only able to scale to
around 100 containers, before the system slows down.

By simply bind mounting /var/lib/docker on its and then setting it private,
the scaling issue goes away.

Docker-DCO-1.1-Signed-off-by: Dan Walsh <dwalsh@redhat.com> (github: rhatdan)
Upstream-commit: 792bb41e524615486ef8266b7bf4804b4fe178f1
Component: engine
2014-03-28 09:19:21 -04:00
da6de365f6 Merge pull request #4450 from alexlarsson/cgroups-systemd
Add systemd implementation of cgroups
Upstream-commit: 69ba31e17ea4dab6b040478720955dece5986f6c
Component: engine
2014-03-28 03:05:02 +02:00
528335a67b Merge pull request #4871 from crosbymichael/bip-exists
Return error when existing bridge does not match ip
Upstream-commit: d848e2d113a6978a42cd5bb93fe57f9ea653b627
Component: engine
2014-03-27 14:51:21 -07:00
5f846085d9 cgroups: Add systemd implementation of cgroups
This implements cgroup.Apply() using the systemd apis.
We create a transient unit called "docker-$id.scope" that contains
the container processes. We also have a way to set unit specific
properties, currently only defining the Slice to put the
scope in.

Docker-DCO-1.1-Signed-off-by: Alexander Larsson <alexl@redhat.com> (github: alexlarsson)
Upstream-commit: 6c7835050e53b733181ddfca6152c358fd625400
Component: engine
2014-03-27 22:44:31 +01:00
9e1caa6b4a Add --opt arguments for drivers
In order to handle special configuration for different drivers we
make the Config field a map to string array. This lets
us use it for lxc, by using the "lxc" key for those, and we can
later extend it easily for other backend-specific options.

Docker-DCO-1.1-Signed-off-by: Alexander Larsson <alexl@redhat.com> (github: alexlarsson)
Upstream-commit: 7a3070a6000963d12be9dcd2698d911b848a33b6
Component: engine
2014-03-27 21:47:47 +01:00
f731a44bb1 Merge pull request #4818 from viirya/fix_working_dir_not_dir
fix the problem when setting existing file as working dir
Upstream-commit: ba9f9b3c9268a1b201bcb10045da77b135d869d1
Component: engine
2014-03-27 11:41:18 -07:00
e14a0de6e1 Merge pull request #4838 from crosbymichael/btrfs-ftw
Promote btrfs
Upstream-commit: 303a954151f89dc7d2c485417fd0a9bacabe9ad0
Component: engine
2014-03-27 19:55:25 +02:00
97a3970ba7 Update native driver to use labels from opts
Docker-DCO-1.1-Signed-off-by: Michael Crosby <michael@crosbymichael.com> (github: crosbymichael)
Upstream-commit: 6c9a47f01c583e9c22b831eb426192148d29d792
Component: engine
2014-03-27 09:04:54 +00:00
60570ca0ef Update lxc to use opts for selinux labels
Docker-DCO-1.1-Signed-off-by: Michael Crosby <michael@crosbymichael.com> (github: crosbymichael)
Upstream-commit: bfa2141765c2a3866ca0f5237fc951f4c2db8b98
Component: engine
2014-03-27 08:57:01 +00:00
5ed6e1adb8 Fix compile and unit test errors after merge
Docker-DCO-1.1-Signed-off-by: Michael Crosby <michael@crosbymichael.com> (github: crosbymichael)
Upstream-commit: 2d270c4f06dbc2ee1293e3f81f6922df248ef8eb
Component: engine
2014-03-27 08:25:01 +00:00
f4111a1ccb Merge branch 'master' into pluginflag
Conflicts:
	pkg/cgroups/cgroups.go
	pkg/libcontainer/nsinit/exec.go
	pkg/libcontainer/nsinit/init.go
	pkg/libcontainer/nsinit/mount.go
	runconfig/hostconfig.go
	runconfig/parse.go
	runtime/execdriver/driver.go
	runtime/execdriver/lxc/lxc_template.go
	runtime/execdriver/lxc/lxc_template_unit_test.go
	runtime/execdriver/native/default_template.go
	runtime/execdriver/native/driver.go

Docker-DCO-1.1-Signed-off-by: Michael Crosby <michael@crosbymichael.com> (github: crosbymichael)
Upstream-commit: eab56ac007b263708b5526609c8be2bc19881467
Component: engine
2014-03-27 08:00:18 +00:00
f757666ccd This patch adds SELinux labeling support.
docker will run the process(es) within the container with an SELinux label and will label
all of  the content within the container with mount label.  Any temporary file systems
created within the container need to be mounted with the same mount label.

The user can override the process label by specifying

-Z With a string of space separated options.

-Z "user=unconfined_u role=unconfined_r type=unconfined_t level=s0"

Would cause the process label to run with unconfined_u:unconfined_r:unconfined_t:s0"

By default the processes will run execute within the container as svirt_lxc_net_t.
All of the content in the container as svirt_sandbox_file_t.

The process mcs level is based of the PID of the docker process that is creating the container.

If you run the container in --priv mode, the labeling will be disabled.

Docker-DCO-1.1-Signed-off-by: Dan Walsh <dwalsh@redhat.com> (github: rhatdan)
Upstream-commit: 4c4356692580afb3971094e322aea64abe0e2500
Component: engine
2014-03-26 15:30:40 -04:00
7c744319b0 Return error when existing bridge does not match ip
Docker-DCO-1.1-Signed-off-by: Michael Crosby <michael@crosbymichael.com> (github: crosbymichael)
Upstream-commit: baba9cde9542b480162d11bd30ca3a522fa6b4d0
Component: engine
2014-03-26 11:51:27 +00:00
da42bdb7df Merge pull request #4628 from kippandrew/port-allocator
Fix port collision with dynamically allocated ports
Upstream-commit: abef5cb0fcd107c751b7390bc7eb45e3ecd675e6
Component: engine
2014-03-25 14:30:10 -07:00
e9aaf94539 Merge pull request #4794 from alexlarsson/dm-better-shutdown
devicemapper: Better/faster shutdown
Upstream-commit: 6643cc20fe16f36ffb3342bec61a3c0f24d2a9df
Component: engine
2014-03-25 14:03:00 -07:00
2ce68073b6 check if working dir is a directory and raise corresponding errors when making dir.
Docker-DCO-1.1-Signed-off-by: Liang-Chi Hsieh <viirya@gmail.com> (github: viirya)
Upstream-commit: 293157b8b38dd5ea5fa49d90501cc3c86717da40
Component: engine
2014-03-25 17:47:08 +08:00
f6d78803bd Promote btrfs
Docker-DCO-1.1-Signed-off-by: Michael Crosby <michael@crosbymichael.com> (github: crosbymichael)
Upstream-commit: 68dd722e3c54995e609b2524bad501ab1d4d15d6
Component: engine
2014-03-24 14:15:04 +00:00
aa948163e7 Revert "Disable automatic killing of containers when docker stop fails"
This reverts commit 8b5cf51d600dc4f3611cf063c52cf3448e7b01e5.

Docker-DCO-1.1-Signed-off-by: Michael Crosby <michael@crosbymichael.com> (github: crosbymichael)
Upstream-commit: d503714285143013d9fa6932ee5775fd155d26d2
Component: engine
2014-03-24 12:03:56 +00:00
fa8143af81 Add unit test for lxc conf merge and native opts
Docker-DCO-1.1-Signed-off-by: Michael Crosby <michael@crosbymichael.com> (github: crosbymichael)
Upstream-commit: 10fdbc0467d1be6c7c731d3f35590d87ee42f96f
Component: engine
2014-03-24 07:16:40 +00:00
9d6d07c6ea Add cpuset.cpus to cgroups and native driver options
Docker-DCO-1.1-Signed-off-by: Michael Crosby <michael@crosbymichael.com> (github: crosbymichael)
Upstream-commit: 9a7be1b015a1ba79e5480d0ddddfa5954b994507
Component: engine
2014-03-24 05:33:11 +00:00
08c755a87a Merge pull request #4800 from vieux/rename_network_driver
rename lxc to bridge
Upstream-commit: 97e5295f437bbb9eae26c99842b269aae1b427c2
Component: engine
2014-03-21 16:52:40 -07:00
2c4bdb6828 Add more native driver options
Docker-DCO-1.1-Signed-off-by: Michael Crosby <michael@crosbymichael.com> (github: crosbymichael)
Upstream-commit: 83618c2b81c561cd77fd70eca90b2b251f61fcc1
Component: engine
2014-03-21 14:07:16 +00:00
74929e5ece Change syntax to use dots
Docker-DCO-1.1-Signed-off-by: Michael Crosby <michael@crosbymichael.com> (github: crosbymichael)
Upstream-commit: 146a212f71fe129f9d349c5c3e80ba4197e35850
Component: engine
2014-03-21 12:38:50 +00:00
e56e4f3bca Change flag to -o and --opt
Docker-DCO-1.1-Signed-off-by: Michael Crosby <michael@crosbymichael.com> (github: crosbymichael)
Upstream-commit: c9d7f858fd1c6e2d1287e28ee12952333b327c75
Component: engine
2014-03-21 11:53:15 +00:00
fd04e06648 Factor out the native driver config options
Docker-DCO-1.1-Signed-off-by: Michael Crosby <michael@crosbymichael.com> (github: crosbymichael)
Upstream-commit: 7c726669cbcc0cfde12c6a9f03974bb672839271
Component: engine
2014-03-21 08:10:07 +00:00