Commit Graph

60 Commits

Author SHA1 Message Date
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
Rohit Jnagal c1d25c185e Add a standalone test utility for cgroup package.
Although it has some overlap with nsinit utility, it is useful to test
cgroup functinality directly and try out new or internal features not
exposed through nsinit.

It still needs some work as I haven't added enough systemd support yet.
I also need to expose an enter method.

Docker-DCO-1.1-Signed-off-by: Rohit Jnagal <jnagal@google.com> (github: rjnagal)
2014-07-09 01:21:26 +00:00
Rohit Jnagal 8e3130d7fd Merge pull request #75 from vmarmol/fix-stats
Ignore stats that are not available
2014-07-08 14:31:16 -07:00
Victor Marmol b18a4fdf2e Ignore stats that are not available
Closes #13

Docker-DCO-1.1-Signed-off-by: Victor Marmol <vmarmol@google.com> (github: vmarmol)
2014-07-08 14:25:55 -07:00
Rohit Jnagal d712d29b9a Add a cleanup method to cgroup fs. This will help in building a
standalone cgroup test util. systemd does auto cleanup on empty, so
doesn't need an extra interface.

Docker-DCO-1.1-Signed-off-by: Rohit Jnagal <jnagal@google.com> (github: rjnagal)
2014-07-08 18:49:45 +00:00
Michael Crosby f6ada60a68 Merge pull request #48 from crosbymichael/add-oom-event
Add oom notify event
2014-06-25 11:56:28 -07:00
Michael Crosby 775666b733 Fix nits on chan direction and defer
Closes #9
Docker-DCO-1.1-Signed-off-by: Michael Crosby <michael@docker.com> (github: crosbymichael)
2014-06-24 12:08:03 -07:00
Victor Marmol f9b158da02 Don't fail getting stats of unknown hierarchies.
Docker-DCO-1.1-Signed-off-by: Victor Marmol <vmarmol@google.com> (github: vmarmol)
2014-06-19 21:32:38 -07:00
Bernerd Schaefer cc266ed54c CpuStats.CpuUsage includes TotalUsage
Docker-DCO-1.1-Signed-off-by: Bernerd Schaefer <bj.schaefer@gmail.com> (github: bernerdschaefer)
2014-06-19 15:43:12 +02:00
Bernerd Schaefer 9fa6481d98 Add fs.NotifyOnOOM for out-of-memory notifications
Docker-DCO-1.1-Signed-off-by: Bernerd Schaefer <bj.schaefer@gmail.com> (github: bernerdschaefer)
2014-06-19 12:27:34 +02:00
Alexander Larsson e0e0da9e28 pkg/cgroups Add GetCgroupMounts() and GetAllSubsystems()
This lists all currently mounted cgroups and all supported cgroup
subsystems on the machine.

Docker-DCO-1.1-Signed-off-by: Alexander Larsson <alexl@redhat.com> (github: alexlarsson)
2014-06-16 17:16:10 +02:00
LK4D4 0c2c75b12a Fix vet errors
Docker-DCO-1.1-Signed-off-by: Alexandr Morozov <lk4d4math@gmail.com> (github: LK4D4)
2014-06-12 09:52:31 +04:00
Michael Crosby 6ab3ef56f4 Update imports for new repository path 2014-06-10 08:14:16 -07:00
Michael Crosby eec4c0b965 Merge pull request #6198 from vishh/stats2
Add more stats to libcontainer.
2014-06-04 15:28:19 -07:00
Vishnu Kannan 7b4689667b Add stats for memory allocation failure count and instantaneous cpu usage in the usermode and kernelmode.
Docker-DCO-1.1-Signed-off-by: Vishnu Kannan <vishnuk@google.com> (github: vishh)
2014-06-04 21:20:21 +00:00
Victor Vieux 3e8849fa76 implement wait on freeze
Docker-DCO-1.1-Signed-off-by: Victor Vieux <vieux@docker.com> (github: vieux)
2014-06-04 02:21:10 +00:00
Michael Crosby 6d28b828ef Don't rejoin the cgroup each time
Docker-DCO-1.1-Signed-off-by: Michael Crosby <michael@crosbymichael.com> (github: crosbymichael)
2014-06-03 15:24:30 -07:00
Michael Crosby 5d1ebaf4c3 Implement systemd support for freezer
These PR does a few things.  It ensures that the freezer cgroup is
joined in the systemd driver.  It also provides a public api for setting
the freezer state via the cgroups package.
Docker-DCO-1.1-Signed-off-by: Michael Crosby <michael@crosbymichael.com> (github: crosbymichael)
2014-06-03 10:46:53 -07:00
Alexander Larsson 03044f6378 libcontainer/cgroup: Use raw access to set up and join the devices cgroup
The systemd support for the devices cgroup lacks two required features:
 * Support for wildcards to allow mknod on any device
 * Support for wildcards to allow /dev/pts support

The second is available in more recent systemd as "char-pts", but not in e.g. v208 which is in wide use.

Additionally, the current approach of letting systemd set up the devices cgroup and then adding
some devices to it doesn't work, because some times systemd (at least v208) re-initializes
the devices cgroup, overwriting our custom devices. See https://github.com/dotcloud/docker/issues/6009
for the details.

When wildcarded mknod support is available in systemd we should implement a pure systemd version,
but we need to keep the old one around for backwards compat.

Docker-DCO-1.1-Signed-off-by: Alexander Larsson <alexl@redhat.com> (github: alexlarsson)
2014-06-03 11:34:14 +02:00
Victor Marmol 564bd1ca35 Merge pull request #6153 from vishh/stats1
Add per cpu usage to libcontainer  stats
2014-06-02 17:53:17 -07:00
Michael Crosby 90d09c83e2 Update cpu stat test for no error
Docker-DCO-1.1-Signed-off-by: Michael Crosby <michael@crosbymichael.com> (github: crosbymichael)
2014-06-02 11:54:23 -07:00
Vishnu Kannan 769a1380b7 Adding percpu usage to cgroup stats reported by libcontainer.
Docker-DCO-1.1-Signed-off-by: Vishnu Kannan <vishnuk@google.com> (github: vishh)
2014-06-02 06:56:15 +00:00
Vishnu Kannan 953f6da166 Adding "stats" and "spec" option to nsinit binary which will print the stats and spec respectively.
Docker-DCO-1.1-Signed-off-by: Vishnu Kannan <vishnuk@google.com> (github: vishh)
2014-06-02 06:37:22 +00:00