mirror of
https://github.com/kata-containers/kata-containers.git
synced 2025-06-29 16:57:18 +00:00
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:
parent
24fcd1b37d
commit
c54f00a7ca
11
README.md
11
README.md
@ -60,7 +60,7 @@ 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
|
||||
@ -68,8 +68,13 @@ $ 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
|
||||
|
||||
|
@ -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
|
||||
|
16
cli/main.go
16
cli/main.go
@ -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)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user