Improve error handling in runc

The error handling on the runc cli is currenly pretty messy because
messages to the user are split between regular stderr format and logrus
message format.  This changes all the error reporting to the cli to only
output on stderr and exit(1) for consumers of the api.

By default logrus logs to /dev/null so that it is not seen by the user.
If the user wants extra and/or structured loggging/errors from runc they
can use the `--log` flag to provide a path to the file where they want
this information.  This allows a consistent behavior on the cli but
extra power and information when debugging with logs.

This also includes a change to enable the same logging information
inside the container's init by adding an init cli command that can share
the existing flags for all other runc commands.

Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
This commit is contained in:
Michael Crosby
2016-03-08 18:05:50 -08:00
parent 4155b68a24
commit 044e298507
8 changed files with 47 additions and 30 deletions
+2 -2
View File
@@ -35,7 +35,7 @@ information is displayed once every 5 seconds.`,
Action: func(context *cli.Context) {
container, err := getContainer(context)
if err != nil {
logrus.Fatal(err)
fatal(err)
}
var (
stats = make(chan *libcontainer.Stats, 1)
@@ -74,7 +74,7 @@ information is displayed once every 5 seconds.`,
}()
n, err := container.NotifyOOM()
if err != nil {
logrus.Fatal(err)
fatal(err)
}
for {
select {