mirror of
https://github.com/kata-containers/kata-containers.git
synced 2025-06-30 09:13:29 +00:00
config: check the builtIn first when updating shim/proxy/agent
Check the "builtIn" first when updating the shim/proxy/agent, thus can avoid checking the shim/proxy's binary files path which is needless for "builtIn" type. Fixes: #1314 Signed-off-by: fupan <lifupan@gmail.com>
This commit is contained in:
parent
2af09d1d58
commit
31232b4416
@ -583,7 +583,12 @@ func updateRuntimeConfigHypervisor(configPath string, tomlConf tomlConfig, confi
|
||||
return nil
|
||||
}
|
||||
|
||||
func updateRuntimeConfigProxy(configPath string, tomlConf tomlConfig, config *oci.RuntimeConfig) error {
|
||||
func updateRuntimeConfigProxy(configPath string, tomlConf tomlConfig, config *oci.RuntimeConfig, builtIn bool) error {
|
||||
if builtIn {
|
||||
config.ProxyType = vc.KataBuiltInProxyType
|
||||
return nil
|
||||
}
|
||||
|
||||
for k, proxy := range tomlConf.Proxy {
|
||||
switch k {
|
||||
case ccProxyTableType:
|
||||
@ -601,15 +606,25 @@ func updateRuntimeConfigProxy(configPath string, tomlConf tomlConfig, config *oc
|
||||
return nil
|
||||
}
|
||||
|
||||
func updateRuntimeConfigAgent(configPath string, tomlConf tomlConfig, config *oci.RuntimeConfig) error {
|
||||
func updateRuntimeConfigAgent(configPath string, tomlConf tomlConfig, config *oci.RuntimeConfig, builtIn bool) error {
|
||||
if builtIn {
|
||||
config.AgentType = vc.KataContainersAgent
|
||||
config.AgentConfig = vc.KataAgentConfig{
|
||||
LongLiveConn: true,
|
||||
UseVSock: config.HypervisorConfig.UseVSock,
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
for k := range tomlConf.Agent {
|
||||
switch k {
|
||||
case hyperstartAgentTableType:
|
||||
config.AgentType = hyperstartAgentTableType
|
||||
config.AgentType = vc.HyperstartAgent
|
||||
config.AgentConfig = vc.HyperConfig{}
|
||||
|
||||
case kataAgentTableType:
|
||||
config.AgentType = kataAgentTableType
|
||||
config.AgentType = vc.KataContainersAgent
|
||||
config.AgentConfig = vc.KataAgentConfig{
|
||||
UseVSock: config.HypervisorConfig.UseVSock,
|
||||
}
|
||||
@ -619,7 +634,13 @@ func updateRuntimeConfigAgent(configPath string, tomlConf tomlConfig, config *oc
|
||||
return nil
|
||||
}
|
||||
|
||||
func updateRuntimeConfigShim(configPath string, tomlConf tomlConfig, config *oci.RuntimeConfig) error {
|
||||
func updateRuntimeConfigShim(configPath string, tomlConf tomlConfig, config *oci.RuntimeConfig, builtIn bool) error {
|
||||
if builtIn {
|
||||
config.ShimType = vc.KataBuiltInShimType
|
||||
config.ShimConfig = vc.ShimConfig{}
|
||||
return nil
|
||||
}
|
||||
|
||||
for k, shim := range tomlConf.Shim {
|
||||
switch k {
|
||||
case ccShimTableType:
|
||||
@ -674,20 +695,20 @@ func SetKernelParams(runtimeConfig *oci.RuntimeConfig) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func updateRuntimeConfig(configPath string, tomlConf tomlConfig, config *oci.RuntimeConfig) error {
|
||||
func updateRuntimeConfig(configPath string, tomlConf tomlConfig, config *oci.RuntimeConfig, builtIn bool) error {
|
||||
if err := updateRuntimeConfigHypervisor(configPath, tomlConf, config); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if err := updateRuntimeConfigProxy(configPath, tomlConf, config); err != nil {
|
||||
if err := updateRuntimeConfigProxy(configPath, tomlConf, config, builtIn); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if err := updateRuntimeConfigAgent(configPath, tomlConf, config); err != nil {
|
||||
if err := updateRuntimeConfigAgent(configPath, tomlConf, config, builtIn); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if err := updateRuntimeConfigShim(configPath, tomlConf, config); err != nil {
|
||||
if err := updateRuntimeConfigShim(configPath, tomlConf, config, builtIn); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
@ -828,7 +849,7 @@ func LoadConfiguration(configPath string, ignoreLogging, builtIn bool) (resolved
|
||||
}).Info("loaded configuration")
|
||||
}
|
||||
|
||||
if err := updateConfig(resolved, tomlConf, &config, builtIn); err != nil {
|
||||
if err := updateRuntimeConfig(resolved, tomlConf, &config, builtIn); err != nil {
|
||||
return "", config, err
|
||||
}
|
||||
|
||||
@ -867,25 +888,6 @@ func checkConfig(config oci.RuntimeConfig) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func updateConfig(configPath string, tomlConf tomlConfig, config *oci.RuntimeConfig, builtIn bool) error {
|
||||
|
||||
if err := updateRuntimeConfig(configPath, tomlConf, config); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if builtIn {
|
||||
config.ProxyType = vc.KataBuiltInProxyType
|
||||
config.ShimType = vc.KataBuiltInShimType
|
||||
config.AgentType = vc.KataContainersAgent
|
||||
config.AgentConfig = vc.KataAgentConfig{
|
||||
LongLiveConn: true,
|
||||
UseVSock: config.HypervisorConfig.UseVSock,
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// checkNetNsConfig performs sanity checks on disable_new_netns config.
|
||||
// Because it is an expert option and conflicts with some other common configs.
|
||||
func checkNetNsConfig(config oci.RuntimeConfig) error {
|
||||
|
@ -1336,7 +1336,7 @@ func TestUpdateRuntimeConfiguration(t *testing.T) {
|
||||
assert.NotEqual(config.AgentType, vc.AgentType(kataAgentTableType))
|
||||
assert.NotEqual(config.AgentConfig, vc.KataAgentConfig{})
|
||||
|
||||
err := updateRuntimeConfig("", tomlConf, &config)
|
||||
err := updateRuntimeConfig("", tomlConf, &config, false)
|
||||
assert.NoError(err)
|
||||
|
||||
assert.Equal(config.AgentType, vc.AgentType(kataAgentTableType))
|
||||
@ -1365,7 +1365,7 @@ func TestUpdateRuntimeConfigurationVMConfig(t *testing.T) {
|
||||
},
|
||||
}
|
||||
|
||||
err := updateRuntimeConfig("", tomlConf, &config)
|
||||
err := updateRuntimeConfig("", tomlConf, &config, false)
|
||||
assert.NoError(err)
|
||||
|
||||
assert.Equal(expectedVMConfig, config.HypervisorConfig.MemorySize)
|
||||
@ -1381,7 +1381,7 @@ func TestUpdateRuntimeConfigurationFactoryConfig(t *testing.T) {
|
||||
|
||||
tomlConf := tomlConfig{Factory: factory{Template: true}}
|
||||
|
||||
err := updateRuntimeConfig("", tomlConf, &config)
|
||||
err := updateRuntimeConfig("", tomlConf, &config, false)
|
||||
assert.NoError(err)
|
||||
|
||||
assert.Equal(expectedFactoryConfig, config.FactoryConfig)
|
||||
@ -1410,7 +1410,7 @@ func TestUpdateRuntimeConfigurationInvalidKernelParams(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
err := updateRuntimeConfig("", tomlConf, &config)
|
||||
err := updateRuntimeConfig("", tomlConf, &config, false)
|
||||
assert.EqualError(err, "Empty kernel parameter")
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user