Commit Graph

82 Commits

Author SHA1 Message Date
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
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
Mrunal Patel 6423c8d261 Merge pull request #307 from LK4D4/systemd_notify_oom
OOM Notify refactoring
2014-12-23 09:15:50 -08:00
Alexander Morozov 6feb7bda04 Fix removing of cgroups if something still alive in container
Now we try to remove cgroups 5 times with increased delay between
tries.

Signed-off-by: Alexander Morozov <lk4d4@docker.com>
2014-12-22 14:34:58 -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 5b623a6e43 Remove cgutil cli application as it is not being used
Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
2014-11-17 11:56:19 -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
Michael Crosby 5cacd48132 Remove systemd.GetStats
Because we are using the paths that are created when we initially setup
cgroups for a container we no longer have to dynamically generates them
when a user requests stats.  This allows us to fully use the fs stats
code without having system create it's paths.

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
Donald Huang 1aafba9f87 Fix typo in json tag
throlling_data -> throttling_data

Signed-off-by: Donald Huang <don.hcd@gmail.com>
2014-11-11 23:34:55 +00: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
Alexander Larsson 06949e779f pkg/cgroups: Export ParseCgroupFile
This is needed for the libvirt exec driver.

Docker-DCO-1.1-Signed-off-by: Alexander Larsson <alexl@redhat.com> (github: alexlarsson)
Docker-DCO-1.1-Signed-off-by: Josh Poimboeuf <jpoimboe@redhat.com> (github: jpoimboe)
2014-10-07 15:55:58 +02: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
Michael Crosby 4aa9963faf Return NotFound error for cgroups abs paths
Signed-off-by: Michael Crosby <michael@docker.com>
2014-08-20 10:14:56 -07:00
Alexandr Morozov 388d143d19
Remove dependency from docker/pkg/systemd
Signed-off-by: Alexandr Morozov <lk4d4math@gmail.com>
2014-08-19 20:16:39 +04:00
Michael Crosby 781855b62a Cleanup systemd cgroup code
The current paths for the different systemd cgroup subsystems that
systemd manages and that we have to manage are very inconsistent.  This
patch cleans up those differences and allows consistent paths to be
used.

Signed-off-by: Michael Crosby <michael@docker.com>
2014-08-13 18:16:51 -07:00
Vishnu Kannan 97de9a45f9 Update cgroups paths in state to be a map with cgroup type as key and path as value.
Docker-DCO-1.1-Signed-off-by: Vishnu Kannan <vishnuk@google.com> (github: vishh)
2014-08-13 23:26:27 +00:00
Vishnu Kannan ad16526d7f Store all the cgroups paths as part of the state. This simplifies entering cgroups and will be useful for
cleanups too in the future.
Docker-DCO-1.1-Signed-off-by: Vishnu Kannan <vishnuk@google.com> (github: vishh)
2014-08-13 23:26:27 +00:00
Vishnu Kannan ae08910fde Enter cgroups as part of nsenter while using systemd.
Docker-DCO-1.1-Signed-off-by: Vishnu Kannan <vishnuk@google.com> (github: vishh)
2014-08-13 23:26:27 +00:00
Vishnu Kannan ae64fd1e58 Enter cgroups while entering namespaces as part of NsEnter.
Docker-DCO-1.1-Signed-off-by: Vishnu Kannan <vishnuk@google.com> (github: vishh)
2014-08-13 23:26:27 +00:00
Nicholas Weaver 8478f0d76d Removed an extra float64()
Docker-DCO-1.1-Signed-off-by: Nicholas Weaver <lynxbat@gmail.com> (github: lynxbat)
2014-08-12 11:45:34 -07:00
Nicholas Weaver b2a1bff2d4 Merge branch 'master' of https://github.com/docker/libcontainer into 145-PercentUsage 2014-08-08 11:18:12 -07:00
Nicholas Weaver 8597998244 Fixes logic for calculating percentage for cgroups.Stats.CpuStats.CpuUsage.PercentUsage
Previous logic divided a uint64 by a uint64 losing precision before multiplying by clock ticks and cpus
This fix maintains precision before converting back to uint64

