Commit Graph

90 Commits

Author SHA1 Message Date
Vishnu Kannan 9bebc66042 Do not fail cgroups setup if parent cgroup does not exist.
Docker-DCO-1.1-Signed-off-by: Vishnu Kannan <vishnuk@google.com> (github: vishh)
2015-03-16 21:09:37 +00:00
Michael Crosby 9387ebb6ba Merge pull request #437 from hqhq/hq_fix_some_cgroups_issues
fix some cgroups issues
2015-03-10 14:04:10 -07:00
Qiang Huang 35c01f9eb3 add Set memoryswap test cases
Signed-off-by: Qiang Huang <h.huangqiang@huawei.com>
2015-03-09 10:25:12 +08:00
Qiang Huang a3b0209cc6 cgroups: don't use d.path for cgroup tests files
d.path() should be used to get the real cgroup path, for temp path,
we can just create one.

Signed-off-by: Qiang Huang <h.huangqiang@huawei.com>
2015-03-09 09:32:02 +08:00
Qiang Huang 606d9064b0 cgroups: only return path when subsystem really mounted
If cgroup patch doesn't exist, there is no point we do the Set.

Signed-off-by: Qiang Huang <h.huangqiang@huawei.com>
2015-03-09 09:16:56 +08:00
Rohit Jnagal 074441b495 Merge pull request #429 from hqhq/hq_use_FindCgroupMountRoot
fix apply error when we not mount cpu subsystem
2015-03-06 10:11:16 -08:00
HuKeping 4332ffcfc6 cgroups: add test for disable oom killer
Signed-off-by: Hu Keping <hukeping@huawei.com>
2015-03-07 02:49:34 +08:00
HuKeping 295c70865d cgroups: add support for oom control
This patch add support for diable OOM Killer.

Signed-off-by: Hu Keping <hukeping@huawei.com>
2015-03-07 02:49:31 +08:00
Qiang Huang 07db66a6ef fix apply error when we not mount cpu subsystem
Find cgroup mountpoint dir through a specific subsystem is not reliable,
we don't know which subsystem users will or will not mount, we can't
assume that, only we can assume is that users mount cgroup subsystems
on the same dir.

Signed-off-by: Qiang Huang <h.huangqiang@huawei.com>
2015-03-05 10:21:52 +08:00
Qiang Huang a8a798a7c9 cgroups: use Set instead of Apply in Freeze
So Apply function of freezer can be as sample as other subsystems.

Signed-off-by: Qiang Huang <h.huangqiang@huawei.com>
2015-03-04 13:45:44 +08:00
Qiang Huang 4077c254a6 add test cases for Set interfaces
Signed-off-by: Qiang Huang <h.huangqiang@huawei.com>
2015-03-04 08:43:59 +08:00
Qiang Huang 74005ed4e0 add function to get string value from cgroup file
Signed-off-by: Qiang Huang <h.huangqiang@huawei.com>
2015-03-04 08:42:56 +08:00
Qiang Huang 1db687f4f4 add Set api
Signed-off-by: Qiang Huang <h.huangqiang@huawei.com>
2015-03-04 08:42:35 +08:00
Qiang Huang cc524f1b72 add Set interface
Signed-off-by: Qiang Huang <h.huangqiang@huawei.com>
2015-03-04 08:42:04 +08:00
Qiang Huang 12a63757db rename Set to Apply
The name `Set` would be used to do dymanic changes of resource configs
in the future. For now, `Apply` also makes more sense.

Signed-off-by: Qiang Huang <h.huangqiang@huawei.com>
2015-03-04 08:37:55 +08:00
Michael Crosby f4cf808a3d Merge branch 'master' into api
Signed-off-by: Michael Crosby <crosbymichael@gmail.com>

