Commit Graph

864 Commits

Author SHA1 Message Date
Brandon Philips 99233fde8c cgroups: systemd: set DefaultDependencies=false if possible
The root problem this fixes is the docker daemon uses DefaulDependencies
for all of its scopes which means that the containers get killed by
systemd before the docker daemon is notified to shutdown. This means
that a docker run in a service file won't get ordered properly on
shutdown! This has affected many CoreOS users and is documented in
systemd as so:

"Unless DefaultDependencies=false is used, scope units will implicitly
have dependencies of type Conflicts= and Before= on shutdown.target."

Unfortunately, systemd didn't allow setting DefaultDependencies=false on
transient units until today:

    systemd-run --scope --property="DefaultDependencies=false" /usr/bin/sleep 50000
    Unknown assignment DefaultDependencies=false.
    Failed to create message: Invalid argument

Fixed here:
http://cgit.freedesktop.org/systemd/systemd/commit/?id=261420ba2a20305ad271b6f5f380aa74c5c9dd50

Discussion with systemd upstream:
http://lists.freedesktop.org/archives/systemd-devel/2014-December/026313.html
http://lists.freedesktop.org/archives/systemd-devel/2015-February/027890.html

Tested with docker and systemd master as of today and it work for me.

Signed-off-by: Brandon Philips <brandon.philips@coreos.com>
2015-02-03 22:25:27 -05:00
Victor Marmol 2da44f8c7b Merge pull request #358 from avagin/capabilities
namespaces: allow to use pid namespace without mount namespace
2015-02-03 15:05:54 -08:00
Andrey Vagin 21c344a479 update vendor/src/github.com/syndtr/gocapability/
Signed-off-by: Andrey Vagin <avagin@openvz.org>
2015-02-04 01:22:25 +03:00
Andrey Vagin 444cc2989a namespaces: allow to use pid namespace without mount namespace
The gocapability package uses /proc/PID/status to get a bounding set.
If a container uses pidns without mntns, it sees /proc from the host
namespace, but the process doesn't know its own pid in this namespace.

In this case it can use /proc/self/status, which is always the right one.

Signed-off-by: Andrew Vagin <avagin@openvz.org>
2015-02-04 01:01:43 +03:00
Mrunal Patel e59984353a Merge pull request #356 from LK4D4/vet_checks
Add vet check to .drone.yml
2015-01-30 14:31:55 -08:00
Alexander Morozov 0890cc54a9 Add vet check to .drone.yml
Signed-off-by: Alexander Morozov <lk4d4@docker.com>
2015-01-30 14:18:33 -08:00
Victor Marmol 3c52181f61 Merge pull request #353 from LK4D4/update_dbus
Update github.com/godbus/dbus to v2
2015-01-29 15:46:05 -08:00
Alexander Morozov 689e8ec949 Update github.com/godbus/dbus to v2
Signed-off-by: Alexander Morozov <lk4d4@docker.com>
2015-01-29 15:35:22 -08:00
Rohit Jnagal 2fac2dad91 Merge pull request #341 from shishir-a412ed/master
Created man page for nsinit
2015-01-29 14:00:07 -08:00
Shishir Mahajan e9f8f8528a Created man page for nsinit
Signed-off-by: Shishir Mahajan <shishir.mahajan@redhat.com>
2015-01-29 16:33:08 -05:00
Victor Marmol c37b9125ec Merge pull request #344 from hqhq/hq_fix_systemd_device
cgroups: always create device cgroup on systemd
2015-01-29 11:39:07 -08:00
Michael Crosby e05f807a89 Merge pull request #349 from LK4D4/replace_wait_for_wait4
Use Wait4 instead of cmd.Wait
2015-01-26 13:07:54 -08:00
Alexander Morozov 39fbf0a904 Use cmd.Process.Wait instead of cmd.Wait
Issue with cmd.Wait is that it is waiting for closing pipes and if we
have forked processes which inherited pipes from parent, then we need to
kill them to unblock cmd.Wait.

Should fix docker/docker#10303

Now idea is next:
- cmd.Process.Wait for init process dead
- Kill remaining processes in cgroup (pipes closed as side effect)
- use cmd.Wait for waiting pipes flushed to client

