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

Commit

Permalink
kata-env: Show runtime trace setting
Browse files Browse the repository at this point in the history
Show whether runtime tracing is enabled in the output of `kata-env`.

Fixes #936.

Signed-off-by: James O. D. Hunt <[email protected]>
  • Loading branch information
jodh-intel committed Nov 23, 2018
1 parent 21f0059 commit 9984636
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 10 deletions.
4 changes: 3 additions & 1 deletion cli/kata-env.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import (
//
// XXX: Increment for every change to the output format
// (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
type MetaInfo struct {
Expand Down Expand Up @@ -65,6 +65,7 @@ type RuntimeInfo struct {
Version RuntimeVersionInfo
Config RuntimeConfigInfo
Debug bool
Trace bool
DisableNewNetNs bool
Path string
}
Expand Down Expand Up @@ -173,6 +174,7 @@ func getRuntimeInfo(configFile string, config oci.RuntimeConfig) RuntimeInfo {

return RuntimeInfo{
Debug: config.Debug,
Trace: config.Trace,
Version: runtimeVersion,
Config: runtimeConfig,
Path: runtimePath,
Expand Down
21 changes: 13 additions & 8 deletions cli/kata-env_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,11 @@ import (
specs "github.com/opencontainers/runtime-spec/specs-go"
"github.com/urfave/cli"

"strconv"

"github.com/kata-containers/runtime/pkg/katautils"
"github.com/kata-containers/runtime/virtcontainers/pkg/oci"
"github.com/stretchr/testify/assert"
"strconv"
)

const testProxyVersion = "proxy version 0.1"
Expand All @@ -45,6 +46,7 @@ var (
hypervisorDebug = false
proxyDebug = false
runtimeDebug = false
runtimeTrace = false
shimDebug = false
netmonDebug = false
)
Expand Down Expand Up @@ -116,6 +118,7 @@ func makeRuntimeConfigFileData(hypervisor, hypervisorPath, kernelPath, imagePath
[runtime]
enable_debug = ` + strconv.FormatBool(runtimeDebug) + `
enable_tracing = ` + strconv.FormatBool(runtimeTrace) + `
disable_new_netns= ` + strconv.FormatBool(disableNewNetNs)
}

Expand Down Expand Up @@ -359,6 +362,7 @@ func getExpectedRuntimeDetails(config oci.RuntimeConfig, configFile string) Runt
},
Path: runtimePath,
Debug: config.Debug,
Trace: config.Trace,
DisableNewNetNs: config.DisableNewNetNs,
}
}
Expand Down Expand Up @@ -501,13 +505,14 @@ func TestEnvGetEnvInfo(t *testing.T) {
}
defer os.RemoveAll(tmpdir)

// Run test twice to ensure the individual component debug options are
// tested.
for _, debug := range []bool{false, true} {
hypervisorDebug = debug
proxyDebug = debug
runtimeDebug = debug
shimDebug = debug
// Run test twice to ensure the individual component debug+trace
// options are tested.
for _, toggle := range []bool{false, true} {
hypervisorDebug = toggle
proxyDebug = toggle
runtimeDebug = toggle
runtimeTrace = toggle
shimDebug = toggle

configFile, config, err := makeRuntimeConfig(tmpdir)
assert.NoError(t, err)
Expand Down
3 changes: 2 additions & 1 deletion pkg/katautils/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -628,7 +628,8 @@ func LoadConfiguration(configPath string, ignoreLogging, builtIn bool) (resolved
kataUtilsLogger.Logger.Level = originalLoggerLevel
}

tracing = tomlConf.Runtime.Tracing
config.Trace = tomlConf.Runtime.Tracing
tracing = config.Trace

if tomlConf.Runtime.InterNetworkModel != "" {
err = config.InterNetworkModel.SetModel(tomlConf.Runtime.InterNetworkModel)
Expand Down
1 change: 1 addition & 0 deletions virtcontainers/pkg/oci/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ type RuntimeConfig struct {
InterNetworkModel vc.NetInterworkingModel
FactoryConfig FactoryConfig
Debug bool
Trace bool

//Determines if create a netns for hypervisor process
DisableNewNetNs bool
Expand Down

0 comments on commit 9984636

Please sign in to comment.