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)
syncpipe: read from parent before reporting error

Docker-DCO-1.1-Signed-off-by: Bernerd Schaefer <bj.schaefer@gmail.com> (github: bernerdschaefer)
Get UID and GID for device nodes

Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
Merge pull request #170 from soundcloud/syncpipe-read-before-close-child

syncpipe: consume from parent before closing child
Merge pull request #173 from crosbymichael/device-ownership

Get UID and GID for device nodes
Merge pull request #174 from vmarmol/no-sleep

Remove sampling from libcontainer CPU stats.
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>
Allow mounts to be supplied with the MS_SLAVE option.

Docker-DCO-1.1-Signed-off-by: Erik Hollensbe <github@hollensbe.org> (github: erikh)
Merge pull request #172 from cf-guardian/create-api

Correct Create() api call description in Factory interface.
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>
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>
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>
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>
Merge pull request #184 from erikh/slave_mounts

Allow mounts to be supplied with the MS_SLAVE option.
Merge pull request #186 from cf-guardian/devices_error_injection

Devices error injection
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)
Merge pull request #189 from vmarmol/cache-mounts

Cache cgroup root mount location.
Merge pull request #185 from cf-guardian/typed_errors

Add rich errors to the API
netlink: Cache native endianness during init

Signed-off-by: Jonathan Rudenberg <jonathan@titanous.com>
netlink: Extract message checks into reusable method

Signed-off-by: Jonathan Rudenberg <jonathan@titanous.com>