Commit Graph

152 Commits

Author SHA1 Message Date
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
Michael Crosby c2a80eb59f Ensure all dev nodes are copied for privileged
This also makes sure that devices are pointers to avoid copies
Docker-DCO-1.1-Signed-off-by: Michael Crosby <michael@crosbymichael.com> (github: crosbymichael)
2014-05-30 18:39:11 -07:00
unclejack ed29012159 Merge pull request #6097 from timthelion/consistentdevices
Refactor device handling code
2014-05-31 03:34:52 +03:00
Timothy Hobbs 18f6a5aaf4 Refactor device handling code
We now have one place that keeps track of (most) devices that are allowed and created within the container.  That place is pkg/libcontainer/devices/devices.go

This fixes several inconsistencies between which devices were created in the lxc backend and the native backend.  It also fixes inconsistencies between wich devices were created and which were allowed.  For example, /dev/full was being created but it was not allowed within the cgroup.  It also declares the file modes and permissions of the default devices, rather than copying them from the host.  This is in line with docker's philosphy of not being host dependent.

Docker-DCO-1.1-Signed-off-by: Timothy Hobbs <timothyhobbs@seznam.cz> (github: https://github.com/timthelion)
2014-05-30 19:21:29 +00:00
Vishnu Kannan a4b8bef91b Added a new method cgroups.GetStats() which will return a cgroups.Stats object which will contain all the available cgroup Stats.
Remove old Stats interface in libcontainers cgroups package.
Changed Stats to use unit64 instead of int64 to prevent integer overflow issues.
Updated unit tests.

Docker-DCO-1.1-Signed-off-by: Vishnu Kannan <vishnuk@google.com> (github: vishh)
2014-05-29 20:16:49 +00:00
Vishnu Kannan 0b580ff32d Added stats.go which provides strong types for all stats that will be exported by libcontainer. This commit only introduces the strong type.
Docker-DCO-1.1-Signed-off-by: Vishnu Kannan <vishnuk@google.com> (github: vishh)
2014-05-23 20:42:43 +00:00
Victor Marmol 6521880a83 Make all cgroup stats output int64s instead of float64.
Docker-DCO-1.1-Signed-off-by: Victor Marmol <vmarmol@google.com> (github: vmarmol)
2014-05-22 20:53:36 +00:00
Michael Crosby fc6d231773 Move get pid into cgroup implementation
Docker-DCO-1.1-Signed-off-by: Michael Crosby <michael@crosbymichael.com> (github: crosbymichael)
2014-05-21 21:14:07 +00:00
Alexander Larsson 6de35476ec cgroups: Allow mknod for any device in systemd cgroup backend
Without this any container startup fails:
2014/05/20 09:20:36 setup mount namespace copy additional dev nodes mknod fuse operation not permitted

Docker-DCO-1.1-Signed-off-by: Alexander Larsson <alexl@redhat.com> (github: alexlarsson)
2014-05-20 09:29:32 +02:00
Michael Crosby 15e734a277 Remove the cgroups maintainer file
We don't need this because it is covered by the libcontainer MAINTAINERS
file
Docker-DCO-1.1-Signed-off-by: Michael Crosby <michael@crosbymichael.com> (github: crosbymichael)
2014-05-14 16:01:45 -07:00
Michael Crosby 3ce347c35f Move cgroups package into libcontainer
Docker-DCO-1.1-Signed-off-by: Michael Crosby <michael@crosbymichael.com> (github: crosbymichael)
2014-05-14 15:21:44 -07:00