Signed-off-by: Alexander Morozov <lk4d4@docker.com>
2015-01-26 12:54:52 -08:00
Mrunal Patel 045e9ae4a0 Merge pull request #347 from guoxiuyan/master
Fix a minor typo
2015-01-25 18:44:12 -08:00
guoxiuyan 7d9244eab2 Fix a minor typo
Signed-off-by: Guo Xiuyan <guoxiuyan@huawei.com>
2015-01-26 09:41:22 +08:00
Mrunal Patel cab4b9bce1 Merge pull request #345 from fabiokung/allow-readonly-rootfs
Support read-only root filesystems
2015-01-22 16:02:57 -08:00
Fabio Kung 2a452c17aa Support read-only root filesystems
The only place I could find where libcontainer tries to write to the
container's root FS is when setting up the pivot dir, to be used on
pivot_root(2).

This makes the pivot base dir configurable, so a read-only FS can be
used as root FS of containers. Users can then specify a writeable
subpath to be used as pivot inside the container.

Signed-off-by: Fabio Kung <fabio@heroku.com> (github: fabiokung)
2015-01-22 13:58:41 -08:00
Qiang Huang 46573774a2 cgroups: simplify the join_memory check
If c.Memory=0, there is no point to set memoryswap.

Signed-off-by: Qiang Huang <h.huangqiang@huawei.com>
2015-01-22 12:19:40 +08:00
Qiang Huang c4821b6f3e cgroups: always create device cgroup on systemd
This is the same behavior as fs does.

Signed-off-by: Qiang Huang <h.huangqiang@huawei.com>
2015-01-22 09:53:30 +08:00
Michael Crosby 3fbf185602 Merge pull request #337 from hqhq/hq_add_blkio_weight
add support for blkio.weight
2015-01-20 10:40:12 -08:00
Michael Crosby 5847aacb32 Merge pull request #340 from mrunalp/check_ns_flags
Checks namespace flags for user ns code path.
2015-01-20 10:39:23 -08:00
Mrunal Patel bde8bf2ebc Adds namespace flag checks to userns setup.
Signed-off-by: Mrunal Patel <mrunalp@gmail.com> (github: mrunalp)
2015-01-20 13:26:59 -05:00
Mrunal Patel 107bad0ee5 Adds namespace flag checks for userns code path in init.
Signed-off-by: Mrunal Patel <mrunalp@gmail.com> (github: mrunalp)
2015-01-20 13:26:20 -05:00
Mrunal Patel 9303a8f15f Merge pull request #324 from avagin/namespaces
namespace: don't change namespaces which are not belonged to the CT
2015-01-20 09:31:24 -08:00
Andrey Vagin ef73d7e235 namespace: don't change namespaces which are not belonged to the CT
An error is reported if a config file contains configuration for
shared namespaces.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
2015-01-20 15:05:00 +03:00
Alexander Morozov b89cd0cf5c Merge pull request #304 from mrunalp/feature/user_namespaces
Adds user namespace support to libcontainer
2015-01-19 11:55:20 -08:00
Mrunal Patel b0eece8d7d Adds support for User Namespaces.
Signed-off-by: Mrunal Patel <mrunalp@gmail.com> (github: mrunalp)

Adds sample configuration to test user namespaces.
Signed-off-by: Mrunal Patel <mrunalp@gmail.com> (github: mrunalp)

Rebases to master.
Signed-off-by: Mrunal Patel <mrunalp@gmail.com> (github: mrunalp)

Fixes integration tests.
Signed-off-by: Mrunal Patel <mrunalp@gmail.com> (github: mrunalp)

Move selinux labeling, apparmor profile and restrict kernel files back to init.

Signed-off-by: Mrunal Patel <mrunalp@gmail.com> (github: mrunalp)

Separate the code paths for userns and default cases.

Signed-off-by: Mrunal Patel <mrunalp@gmail.com> (github: mrunalp)

tty not required for setup

Signed-off-by: Mrunal Patel <mrunalp@gmail.com> (github: mrunalp)

Cleanup and address review comments.

Signed-off-by: Mrunal Patel <mrunalp@gmail.com> (github: mrunalp)

Remove debug logs and other cleanup.

Signed-off-by: Mrunal Patel <mrunalp@gmail.com> (github: mrunalp)

Use function paramaters for SetupContainer.

Signed-off-by: Mrunal Patel <mrunalp@gmail.com> (github: mrunalp)
2015-01-19 14:50:21 -05:00
Mrunal Patel eb74393a3d Merge pull request #338 from avagin/fixes
cgroups: set a freezer state before calling FreezerGroup.Set()
2015-01-19 09:33:08 -08:00
Andrey Vagin e451df796a namespace: don't create needless namespaces
A non-zero Path field for a namespace says that a process should attach to an
existing namespace, so the process can be forked without the flag for this
namespace.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
2015-01-19 18:43:16 +03:00
Andrey Vagin 30b3306416 cgroups: set a freezer state before calling FreezerGroup.Set()
My previous patch moved the setting of the freezer state after the Set()
command. It's wrong, because this command uses it, so we need to set the
freezer state before the command and rollback it in an error case.

