Commit Graph

762 Commits

Author SHA1 Message Date
Michael Crosby 84ad9386a0 Merge pull request #184 from erikh/slave_mounts
Allow mounts to be supplied with the MS_SLAVE option.
2014-09-09 10:34:34 -07:00
Steve Powell 8453bee1ca Unify the errors ProcessConfigInvalid and ConfigInvalid to avoid caller confusion.
There is no check that these are being confused since they are both in the same type.

Signed-off-by: Steve Powell <spowell@pivotal.io>
2014-09-05 10:08:11 -07:00
Steve Powell 67e4c76c16 Inject errors into ioutil.ReadDir calls from devices.go
Added ioutilReadDir variable and test following the pattern
established by osLstat.

Signed-off-by: Steve Powell <spowell@pivotal.io>
2014-09-04 17:00:09 -07:00
Steve Powell 28e964bac6 Inject errors into os.Lstat call from devices.go
Since the caller of os.Lstat in devices.go is a function (not a method),
we use a variable to allow os.Lstat to be substituted during testing.

In this case the variable osLstat is private to the devices package to
prevent abuse. So the testcase needs to reside in the same package.

This commit includes a simple test of GetDevices() using osLstat to
simulate an error being returned from os.Lstat. In this case, the
behaviour of GetDevices() in the error case is trivial, but this may
change.

This is just the beginning of error injection. In future, it may be
necessary to pull out repetitive code sequences into a common file.

Signed-off-by: Steve Powell <spowell@pivotal.io>
2014-09-04 16:34:51 -07:00
Glyn Normington 582b25986d Add rich errors to the API
Add a rich Error type to the libcontainer package and use it in the API so
that callers can:

  * Check for a specific error without depending on an error string,
  * Obtain the stack trace of the function or method which detected the error.

The Error type provides a typed error code and a stack trace. The error code
identifies the error and enables the caller to test for it without being
sensitive to changes in the error text. The stack trace identifies the point
at which the error was detected. The combination of error code and stack trace
will enable errors to be diagnosed much more easily and with less guesswork
than when raw string-based errors are used.

The Error type conforms to the error interface and its Error method prints a
short error message. The Detail method provides a verbose error message
including the stack trace.

Notes:

1. There is an unfortunate precedent in the Go standard library which uses
variables to define errors. Checking for a specific error involves a string
comparison and assumes the corresponding variable has not been updated. It is
more robust and efficient to identify errors with integer-based types and
associated constants, although errors should still include a string
description for ease of use by humans.

2. It is not feasible to assign distinct types to Factory and Container
error codes because common errors such as SystemError cannot be declared in
two places and the names of the error codes then need to be decorated. This is
less readable.

Signed-off-by: Steve Powell <spowell@pivotal.io>
2014-09-04 15:01:09 -07:00
Michael Crosby 318d845931 Merge pull request #172 from cf-guardian/create-api
Correct Create() api call description in Factory interface.
2014-09-04 09:07:49 -07:00
Erik Hollensbe 73db17b4d7 Allow mounts to be supplied with the MS_SLAVE option.
Docker-DCO-1.1-Signed-off-by: Erik Hollensbe <github@hollensbe.org> (github: erikh)
2014-09-03 19:37:48 -07:00
Steve Powell 24e7b86a87 Remove erroneous reference to `path` in description and error list;
add format description for `id` string;
add "invalid format" error for `id` string;
remove initial capitals on references to parameter names;
remove reference to `initialConfig`;
add description of id checking.

Signed-off-by: Steve Powell <spowell@pivotal.io>
2014-09-03 17:30:13 -07:00
Victor Marmol 395d842ab4 Merge pull request #174 from vmarmol/no-sleep
Remove sampling from libcontainer CPU stats.
2014-09-03 16:09:59 -07:00
Victor Marmol 40d371a735 Merge pull request #173 from crosbymichael/device-ownership
Get UID and GID for device nodes
2014-09-02 10:16:17 -07:00
Victor Marmol d2a3ff2620 Merge pull request #170 from soundcloud/syncpipe-read-before-close-child
syncpipe: consume from parent before closing child
2014-09-02 10:05:20 -07:00
Michael Crosby 55f3560c3e Get UID and GID for device nodes
Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
2014-09-01 17:29:50 -07:00
Bernerd Schaefer 1faa2b56df syncpipe: read from parent before reporting error
Docker-DCO-1.1-Signed-off-by: Bernerd Schaefer <bj.schaefer@gmail.com> (github: bernerdschaefer)
2014-09-01 10:36:55 +02: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
Michael Crosby 55430d0db7 Merge pull request #166 from crosbymichael/api-update
Update container to have an ID provided by the user
2014-08-29 11:55:12 -07:00
Michael Crosby d6348aec6c Update container to have ID provided by the user
Signed-off-by: Michael Crosby <michael@docker.com>
2014-08-29 11:49:01 -07:00
Michael Crosby 4080743cbc Merge pull request #167 from discordianfish/use-blkio-throttle-stats-as-backup
Use blkio.throttle.* stats when CFQ is not in use
2014-08-28 16:35:13 -07:00
Rohit Jnagal 9f289bafe3 Merge pull request #168 from crosbymichael/tmpfs
Add support for user defined mounts in tmpfs
2014-08-28 13:23:17 -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 07212ae6ca Add tmpfs support to Mount
Signed-off-by: Michael Crosby <michael@docker.com>
2014-08-27 03:39:46 -07:00
Michael Crosby daa3a548b9 Move mount logic into Mount type
Signed-off-by: Michael Crosby <michael@docker.com>
2014-08-27 01:51:52 -07:00
Michael Crosby 1ecaf30408 Merge pull request #164 from crosbymichael/use-privilged
Use --privileged in Makefile
2014-08-25 11:16:09 -07:00
Michael Crosby 3e908c1f0c Merge pull request #162 from rhatdan/unreserve
Allow docker to free container labels when containers are removed.
2014-08-25 11:04:53 -07:00
Michael Crosby 29a79f7092 Use --privileged in Makefile
We need --privileged for apparmor based systems until we have an
apparmor specific flag to set the profile to unconfined.

