Merge pull request #365 from liubin/feature/delete-shim-364

runtime: clean up shim abstraction
This commit is contained in:
Fupan Li
2020-07-07 09:54:27 +08:00
committed by GitHub
23 changed files with 13 additions and 1697 deletions

View File

@@ -30,7 +30,6 @@ const (
var (
defaultProxy = vc.KataProxyType
defaultShim = vc.KataShimType
// if true, enable opentracing support.
tracing = false
@@ -42,7 +41,7 @@ var (
//
// [<component>.<type>]
//
// The components are hypervisor, proxy, shim and agent. For example,
// The components are hypervisor, proxy and agent. For example,
//
// [proxy.kata]
//
@@ -57,9 +56,6 @@ const (
// supported proxy component types
kataProxyTableType = "kata"
// supported shim component types
kataShimTableType = "kata"
// supported agent component types
kataAgentTableType = "kata"
@@ -70,7 +66,6 @@ const (
type tomlConfig struct {
Hypervisor map[string]hypervisor
Proxy map[string]proxy
Shim map[string]shim
Agent map[string]agent
Runtime runtime
Factory factory
@@ -150,12 +145,6 @@ type runtime struct {
InterNetworkModel string `toml:"internetworking_model"`
}
type shim struct {
Path string `toml:"path"`
Debug bool `toml:"enable_debug"`
Tracing bool `toml:"enable_tracing"`
}
type agent struct {
Debug bool `toml:"enable_debug"`
Tracing bool `toml:"enable_tracing"`
@@ -474,24 +463,6 @@ func (p proxy) debug() bool {
return p.Debug
}
func (s shim) path() (string, error) {
p := s.Path
if p == "" {
p = defaultShimPath
}
return ResolvePath(p)
}
func (s shim) debug() bool {
return s.Debug
}
func (s shim) trace() bool {
return s.Tracing
}
func (a agent) debug() bool {
return a.Debug
}
@@ -898,19 +869,6 @@ func newFactoryConfig(f factory) (oci.FactoryConfig, error) {
}, nil
}
func newShimConfig(s shim) (vc.ShimConfig, error) {
path, err := s.path()
if err != nil {
return vc.ShimConfig{}, err
}
return vc.ShimConfig{
Path: path,
Debug: s.debug(),
Trace: s.trace(),
}, nil
}
func updateRuntimeConfigHypervisor(configPath string, tomlConf tomlConfig, config *oci.RuntimeConfig) error {
for k, hypervisor := range tomlConf.Hypervisor {
var err error
@@ -1011,32 +969,6 @@ func updateRuntimeConfigAgent(configPath string, tomlConf tomlConfig, config *oc
return nil
}
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 kataShimTableType:
config.ShimType = vc.KataShimType
default:
return fmt.Errorf("%s shim is not supported", k)
}
shConfig, err := newShimConfig(shim)
if err != nil {
return fmt.Errorf("%v: %v", configPath, err)
}
config.ShimConfig = shConfig
}
return nil
}
// SetKernelParams adds the user-specified kernel parameters (from the
// configuration file) to the defaults so that the former take priority.
func SetKernelParams(runtimeConfig *oci.RuntimeConfig) error {
@@ -1111,10 +1043,6 @@ func updateRuntimeConfig(configPath string, tomlConf tomlConfig, config *oci.Run
return err
}
if err := updateRuntimeConfigShim(configPath, tomlConf, config, builtIn); err != nil {
return err
}
fConfig, err := newFactoryConfig(tomlConf.Factory)
if err != nil {
return fmt.Errorf("%v: %v", configPath, err)
@@ -1193,7 +1121,6 @@ func initConfig() (config oci.RuntimeConfig, err error) {
AgentType: defaultAgent,
AgentConfig: defaultAgentConfig,
ProxyType: defaultProxy,
ShimType: defaultShim,
}
return config, nil
@@ -1336,11 +1263,6 @@ func checkNetNsConfig(config oci.RuntimeConfig) error {
if config.InterNetworkModel != vc.NetXConnectNoneModel {
return fmt.Errorf("config disable_new_netns only works with 'none' internetworking_model")
}
} else if shim, ok := config.ShimConfig.(vc.ShimConfig); ok && shim.Trace {
// Normally, the shim runs in a separate network namespace.
// But when tracing, the shim process needs to be able to talk
// to the Jaeger agent running in the host network namespace.
return errors.New("Shim tracing requires disable_new_netns for Jaeger agent communication")
}
return nil