Merge pull request #744 from rhatdan/debug

Add --debug flag to kpod to turn up logging level to debug
This commit is contained in:
Mrunal Patel 2017-08-14 16:21:22 -07:00 committed by GitHub
commit 36fd0a7208
6 changed files with 73 additions and 16 deletions

View file

@ -43,13 +43,16 @@ It is currently in active development in the Kubernetes community through the [d
| [kpod(1)](/docs/kpod.1.md) | Simple management tool for pods and images | | [kpod(1)](/docs/kpod.1.md) | Simple management tool for pods and images |
| [kpod-history(1)](/docs/kpod-history.1.md)] | Shows the history of an image | | [kpod-history(1)](/docs/kpod-history.1.md)] | Shows the history of an image |
| [kpod-images(1)](/docs/kpod-images.1.md) | List images in local storage | | [kpod-images(1)](/docs/kpod-images.1.md) | List images in local storage |
| [kpod-info(1)](/docs/kpod-info.1.md) | Display System Information |
| [kpod-inspect(1)](/docs/kpod-inspect.1.md) | Display the configuration of a container or image | | [kpod-inspect(1)](/docs/kpod-inspect.1.md) | Display the configuration of a container or image |
| [kpod-mount(1)](/docs/kpod-mount.1.md) | Mount a working container's root filesystem |
| [kpod-load(1)](/docs/kpod-load.1.md) | Load an image from docker archive or oci | | [kpod-load(1)](/docs/kpod-load.1.md) | Load an image from docker archive or oci |
| [kpod-pull(1)](/docs/kpod-pull.1.md) | Pull an image from a registry | | [kpod-pull(1)](/docs/kpod-pull.1.md) | Pull an image from a registry |
| [kpod-push(1)](/docs/kpod-push.1.md) | Push an image to a specified destination | | [kpod-push(1)](/docs/kpod-push.1.md) | Push an image to a specified destination |
| [kpod-rmi(1)](/docs/kpod-rmi.1.md) | Removes one or more images | | [kpod-rmi(1)](/docs/kpod-rmi.1.md) | Removes one or more images |
| [kpod-save(1)](/docs/kpod-save.1.md) | Saves an image to an archive | | [kpod-save(1)](/docs/kpod-save.1.md) | Saves an image to an archive |
| [kpod-tag(1)](/docs/kpod-tag.1.md) | Add an additional name to a local image | | [kpod-tag(1)](/docs/kpod-tag.1.md) | Add an additional name to a local image |
| [kpod-umount(1)](/docs/kpod-umount.1.md) | Unmount a working container's root filesystem |
| [kpod-version(1)](/docs/kpod-version.1.md) | Display the Kpod Version Information | | [kpod-version(1)](/docs/kpod-version.1.md) | Display the Kpod Version Information |
## Configuration ## Configuration

View file

@ -4,6 +4,7 @@ import (
is "github.com/containers/image/storage" is "github.com/containers/image/storage"
"github.com/containers/storage" "github.com/containers/storage"
"github.com/kubernetes-incubator/cri-o/libkpod" "github.com/kubernetes-incubator/cri-o/libkpod"
"github.com/sirupsen/logrus"
"github.com/urfave/cli" "github.com/urfave/cli"
) )
@ -46,5 +47,9 @@ func getConfig(c *cli.Context) (*libkpod.Config, error) {
config.StorageOptions = opts config.StorageOptions = opts
} }
} }
if c.Bool("debug") {
logrus.SetLevel(logrus.DebugLevel)
}
return config, nil return config, nil
} }

View file

@ -15,6 +15,7 @@ func main() {
if reexec.Init() { if reexec.Init() {
return return
} }
logrus.SetLevel(logrus.ErrorLevel)
app := cli.NewApp() app := cli.NewApp()
app.Name = "kpod" app.Name = "kpod"
@ -28,17 +29,25 @@ func main() {
imagesCommand, imagesCommand,
infoCommand, infoCommand,
inspectCommand, inspectCommand,
loadCommand,
mountCommand, mountCommand,
pullCommand, pullCommand,
pushCommand, pushCommand,
rmiCommand, rmiCommand,
saveCommand,
tagCommand, tagCommand,
umountCommand, umountCommand,
versionCommand, versionCommand,
saveCommand,
loadCommand,
} }
app.Flags = []cli.Flag{ app.Flags = []cli.Flag{
cli.StringFlag{
Name: "config, c",
Usage: "path of a config file detailing container server configuration options",
},
cli.BoolFlag{
Name: "debug",
Usage: "print debugging information",
},
cli.StringFlag{ cli.StringFlag{
Name: "root", Name: "root",
Usage: "path to the root directory in which data, including images, is stored", Usage: "path to the root directory in which data, including images, is stored",
@ -55,12 +64,9 @@ func main() {
Name: "storage-opt", Name: "storage-opt",
Usage: "used to pass an option to the storage driver", Usage: "used to pass an option to the storage driver",
}, },
cli.StringFlag{
Name: "config, c",
Usage: "path of a config file detailing container server configuration options",
},
} }
if err := app.Run(os.Args); err != nil { if err := app.Run(os.Args); err != nil {
logrus.Fatal(err) logrus.Errorf(err.Error())
os.Exit(1)
} }
} }

View file

@ -27,6 +27,25 @@ _kpod_history() {
esac esac
} }
_kpod_info() {
local boolean_options="
--help
-h
--json
--debug
"
local options_with_args="
"
local all_options="$options_with_args $boolean_options"
case "$cur" in
-*)
COMPREPLY=($(compgen -W "$boolean_options $options_with_args" -- "$cur"))
;;
esac
}
_kpod_images() { _kpod_images() {
local boolean_options=" local boolean_options="
--help --help
@ -219,14 +238,21 @@ _kpod_load() {
_kpod_kpod() { _kpod_kpod() {
local options_with_args=" local options_with_args="
--config -c
--root
--runroot
--storage-driver
--storage-opt
" "
local boolean_options=" local boolean_options="
--version -v --debug
--help -h --help -h
--version -v
" "
commands=" commands="
history history
images images
info
launch launch
load load
mount mount

View file

@ -21,9 +21,9 @@ Information display here pertain to the host, current storage stats, and build o
Show additional information Show additional information
**--debug, -D** **--json**
Show additional information Output as JSON instead of the default YAML",
## EXAMPLE ## EXAMPLE

View file

@ -5,8 +5,7 @@
kpod - Simple management tool for containers and images kpod - Simple management tool for containers and images
## SYNOPSIS ## SYNOPSIS
**kpod** **kpod** [*options*] COMMAND
[**--help**|**-h**]
# DESCRIPTION # DESCRIPTION
kpod is a simple client only tool to help with debugging issues when daemons kpod is a simple client only tool to help with debugging issues when daemons
@ -24,6 +23,24 @@ has the capability to debug pods/images created by crio.
**--help, -h** **--help, -h**
Print usage statement Print usage statement
**--config value, -c**=**"config.file"**
Path of a config file detailing container server configuration options
**--debug**
Print debugging information
**--root**=**value**
Path to the root directory in which data, including images, is stored
**--runroot**=**value**
Path to the 'run directory' where all state information is stored
**--storage-driver, -s**=**value**
Select which storage driver is used to manage storage of images and containers (default is overlay)
**--storage-opt**=**value**
Used to pass an option to the storage driver
**--version, -v** **--version, -v**
Print the version Print the version