Docker-DCO-1.1-Signed-off-by: Nicholas Weaver <lynxbat@gmail.com> (github: lynxbat)
2014-08-07 16:22:35 -07:00
Vishnu Kannan e5e40b6ef0 Docker 'runin' demands passing flags before 'nsenter' cli option.
Docker does not require RunIn API. Hence that API has been removed.
nsinit CLI has been modified to work around the nsenter changes.

Docker-DCO-1.1-Signed-off-by: Vishnu Kannan <vishnuk@google.com> (github: vishh)
2014-08-05 22:13:23 +00:00
Peter Bourgon c6edb4ad96 Only import "testing" from *_test.go
This prevents the testing package flags from leaking into the
flagsets of binaries that import libcontainer.

Docker-DCO-1.1-Signed-off-by: Peter Bourgon <peter@bourgon.org> (github: peterbourgon)
2014-07-30 18:15:12 +02:00
Vishnu Kannan 66aee74b1e Libcontainer fs.GetStats() will not look for cgroups relative to the cgroup of init process if the parent
in cgroups.Cgroup is absolute. This is required to get stats of other containers while running inside a docker container.

Docker-DCO-1.1-Signed-off-by: Vishnu Kannan <vishnuk@google.com> (github: vishh)
2014-07-29 05:08:04 +00:00
Michael Crosby 4568ca76c8 Update imports for new docker location
Docker-DCO-1.1-Signed-off-by: Michael Crosby <michael@docker.com> (github: crosbymichael)
2014-07-24 14:28:49 -07:00
Victor Marmol de63d7006b Small fix for GetAllCgroups().
Incorrect parsing of length of fields.

Docker-DCO-1.1-Signed-off-by: Victor Marmol <vmarmol@google.com> (github: vmarmol)
2014-07-21 18:55:06 -07:00
Michael Crosby 8947d07576 Finish removing the dependency on docker/pkg/system
Fixes #92
Docker-DCO-1.1-Signed-off-by: Michael Crosby <michael@docker.com> (github: crosbymichael)
2014-07-14 17:00:05 -07:00
Victor Marmol 8de8fe9272 Remove FreezerStats.
They are really freezer state and we'll move them through another
interface.

Docker-DCO-1.1-Signed-off-by: Victor Marmol <vmarmol@google.com> (github: vmarmol)
2014-07-13 16:14:05 -07:00
Michael Crosby 7e1cfc1f6a Dont fail on missing subsystem for systemd stats
Docker-DCO-1.1-Signed-off-by: Michael Crosby <michael@docker.com> (github: crosbymichael)
2014-07-11 12:05:59 -07:00
Michael Crosby 50106c7490 Fix nsinit function to get stats from systemd
Docker-DCO-1.1-Signed-off-by: Michael Crosby <michael@docker.com> (github: crosbymichael)
2014-07-11 12:00:27 -07:00
Jimmi Dyson cbd37fba86 Add systemd stats, reusing fs stats functionality
Docker-DCO-1.1-Signed-off-by: Jimmi Dyson <jimmidyson@gmail.com> (github: jimmidyson)
2014-07-11 11:43:08 -07:00
Michael Crosby 1e643a7d2e Merge pull request #79 from rjnagal/cgroup_testing
Add a standalone test utility for cgroup package.
2014-07-10 11:20:48 -07:00
Rohit Jnagal 0916444691 Improved comment and names.
Docker-DCO-1.1-Signed-off-by: Rohit Jnagal <jnagal@google.com> (github: rjnagal)
2014-07-09 16:54:55 +00:00
Rohit Jnagal dceaa2e7b3 Cleanup checks for non-existent cgroup file to be concise.
Docker-DCO-1.1-Signed-off-by: Rohit Jnagal <jnagal@google.com> (github: rjnagal)
2014-07-09 16:39:38 +00:00