Skip to content
This repository has been archived by the owner on May 12, 2021. It is now read-only.

Commit

Permalink
kata-check: reduce default output verbosity
Browse files Browse the repository at this point in the history
Update kata-check to print by default only relevant information about
the ability to run / create Kata Containers, and omit the list of checks
performed. Checks can still be printed using the --verbose flag.

Fixes: #1944

Signed-off-by: Marco Vedovati <[email protected]>
  • Loading branch information
marcov committed Aug 22, 2019
1 parent 24fcd1b commit c54f00a
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 11 deletions.
11 changes: 8 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,16 +60,21 @@ technologies:
### Hardware requirements

The runtime has a built-in command to determine if your host system is capable
of running a Kata Container:
of running and creating a Kata Container:

```bash
$ kata-runtime kata-check
```

> **Note:**
>
> If you run the previous command as the `root` user, further checks will be
> performed (e.g. it will check if another incompatible hypervisor is running).
> - By default, only a brief success / failure message is printed.
> If more details are needed, the `--verbose` flag can be used to display the
> list of all the checks performed.
>
> - `root` permission is needed to check if the system is capable of running
> Kata containers. In this case, additional checks are performed (e.g., if another
> incompatible hypervisor is running).
## Download and install

Expand Down
16 changes: 13 additions & 3 deletions cli/kata-check.go
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,18 @@ func genericHostIsVMContainerCapable(details vmContainerCapableDetails) error {
var kataCheckCLICommand = cli.Command{
Name: checkCmd,
Usage: "tests if system can run " + project,
Flags: []cli.Flag{
cli.BoolFlag{
Name: "verbose, v",
Usage: "display the list of checks performed",
},
},

Action: func(context *cli.Context) error {
verbose := context.Bool("verbose")
if verbose {
kataLog.Logger.SetLevel(logrus.InfoLevel)
}
ctx, err := cliContextToContext(context)
if err != nil {
return err
Expand Down Expand Up @@ -335,16 +346,15 @@ var kataCheckCLICommand = cli.Command{
if err != nil {
return err
}

kataLog.Info(successMessageCapable)
fmt.Println(successMessageCapable)

if os.Geteuid() == 0 {
err = archHostCanCreateVMContainer(runtimeConfig.HypervisorType)
if err != nil {
return err
}

kataLog.Info(successMessageCreate)
fmt.Println(successMessageCreate)
}

return nil
Expand Down
16 changes: 11 additions & 5 deletions cli/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -260,11 +260,17 @@ func beforeSubcommands(c *cli.Context) error {
return nil
}

ignoreLogging := false
ignoreConfigLogs := false
var traceRootSpan string

subCmdIsCheckCmd := (c.NArg() == 1 && (c.Args()[0] == checkCmd))
if !subCmdIsCheckCmd {
subCmdIsCheckCmd := (c.NArg() >= 1 && (c.Args()[0] == checkCmd))
if subCmdIsCheckCmd {
// checkCmd will use the default logrus logger to stderr
// raise the logger default level to warn
kataLog.Logger.SetLevel(logrus.WarnLevel)
// do not print configuration logs for checkCmd
ignoreConfigLogs = true
} else {
if path := c.GlobalString("log"); path != "" {
f, err := os.OpenFile(path, os.O_CREATE|os.O_WRONLY|os.O_APPEND|os.O_SYNC, 0640)
if err != nil {
Expand Down Expand Up @@ -300,11 +306,11 @@ func beforeSubcommands(c *cli.Context) error {

if c.NArg() == 1 && c.Args()[0] == envCmd {
// simply report the logging setup
ignoreLogging = true
ignoreConfigLogs = true
}
}

configFile, runtimeConfig, err = katautils.LoadConfiguration(c.GlobalString(configFilePathOption), ignoreLogging, false)
configFile, runtimeConfig, err = katautils.LoadConfiguration(c.GlobalString(configFilePathOption), ignoreConfigLogs, false)
if err != nil {
fatal(err)
}
Expand Down

0 comments on commit c54f00a

Please sign in to comment.