Fixes: 13a5703d85 ("cgroups: don't change a freezer state if an operation failed")

Signed-off-by: Andrey Vagin <avagin@openvz.org>
2015-01-19 17:26:34 +03:00
Qiang Huang 54968f68bc add support for blkio.weight
Signed-off-by: Qiang Huang <h.huangqiang@huawei.com>
2015-01-19 14:33:48 +08:00
Michael Crosby 73ba097bf5 Merge pull request #336 from dqminh/execin-wait
nsenter waits for parent signal before forking
2015-01-16 14:51:02 -08:00
Daniel, Dao Quang Minh 5a87153824 fix TestNsenterAlivePid
unblock the nsenter-exec test process to let it finish succesfully

Signed-off-by: Daniel, Dao Quang Minh <dqminh89@gmail.com>
2015-01-16 05:13:19 -05:00
Daniel, Dao Quang Minh f5dfd9a702 nit: reindent with indent -linux
Signed-off-by: Daniel, Dao Quang Minh <dqminh89@gmail.com>
2015-01-16 04:58:30 -05:00
Daniel, Dao Quang Minh 9946e299af nsenter waits for parent signal before forking
this allows the parent to place the process into cgroup first so it can track
the children properly

Docker-DCO-1.1-Signed-off-by: Daniel, Dao Quang Minh <dqminh89@gmail.com> (github: dqminh)
2015-01-16 04:56:45 -05:00
Victor Marmol 29ba9b3179 Merge pull request #335 from avagin/fixes
cgroups: don't change a freezer state if an operation failed
2015-01-15 08:25:10 -08:00
Andrey Vagin 13a5703d85 cgroups: don't change a freezer state if an operation failed
Signed-off-by: Andrey Vagin <avagin@openvz.org>
2015-01-15 19:03:18 +03:00
Mrunal Patel 1d3b2589d7 Merge pull request #328 from icecrime/signal_exit_code
Fix exit codes when dying on a signal
2015-01-12 17:29:26 -08:00
Victor Marmol dd6bc28afb Merge pull request #329 from crosbymichael/oom-nsinit
Add nsinit command to display oom notifications
2015-01-12 16:39:16 -08:00
Michael Crosby 4bbd44784c Add nsinit command to display oom notifications
This adds the ability to receive OOM notifications for a container via
the `nsinit oom` command.

Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
2015-01-12 16:37:33 -08:00
Arnaud Porterie fec4c5ab0a Fix exit codes when dying on a signal
Test the process WaitStatus for a signal, and return an exit code of 128
+ signal which killed the process. Fixes docker/docker#9979.

Signed-off-by: Arnaud Porterie <arnaud.porterie@docker.com>
2015-01-12 16:20:31 -08:00
Victor Marmol 9377591781 Merge pull request #326 from estesp/add-multiarch-info
Update ROADMAP.md to correctly reflect current arch status
2015-01-12 14:28:56 -08:00
Michael Crosby 6460fd7966 Merge pull request #327 from crosbymichael/refactor-killAllPids
Refactor kill all pids
2015-01-12 10:36:59 -08:00
Mrunal Patel ba613c5a84 Merge pull request #315 from avagin/nsenter
A few fixes for nsenter
2015-01-12 10:36:20 -08:00
Michael Crosby 4903df2ed5 Refactor killAllPids
This refactors the function to avoid two calls to FindProcess

Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
2015-01-12 10:31:31 -08:00
Michael Crosby 2d9ef3af72 Add config for running a container in host pid ns
Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
2015-01-12 10:29:41 -08:00
Michael Crosby 09809b551c Merge pull request #320 from rhatdan/pidns
killall processes in a cgroup if you are not using the pid namespace
2015-01-12 10:18:48 -08:00
Phil Estes 50f0faa795 Update ROADMAP.md to correctly reflect current arch status
Adds POWER (ppc64 and ppc64le), System z (s390x), and ARM to list of
architectures currently supported by libcontainer

Docker-DCO-1.1-Signed-off-by: Phil Estes <estesp@linux.vnet.ibm.com> (github: estesp)
2015-01-12 12:58:27 -05:00
Andrey Vagin 35ae1c4871 nsenter: add a macros to print errors
Signed-off-by: Andrey Vagin <avagin@openvz.org>
2015-01-12 07:56:12 +03:00
Andrey Vagin 85cd86999f nsenter: use %m instead of strerror(errno)
Signed-off-by: Andrey Vagin <avagin@openvz.org>
2015-01-12 07:56:12 +03:00