Conflicts:
	MAINTAINERS
	cgroups/cgroups.go
	cgroups/fs/apply_raw.go
	cgroups/fs/notify_linux.go
	cgroups/fs/notify_linux_test.go
	cgroups/systemd/apply_systemd.go
	config.go
	configs/config_test.go
	console/console.go
	integration/exec_test.go
	integration/init_test.go
	integration/template_test.go
	integration/utils_test.go
	linux_notify.go
	linux_notify_test.go
	mount/init.go
	mount/mount_config.go
	mount/pivotroot.go
	mount/ptmx.go
	namespaces/create.go
	namespaces/exec.go
	namespaces/execin.go
	namespaces/init.go
	namespaces/nsenter/nsenter.c
	namespaces/nsenter/nsenter.go
	namespaces/utils.go
	network/network.go
	network/types.go
	network/veth.go
	notify_linux.go
	notify_linux_test.go
	nsinit/exec.go
	nsinit/main.go
	nsinit/nsenter.go
	nsinit/oom.go
	sample_configs/host-pid.json
	sample_configs/userns.json
	security/capabilities/capabilities.go
	update-vendor.sh
2015-02-16 15:09:42 -08:00
Michael Crosby 5fc19e8db5 Rename Fs fields to fs
Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
2015-02-11 11:20:08 -08:00
Victor Marmol e0de51f53c Retry getting the cgroup root at apply time.
This will allow late-binding of the cgroup hierarchy.

Fixes docker/docker#8791

Signed-off-by: Victor Marmol <vmarmol@google.com>
2015-02-06 11:04:25 -08:00
Michael Crosby 935d81f23d Flatten configuration structs
Change the various config structs into one package and have a flatter
structure for easier use.

Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
2015-01-31 19:56:27 -08:00
Andrey Vagin ca633b2f29 Merge remote-tracking branch 'origin/master' into api
Signed-off-by: Andrey Vagin <avagin@openvz.org>
2015-01-28 14:37:40 +03: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
Andrey Vagin 02c1de6f11 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: 13a5703 ("cgroups: don't change a freezer state if an operation failed")

Signed-off-by: Andrey Vagin <avagin@openvz.org>
2015-01-19 17:38:26 +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
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
Andrey Vagin 4eaff5e14e cgroups: don't change a freezer state if an operation failed
Signed-off-by: Andrey Vagin <avagin@openvz.org>
2015-01-15 01:45:49 +03:00
Andrey Vagin 083d91f8c3 cgroups: Add comments for methods of cgroup managers
Signed-off-by: Andrey Vagin <avagin@openvz.org>
2015-01-15 01:45:49 +03:00
Andrey Vagin ee6e585e21 cgroups: replace SetPaths on LoadCgroupManager
Signed-off-by: Andrey Vagin <avagin@openvz.org>
2015-01-15 00:44:14 +03:00
Andrey Vagin ba4257a146 new-api: add the Freezer method to cgroup.Manager
Signed-off-by: Andrey Vagin <avagin@openvz.org>
2015-01-15 00:43:14 +03:00
Andrey Vagin 6dd7552537 new-api: implement fs and systemd cgroup managers
Signed-off-by: Andrey Vagin <avagin@openvz.org>
2015-01-15 00:43:13 +03:00
Victor Marmol e3184f97e0 Don't get stats for cgroups that don't exist.
Signed-off-by: Victor Marmol <vmarmol@google.com>
2015-01-08 11:17:09 -08:00
Alexander Morozov c34b3d5ce9 Fix vet errors
Signed-off-by: Alexander Morozov <lk4d4@docker.com>
2014-12-29 10:57:01 -08:00
Alexander Morozov 9825a26db5 Refactor NotifyOnOOM a little
Now there is function NotifyOnOOM in libcontainer package, which
receives *libcontainer.State as argument.

Signed-off-by: Alexander Morozov <lk4d4@docker.com>
2014-12-22 11:44:41 -08:00
Qiang Huang 2aebf7d849 cgroups: add failcnt test
It was missed in the first place.

Signed-off-by: Qiang Huang <h.huangqiang@huawei.com>
2014-12-11 16:27:06 -08:00
Qiang Huang 9184d9473d cgroup: add support to set MemorySwap
Signed-off-by: Qiang Huang <h.huangqiang@huawei.com>
2014-12-11 09:40:55 -08:00
Qiang Huang e3b14402eb cgroups: add support for cpuset.mems
Signed-off-by: Qiang Huang <h.huangqiang@huawei.com>
2014-12-05 17:37:24 -08:00
Michael Crosby 75093be3c9 Always join fs.Cpuset reguardless of value
Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
2014-11-17 19:06:20 -08:00
Qiang Huang 9c7bd7cd9e libcontainer: setup cpuset cgroup by default
Currently if we don't use --cpuset, the cpuset cgroup is not
created, it's bad if we want to modify cpuset config subsequently,
change the behavior to make it right.

