kata-env: Show runtime trace setting

Show whether runtime tracing is enabled in the output of `kata-env`.

Fixes #936.

Signed-off-by: James O. D. Hunt <james.o.hunt@intel.com>
This commit is contained in:
James O. D. Hunt 2018-11-23 15:47:54 +00:00
parent 21f0059487
commit 9984636f5a
4 changed files with 19 additions and 10 deletions

View File

@ -25,7 +25,7 @@ import (
// //
// XXX: Increment for every change to the output format // XXX: Increment for every change to the output format
// (meaning any change to the EnvInfo type). // (meaning any change to the EnvInfo type).
const formatVersion = "1.0.19" const formatVersion = "1.0.20"
// MetaInfo stores information on the format of the output itself // MetaInfo stores information on the format of the output itself
type MetaInfo struct { type MetaInfo struct {
@ -65,6 +65,7 @@ type RuntimeInfo struct {
Version RuntimeVersionInfo Version RuntimeVersionInfo
Config RuntimeConfigInfo Config RuntimeConfigInfo
Debug bool Debug bool
Trace bool
DisableNewNetNs bool DisableNewNetNs bool
Path string Path string
} }
@ -173,6 +174,7 @@ func getRuntimeInfo(configFile string, config oci.RuntimeConfig) RuntimeInfo {
return RuntimeInfo{ return RuntimeInfo{
Debug: config.Debug, Debug: config.Debug,
Trace: config.Trace,
Version: runtimeVersion, Version: runtimeVersion,
Config: runtimeConfig, Config: runtimeConfig,
Path: runtimePath, Path: runtimePath,

View File

@ -24,10 +24,11 @@ import (
specs "github.com/opencontainers/runtime-spec/specs-go" specs "github.com/opencontainers/runtime-spec/specs-go"
"github.com/urfave/cli" "github.com/urfave/cli"
"strconv"
"github.com/kata-containers/runtime/pkg/katautils" "github.com/kata-containers/runtime/pkg/katautils"
"github.com/kata-containers/runtime/virtcontainers/pkg/oci" "github.com/kata-containers/runtime/virtcontainers/pkg/oci"
"github.com/stretchr/testify/assert" "github.com/stretchr/testify/assert"
"strconv"
) )
const testProxyVersion = "proxy version 0.1" const testProxyVersion = "proxy version 0.1"
@ -45,6 +46,7 @@ var (
hypervisorDebug = false hypervisorDebug = false
proxyDebug = false proxyDebug = false
runtimeDebug = false runtimeDebug = false
runtimeTrace = false
shimDebug = false shimDebug = false
netmonDebug = false netmonDebug = false
) )
@ -116,6 +118,7 @@ func makeRuntimeConfigFileData(hypervisor, hypervisorPath, kernelPath, imagePath
[runtime] [runtime]
enable_debug = ` + strconv.FormatBool(runtimeDebug) + ` enable_debug = ` + strconv.FormatBool(runtimeDebug) + `
enable_tracing = ` + strconv.FormatBool(runtimeTrace) + `
disable_new_netns= ` + strconv.FormatBool(disableNewNetNs) disable_new_netns= ` + strconv.FormatBool(disableNewNetNs)
} }
@ -359,6 +362,7 @@ func getExpectedRuntimeDetails(config oci.RuntimeConfig, configFile string) Runt
}, },
Path: runtimePath, Path: runtimePath,
Debug: config.Debug, Debug: config.Debug,
Trace: config.Trace,
DisableNewNetNs: config.DisableNewNetNs, DisableNewNetNs: config.DisableNewNetNs,
} }
} }
@ -501,13 +505,14 @@ func TestEnvGetEnvInfo(t *testing.T) {
} }
defer os.RemoveAll(tmpdir) defer os.RemoveAll(tmpdir)
// Run test twice to ensure the individual component debug options are // Run test twice to ensure the individual component debug+trace
// tested. // options are tested.
for _, debug := range []bool{false, true} { for _, toggle := range []bool{false, true} {
hypervisorDebug = debug hypervisorDebug = toggle
proxyDebug = debug proxyDebug = toggle
runtimeDebug = debug runtimeDebug = toggle
shimDebug = debug runtimeTrace = toggle
shimDebug = toggle
configFile, config, err := makeRuntimeConfig(tmpdir) configFile, config, err := makeRuntimeConfig(tmpdir)
assert.NoError(t, err) assert.NoError(t, err)

View File

@ -628,7 +628,8 @@ func LoadConfiguration(configPath string, ignoreLogging, builtIn bool) (resolved
kataUtilsLogger.Logger.Level = originalLoggerLevel kataUtilsLogger.Logger.Level = originalLoggerLevel
} }
tracing = tomlConf.Runtime.Tracing config.Trace = tomlConf.Runtime.Tracing
tracing = config.Trace
if tomlConf.Runtime.InterNetworkModel != "" { if tomlConf.Runtime.InterNetworkModel != "" {
err = config.InterNetworkModel.SetModel(tomlConf.Runtime.InterNetworkModel) err = config.InterNetworkModel.SetModel(tomlConf.Runtime.InterNetworkModel)

View File

@ -121,6 +121,7 @@ type RuntimeConfig struct {
InterNetworkModel vc.NetInterworkingModel InterNetworkModel vc.NetInterworkingModel
FactoryConfig FactoryConfig FactoryConfig FactoryConfig
Debug bool Debug bool
Trace bool
//Determines if create a netns for hypervisor process //Determines if create a netns for hypervisor process
DisableNewNetNs bool DisableNewNetNs bool