kata-check: reduce default output verbosity

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 <mvedovati@suse.com>
This commit is contained in:
Marco Vedovati
2019-08-20 16:18:27 +02:00
parent 24fcd1b37d
commit c54f00a7ca
3 changed files with 32 additions and 11 deletions

View File

@@ -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
@@ -335,8 +346,7 @@ var kataCheckCLICommand = cli.Command{
if err != nil {
return err
}
kataLog.Info(successMessageCapable)
fmt.Println(successMessageCapable)
if os.Geteuid() == 0 {
err = archHostCanCreateVMContainer(runtimeConfig.HypervisorType)
@@ -344,7 +354,7 @@ var kataCheckCLICommand = cli.Command{
return err
}
kataLog.Info(successMessageCreate)
fmt.Println(successMessageCreate)
}
return nil

View File

@@ -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 {
@@ -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)
}