Signed-off-by: Qiang Huang <h.huangqiang@huawei.com>
2014-11-17 19:06:20 -08:00
Michael Crosby 29b1d2b23f Move RemovePaths into cgroups pkg for reuse
Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
2014-11-17 11:56:19 -08:00
Michael Crosby bc7efa6b81 Have cgroup.Apply return paths to setup cgroups
There is no reason to have a special type returned from the cgroups
Apply function for getting the paths and cleanup.  With access to the
paths we can just delete what we need.

Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
2014-11-17 11:56:19 -08:00
Donald Huang 6c6808e5bf Change arguments to fs.GetStats to be map[string]string
Allows us to remove systemd.GetPaths later

Signed-off-by: Donald Huang <don.hcd@gmail.com>
2014-11-17 11:56:19 -08:00
Alexandr Morozov 7da5ab8130 Fix vet errors
Signed-off-by: Alexandr Morozov <lk4d4@docker.com>
2014-11-05 15:38:58 -08:00
Abin Shahab b9c834b7aa ADDITIONAL CGROUPS BLKIO STATS
Currently github.com/docker/libcontainer/cgroups/fs.GetStats does not provide the following metrics:
blkio.io_wait_time, blkio.io_service_time, blkio.io_merged, and blkio.time.

This commits add these four metrics. The descriptions of the metrics are here: https://www.kernel.org/doc/Documentation/cgroups/blkio-controller.txt.

It also modifies blkio_test and stats_util_test to ensure that the metrics are parsed.

Docker-DCO-1.1-Signed-off-by: Abin Shahab <ashahab@altiscale.com> (github: ashahab-altiscale)
2014-10-21 06:28:08 +00:00
Ian Main d67a27ee13 Create an ApplyDevices call.
For our work on adding dynamic device support to Docker we needed to be
able to call this to update the list of allowed devices.  This works for
both systemd and fs based cgroups implementations.

Co-Authored-By: Chris Alfonso <calfonso@redhat.com> (github: calfonso)
Docker-DCO-1.1-Signed-off-by: Ian Main <imain@redhat.com> (github: imain)
2014-10-15 11:59:26 -07:00
Vishnu Kannan 4bfda8a764 Saturate negative memory stat values at '0'.
Docker-DCO-1.1-Signed-off-by: Vishnu Kannan <vishnuk@google.com> (github: vishh)
2014-09-24 16:47:41 +00:00
Victor Marmol 3cbe3eb3f6 Cache cgroup root mount location.
We calculate this on every cgroup call. It comprised of 30%+ of the CPU
usage in cAdvisor.

Docker-DCO-1.1-Signed-off-by: Victor Marmol <vmarmol@google.com> (github: vmarmol)
2014-09-10 17:44:13 -07:00
Victor Marmol 2636848328 Remove sampling from libcontainer CPU stats.
Sampling should be done by higher layer in configurable intervals. This
change removes the percentage stat as sampling is required for this.

Docker-DCO-1.1-Signed-off-by: Victor Marmol <vmarmol@google.com> (github: vmarmol)
2014-08-30 09:58:27 -07:00
Johannes 'fish' Ziemke 78700bfea3 Use blkio.throttle.* stats when CFQ is not in use
This makes blkio's GetStats try to read blkio.io_serviced_recursive
first and fall back to read the stats from blkio.throttle in case it
can't. blkio.io_serviced_recursive seems to be available across all
kernels with CFQ enabled.

This closes #165

Signed-off-by: Johannes 'fish' Ziemke <github@freigeist.org>
2014-08-27 15:01:46 +02:00
Michael Crosby a117d3a1c0 Ignore not found erros in Paths
Signed-off-by: Michael Crosby <michael@docker.com>
2014-08-20 10:39:48 -07:00
Michael Crosby 3cdf12b041 Change not found error to be typed with cgroup subsystem
Signed-off-by: Michael Crosby <michael@docker.com>
2014-08-20 10:32:01 -07:00