mirror of
https://github.com/kata-containers/kata-containers.git
synced 2025-07-07 12:29:56 +00:00
kata-env: Fix display of debug options
The runtime and hypervisor `Debug` options were always showing as `false` (although all debug options in `configuration.toml` were correctly honoured). Note: Also moved location of `FactoryConfig` in `RuntimeConfig` as the `malign` linter was complaining: ``` virtcontainers/pkg/oci/utils.go:102:20⚠️ struct of size 408 could be 400 (maligned) ``` Fixes #724. Signed-off-by: James O. D. Hunt <james.o.hunt@intel.com>
This commit is contained in:
parent
a5f05bf3e1
commit
23a35c84c9
@ -532,6 +532,7 @@ func loadConfiguration(configPath string, ignoreLogging bool) (resolvedConfigPat
|
|||||||
}
|
}
|
||||||
|
|
||||||
if tomlConf.Runtime.Debug {
|
if tomlConf.Runtime.Debug {
|
||||||
|
config.Debug = true
|
||||||
debug = true
|
debug = true
|
||||||
crashOnError = true
|
crashOnError = true
|
||||||
} else {
|
} else {
|
||||||
|
@ -25,6 +25,13 @@ import (
|
|||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
var (
|
||||||
|
hypervisorDebug = false
|
||||||
|
proxyDebug = false
|
||||||
|
runtimeDebug = false
|
||||||
|
shimDebug = false
|
||||||
|
)
|
||||||
|
|
||||||
type testRuntimeConfig struct {
|
type testRuntimeConfig struct {
|
||||||
RuntimeConfig oci.RuntimeConfig
|
RuntimeConfig oci.RuntimeConfig
|
||||||
RuntimeConfigFile string
|
RuntimeConfigFile string
|
||||||
@ -52,17 +59,20 @@ func makeRuntimeConfigFileData(hypervisor, hypervisorPath, kernelPath, imagePath
|
|||||||
enable_iothreads = ` + strconv.FormatBool(enableIOThreads) + `
|
enable_iothreads = ` + strconv.FormatBool(enableIOThreads) + `
|
||||||
hotplug_vfio_on_root_bus = ` + strconv.FormatBool(hotplugVFIOOnRootBus) + `
|
hotplug_vfio_on_root_bus = ` + strconv.FormatBool(hotplugVFIOOnRootBus) + `
|
||||||
msize_9p = ` + strconv.FormatUint(uint64(defaultMsize9p), 10) + `
|
msize_9p = ` + strconv.FormatUint(uint64(defaultMsize9p), 10) + `
|
||||||
|
enable_debug = ` + strconv.FormatBool(hypervisorDebug) + `
|
||||||
|
|
||||||
[proxy.kata]
|
[proxy.kata]
|
||||||
|
enable_debug = ` + strconv.FormatBool(proxyDebug) + `
|
||||||
path = "` + proxyPath + `"
|
path = "` + proxyPath + `"
|
||||||
|
|
||||||
[shim.kata]
|
[shim.kata]
|
||||||
path = "` + shimPath + `"
|
path = "` + shimPath + `"
|
||||||
|
enable_debug = ` + strconv.FormatBool(shimDebug) + `
|
||||||
|
|
||||||
[agent.kata]
|
[agent.kata]
|
||||||
|
|
||||||
[runtime]
|
[runtime]
|
||||||
`
|
enable_debug = ` + strconv.FormatBool(runtimeDebug)
|
||||||
}
|
}
|
||||||
|
|
||||||
func createConfig(configPath string, fileData string) error {
|
func createConfig(configPath string, fileData string) error {
|
||||||
|
@ -160,6 +160,7 @@ func getRuntimeInfo(configFile string, config oci.RuntimeConfig) RuntimeInfo {
|
|||||||
runtimePath, _ := os.Executable()
|
runtimePath, _ := os.Executable()
|
||||||
|
|
||||||
return RuntimeInfo{
|
return RuntimeInfo{
|
||||||
|
Debug: config.Debug,
|
||||||
Version: runtimeVersion,
|
Version: runtimeVersion,
|
||||||
Config: runtimeConfig,
|
Config: runtimeConfig,
|
||||||
Path: runtimePath,
|
Path: runtimePath,
|
||||||
@ -284,6 +285,7 @@ func getHypervisorInfo(config oci.RuntimeConfig) HypervisorInfo {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return HypervisorInfo{
|
return HypervisorInfo{
|
||||||
|
Debug: config.HypervisorConfig.Debug,
|
||||||
MachineType: config.HypervisorConfig.HypervisorMachineType,
|
MachineType: config.HypervisorConfig.HypervisorMachineType,
|
||||||
Version: version,
|
Version: version,
|
||||||
Path: hypervisorPath,
|
Path: hypervisorPath,
|
||||||
|
@ -149,6 +149,7 @@ func getExpectedShimDetails(config oci.RuntimeConfig) (ShimInfo, error) {
|
|||||||
Type: string(config.ShimType),
|
Type: string(config.ShimType),
|
||||||
Version: testShimVersion,
|
Version: testShimVersion,
|
||||||
Path: shimPath,
|
Path: shimPath,
|
||||||
|
Debug: shimConfig.Debug,
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -243,6 +244,7 @@ func getExpectedHypervisor(config oci.RuntimeConfig) HypervisorInfo {
|
|||||||
MachineType: config.HypervisorConfig.HypervisorMachineType,
|
MachineType: config.HypervisorConfig.HypervisorMachineType,
|
||||||
BlockDeviceDriver: config.HypervisorConfig.BlockDeviceDriver,
|
BlockDeviceDriver: config.HypervisorConfig.BlockDeviceDriver,
|
||||||
Msize9p: config.HypervisorConfig.Msize9p,
|
Msize9p: config.HypervisorConfig.Msize9p,
|
||||||
|
Debug: config.HypervisorConfig.Debug,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -259,7 +261,7 @@ func getExpectedKernel(config oci.RuntimeConfig) KernelInfo {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func getExpectedRuntimeDetails(configFile string) RuntimeInfo {
|
func getExpectedRuntimeDetails(config oci.RuntimeConfig, configFile string) RuntimeInfo {
|
||||||
runtimePath, _ := os.Executable()
|
runtimePath, _ := os.Executable()
|
||||||
|
|
||||||
return RuntimeInfo{
|
return RuntimeInfo{
|
||||||
@ -271,14 +273,15 @@ func getExpectedRuntimeDetails(configFile string) RuntimeInfo {
|
|||||||
Config: RuntimeConfigInfo{
|
Config: RuntimeConfigInfo{
|
||||||
Path: configFile,
|
Path: configFile,
|
||||||
},
|
},
|
||||||
Path: runtimePath,
|
Path: runtimePath,
|
||||||
|
Debug: config.Debug,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func getExpectedSettings(config oci.RuntimeConfig, tmpdir, configFile string) (EnvInfo, error) {
|
func getExpectedSettings(config oci.RuntimeConfig, tmpdir, configFile string) (EnvInfo, error) {
|
||||||
meta := getExpectedMetaInfo()
|
meta := getExpectedMetaInfo()
|
||||||
|
|
||||||
runtime := getExpectedRuntimeDetails(configFile)
|
runtime := getExpectedRuntimeDetails(config, configFile)
|
||||||
|
|
||||||
proxy, err := getExpectedProxyDetails(config)
|
proxy, err := getExpectedProxyDetails(config)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -407,16 +410,25 @@ func TestEnvGetEnvInfo(t *testing.T) {
|
|||||||
}
|
}
|
||||||
defer os.RemoveAll(tmpdir)
|
defer os.RemoveAll(tmpdir)
|
||||||
|
|
||||||
configFile, config, err := makeRuntimeConfig(tmpdir)
|
// Run test twice to ensure the individual component debug options are
|
||||||
assert.NoError(t, err)
|
// tested.
|
||||||
|
for _, debug := range []bool{false, true} {
|
||||||
|
hypervisorDebug = debug
|
||||||
|
proxyDebug = debug
|
||||||
|
runtimeDebug = debug
|
||||||
|
shimDebug = debug
|
||||||
|
|
||||||
expectedEnv, err := getExpectedSettings(config, tmpdir, configFile)
|
configFile, config, err := makeRuntimeConfig(tmpdir)
|
||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
|
|
||||||
env, err := getEnvInfo(configFile, config)
|
expectedEnv, err := getExpectedSettings(config, tmpdir, configFile)
|
||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
|
|
||||||
assert.Equal(t, expectedEnv, env)
|
env, err := getEnvInfo(configFile, config)
|
||||||
|
assert.NoError(t, err)
|
||||||
|
|
||||||
|
assert.Equal(t, expectedEnv, env)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestEnvGetEnvInfoNoHypervisorVersion(t *testing.T) {
|
func TestEnvGetEnvInfoNoHypervisorVersion(t *testing.T) {
|
||||||
@ -545,7 +557,7 @@ func TestEnvGetRuntimeInfo(t *testing.T) {
|
|||||||
configFile, config, err := makeRuntimeConfig(tmpdir)
|
configFile, config, err := makeRuntimeConfig(tmpdir)
|
||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
|
|
||||||
expectedRuntime := getExpectedRuntimeDetails(configFile)
|
expectedRuntime := getExpectedRuntimeDetails(config, configFile)
|
||||||
|
|
||||||
runtime := getRuntimeInfo(configFile, config)
|
runtime := getRuntimeInfo(configFile, config)
|
||||||
|
|
||||||
|
@ -103,8 +103,6 @@ type RuntimeConfig struct {
|
|||||||
HypervisorType vc.HypervisorType
|
HypervisorType vc.HypervisorType
|
||||||
HypervisorConfig vc.HypervisorConfig
|
HypervisorConfig vc.HypervisorConfig
|
||||||
|
|
||||||
FactoryConfig FactoryConfig
|
|
||||||
|
|
||||||
AgentType vc.AgentType
|
AgentType vc.AgentType
|
||||||
AgentConfig interface{}
|
AgentConfig interface{}
|
||||||
|
|
||||||
@ -119,6 +117,8 @@ type RuntimeConfig struct {
|
|||||||
//Determines how the VM should be connected to the
|
//Determines how the VM should be connected to the
|
||||||
//the container network interface
|
//the container network interface
|
||||||
InterNetworkModel vc.NetInterworkingModel
|
InterNetworkModel vc.NetInterworkingModel
|
||||||
|
FactoryConfig FactoryConfig
|
||||||
|
Debug bool
|
||||||
}
|
}
|
||||||
|
|
||||||
// AddKernelParam allows the addition of new kernel parameters to an existing
|
// AddKernelParam allows the addition of new kernel parameters to an existing
|
||||||
|
Loading…
Reference in New Issue
Block a user