Signed-off-by: Michael Crosby <michael@docker.com>
2014-08-25 11:03:59 -07:00
Dan Walsh f5d6269371 Allow docker to free container labels when containers are removed.
Currently we do not remove reservations on MCS labels when a container
is removed.  Not a big problem, since on reboot it would be freed.
But we should be cleaning this up.  Currently we support ~500,000
labels.

Docker-DCO-1.1-Signed-off-by: Dan Walsh <dwalsh@redhat.com> (github: rhatdan)
2014-08-20 17:07:38 -04:00
Michael Crosby db65c35051 Merge pull request #161 from crosbymichael/return-notfound-err
Return NotFound error for cgroups abs paths
2014-08-20 14:39:56 -05: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
Michael Crosby edfe81a08b Merge pull request #159 from LK4D4/remove_docker_systemd_dep
Remove dependency from docker/pkg/systemd
2014-08-19 12:55:19 -05: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
Victor Marmol 29363e2d2d Merge pull request #143 from vishh/enter_cgroup
Enter cgroups as part of NsEnter
2014-08-14 14:04:19 -04:00
Vish Kannan 86ba98bbfd Merge pull request #4 from crosbymichael/cgroup-enter
Cleanup systemd cgroup code
2014-08-13 23:26:18 -07: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
Victor Marmol 6940d0ea85 Merge pull request #156 from LK4D4/fix_vet_errors
Fix warnings from go vet
2014-08-13 11:49:46 -04:00
Alexandr Morozov 665613ccd4
Fix warnings from go vet
Signed-off-by: Alexandr Morozov <lk4d4math@gmail.com>
2014-08-13 14:38:20 +04:00
Michael Crosby 1befa2fe9e Merge pull request #155 from crosbymichael/execin-func
Implement execin by using registered functions
2014-08-12 18:09:29 -07:00
Michael Crosby bdafa085ae Reuse exec cli function and strip nsenter- from funcs
Signed-off-by: Michael Crosby <michael@docker.com>
2014-08-12 17:33:20 -07:00
Michael Crosby 33129cabee Merge pull request #147 from lynxbat/145-PercentUsage
Fixes logic for calculating percentage
2014-08-12 13:16:50 -07:00
Michael Crosby 7d1ba0698f Cleanup and rename loadContainer to loadConfig
Signed-off-by: Michael Crosby <michael@docker.com>
2014-08-12 12:03:53 -07:00
Michael Crosby 52ba97e3b1 Add ip func example for listing namespace interfaces
Signed-off-by: Michael Crosby <michael@docker.com>
2014-08-12 11:52:33 -07: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
Michael Crosby 70367b2cf3 Improve execin to support registering funcs
This also changes the functionality of the default exec in to just be an
existing func that is called than handles the implementation to exec a
user user's process inside the container.  This implements this
functionallity in nsinit but is a base for how we will be handling these
types of features inside docker.

Signed-off-by: Michael Crosby <michael@docker.com>
2014-08-12 11:43:12 -07:00
Michael Crosby 51e6049226 Make nsinit package main only
Signed-off-by: Michael Crosby <michael@docker.com>
2014-08-12 10:48:12 -07:00
Michael Crosby 9378c05c37 Remove nsinit main calling pkg
Signed-off-by: Michael Crosby <michael@docker.com>
2014-08-12 10:45:41 -07:00
Michael Crosby d9e307741f Merge pull request #152 from crosbymichael/addsetns-by-fd
Expose setting interface by fd in network pkg
2014-08-12 10:41:21 -07:00