mirror of
https://github.com/kata-containers/kata-containers.git
synced 2025-06-29 08:47:56 +00:00
runtime: remove agent abstraction
This PR will delete agent abstraction and use Kata agent as the only one agent. Fixes: #377 Signed-off-by: bin liu <bin@hyper.sh>
This commit is contained in:
parent
350831b18b
commit
bd8f03a5ef
@ -166,7 +166,6 @@ var initFactoryCommand = cli.Command{
|
|||||||
VMConfig: vc.VMConfig{
|
VMConfig: vc.VMConfig{
|
||||||
HypervisorType: runtimeConfig.HypervisorType,
|
HypervisorType: runtimeConfig.HypervisorType,
|
||||||
HypervisorConfig: runtimeConfig.HypervisorConfig,
|
HypervisorConfig: runtimeConfig.HypervisorConfig,
|
||||||
AgentType: runtimeConfig.AgentType,
|
|
||||||
AgentConfig: runtimeConfig.AgentConfig,
|
AgentConfig: runtimeConfig.AgentConfig,
|
||||||
ProxyType: runtimeConfig.ProxyType,
|
ProxyType: runtimeConfig.ProxyType,
|
||||||
ProxyConfig: runtimeConfig.ProxyConfig,
|
ProxyConfig: runtimeConfig.ProxyConfig,
|
||||||
@ -256,7 +255,6 @@ var destroyFactoryCommand = cli.Command{
|
|||||||
VMConfig: vc.VMConfig{
|
VMConfig: vc.VMConfig{
|
||||||
HypervisorType: runtimeConfig.HypervisorType,
|
HypervisorType: runtimeConfig.HypervisorType,
|
||||||
HypervisorConfig: runtimeConfig.HypervisorConfig,
|
HypervisorConfig: runtimeConfig.HypervisorConfig,
|
||||||
AgentType: runtimeConfig.AgentType,
|
|
||||||
AgentConfig: runtimeConfig.AgentConfig,
|
AgentConfig: runtimeConfig.AgentConfig,
|
||||||
ProxyType: runtimeConfig.ProxyType,
|
ProxyType: runtimeConfig.ProxyType,
|
||||||
ProxyConfig: runtimeConfig.ProxyConfig,
|
ProxyConfig: runtimeConfig.ProxyConfig,
|
||||||
@ -314,7 +312,6 @@ var statusFactoryCommand = cli.Command{
|
|||||||
VMConfig: vc.VMConfig{
|
VMConfig: vc.VMConfig{
|
||||||
HypervisorType: runtimeConfig.HypervisorType,
|
HypervisorType: runtimeConfig.HypervisorType,
|
||||||
HypervisorConfig: runtimeConfig.HypervisorConfig,
|
HypervisorConfig: runtimeConfig.HypervisorConfig,
|
||||||
AgentType: runtimeConfig.AgentType,
|
|
||||||
AgentConfig: runtimeConfig.AgentConfig,
|
AgentConfig: runtimeConfig.AgentConfig,
|
||||||
ProxyType: runtimeConfig.ProxyType,
|
ProxyType: runtimeConfig.ProxyType,
|
||||||
ProxyConfig: runtimeConfig.ProxyConfig,
|
ProxyConfig: runtimeConfig.ProxyConfig,
|
||||||
|
@ -6,6 +6,7 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"context"
|
||||||
"flag"
|
"flag"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"os"
|
"os"
|
||||||
@ -73,11 +74,19 @@ func TestFactoryCLIFunctionInit(t *testing.T) {
|
|||||||
runtimeConfig.FactoryConfig.Template = true
|
runtimeConfig.FactoryConfig.Template = true
|
||||||
runtimeConfig.FactoryConfig.TemplatePath = "/run/vc/vm/template"
|
runtimeConfig.FactoryConfig.TemplatePath = "/run/vc/vm/template"
|
||||||
runtimeConfig.HypervisorType = vc.MockHypervisor
|
runtimeConfig.HypervisorType = vc.MockHypervisor
|
||||||
runtimeConfig.AgentType = vc.NoopAgentType
|
|
||||||
runtimeConfig.ProxyType = vc.NoopProxyType
|
runtimeConfig.ProxyType = vc.NoopProxyType
|
||||||
ctx.App.Metadata["runtimeConfig"] = runtimeConfig
|
ctx.App.Metadata["runtimeConfig"] = runtimeConfig
|
||||||
fn, ok = initFactoryCommand.Action.(func(context *cli.Context) error)
|
fn, ok = initFactoryCommand.Action.(func(context *cli.Context) error)
|
||||||
assert.True(ok)
|
assert.True(ok)
|
||||||
|
|
||||||
|
// config mock agent
|
||||||
|
stdCtx, err := cliContextToContext(ctx)
|
||||||
|
if err != nil {
|
||||||
|
stdCtx = context.Background()
|
||||||
|
}
|
||||||
|
stdCtx = vc.WithNewAgentFunc(stdCtx, vc.NewMockAgent)
|
||||||
|
ctx.App.Metadata["context"] = stdCtx
|
||||||
|
|
||||||
err = fn(ctx)
|
err = fn(ctx)
|
||||||
assert.Nil(err)
|
assert.Nil(err)
|
||||||
}
|
}
|
||||||
@ -109,7 +118,6 @@ func TestFactoryCLIFunctionDestroy(t *testing.T) {
|
|||||||
// With template
|
// With template
|
||||||
runtimeConfig.FactoryConfig.Template = true
|
runtimeConfig.FactoryConfig.Template = true
|
||||||
runtimeConfig.HypervisorType = vc.MockHypervisor
|
runtimeConfig.HypervisorType = vc.MockHypervisor
|
||||||
runtimeConfig.AgentType = vc.NoopAgentType
|
|
||||||
ctx.App.Metadata["runtimeConfig"] = runtimeConfig
|
ctx.App.Metadata["runtimeConfig"] = runtimeConfig
|
||||||
fn, ok = destroyFactoryCommand.Action.(func(context *cli.Context) error)
|
fn, ok = destroyFactoryCommand.Action.(func(context *cli.Context) error)
|
||||||
assert.True(ok)
|
assert.True(ok)
|
||||||
@ -145,7 +153,6 @@ func TestFactoryCLIFunctionStatus(t *testing.T) {
|
|||||||
// With template
|
// With template
|
||||||
runtimeConfig.FactoryConfig.Template = true
|
runtimeConfig.FactoryConfig.Template = true
|
||||||
runtimeConfig.HypervisorType = vc.MockHypervisor
|
runtimeConfig.HypervisorType = vc.MockHypervisor
|
||||||
runtimeConfig.AgentType = vc.NoopAgentType
|
|
||||||
ctx.App.Metadata["runtimeConfig"] = runtimeConfig
|
ctx.App.Metadata["runtimeConfig"] = runtimeConfig
|
||||||
err = fn(ctx)
|
err = fn(ctx)
|
||||||
assert.Nil(err)
|
assert.Nil(err)
|
||||||
|
@ -114,7 +114,6 @@ type ProxyInfo struct {
|
|||||||
|
|
||||||
// AgentInfo stores agent details
|
// AgentInfo stores agent details
|
||||||
type AgentInfo struct {
|
type AgentInfo struct {
|
||||||
Type string
|
|
||||||
Debug bool
|
Debug bool
|
||||||
Trace bool
|
Trace bool
|
||||||
TraceMode string
|
TraceMode string
|
||||||
@ -296,23 +295,13 @@ func getCommandVersion(cmd string) (string, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func getAgentInfo(config oci.RuntimeConfig) (AgentInfo, error) {
|
func getAgentInfo(config oci.RuntimeConfig) (AgentInfo, error) {
|
||||||
agent := AgentInfo{
|
agent := AgentInfo{}
|
||||||
Type: string(config.AgentType),
|
|
||||||
}
|
|
||||||
|
|
||||||
switch config.AgentType {
|
agentConfig := config.AgentConfig
|
||||||
case vc.KataContainersAgent:
|
agent.Debug = agentConfig.Debug
|
||||||
agentConfig, ok := config.AgentConfig.(vc.KataAgentConfig)
|
agent.Trace = agentConfig.Trace
|
||||||
if !ok {
|
agent.TraceMode = agentConfig.TraceMode
|
||||||
return AgentInfo{}, errors.New("cannot determine Kata agent config")
|
agent.TraceType = agentConfig.TraceType
|
||||||
}
|
|
||||||
agent.Debug = agentConfig.Debug
|
|
||||||
agent.Trace = agentConfig.Trace
|
|
||||||
agent.TraceMode = agentConfig.TraceMode
|
|
||||||
agent.TraceType = agentConfig.TraceType
|
|
||||||
default:
|
|
||||||
// Nothing useful to report for the other agent types
|
|
||||||
}
|
|
||||||
|
|
||||||
return agent, nil
|
return agent, nil
|
||||||
}
|
}
|
||||||
|
@ -198,13 +198,8 @@ func getExpectedNetmonDetails(config oci.RuntimeConfig) (NetmonInfo, error) {
|
|||||||
|
|
||||||
func getExpectedAgentDetails(config oci.RuntimeConfig) (AgentInfo, error) {
|
func getExpectedAgentDetails(config oci.RuntimeConfig) (AgentInfo, error) {
|
||||||
|
|
||||||
agentConfig, ok := config.AgentConfig.(vc.KataAgentConfig)
|
agentConfig := config.AgentConfig
|
||||||
if !ok {
|
|
||||||
return AgentInfo{}, fmt.Errorf("expected KataAgentConfig, got %T", config.AgentConfig)
|
|
||||||
}
|
|
||||||
|
|
||||||
return AgentInfo{
|
return AgentInfo{
|
||||||
Type: string(config.AgentType),
|
|
||||||
Debug: agentConfig.Debug,
|
Debug: agentConfig.Debug,
|
||||||
Trace: agentConfig.Trace,
|
Trace: agentConfig.Trace,
|
||||||
|
|
||||||
@ -490,7 +485,6 @@ func TestEnvGetEnvInfo(t *testing.T) {
|
|||||||
runtimeDebug = toggle
|
runtimeDebug = toggle
|
||||||
runtimeTrace = toggle
|
runtimeTrace = toggle
|
||||||
agentDebug = toggle
|
agentDebug = toggle
|
||||||
agentTrace = toggle
|
|
||||||
|
|
||||||
configFile, config, err := makeRuntimeConfig(tmpdir)
|
configFile, config, err := makeRuntimeConfig(tmpdir)
|
||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
@ -536,13 +530,8 @@ func TestEnvGetEnvInfoAgentError(t *testing.T) {
|
|||||||
assert.NoError(err)
|
assert.NoError(err)
|
||||||
defer os.RemoveAll(tmpdir)
|
defer os.RemoveAll(tmpdir)
|
||||||
|
|
||||||
configFile, config, err := makeRuntimeConfig(tmpdir)
|
_, _, err = makeRuntimeConfig(tmpdir)
|
||||||
assert.NoError(err)
|
assert.NoError(err)
|
||||||
|
|
||||||
config.AgentConfig = "invalid agent config"
|
|
||||||
|
|
||||||
_, err = getEnvInfo(configFile, config)
|
|
||||||
assert.Error(err)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestEnvGetEnvInfoNoOSRelease(t *testing.T) {
|
func TestEnvGetEnvInfoNoOSRelease(t *testing.T) {
|
||||||
@ -728,8 +717,7 @@ func TestEnvGetAgentInfo(t *testing.T) {
|
|||||||
|
|
||||||
assert.Equal(t, expectedAgent, agent)
|
assert.Equal(t, expectedAgent, agent)
|
||||||
|
|
||||||
agentConfig, ok := config.AgentConfig.(vc.KataAgentConfig)
|
agentConfig := config.AgentConfig
|
||||||
assert.True(t, ok)
|
|
||||||
|
|
||||||
agentConfig.Debug = true
|
agentConfig.Debug = true
|
||||||
config.AgentConfig = agentConfig
|
config.AgentConfig = agentConfig
|
||||||
@ -746,10 +734,6 @@ func TestEnvGetAgentInfo(t *testing.T) {
|
|||||||
assert.True(t, agent.Trace)
|
assert.True(t, agent.Trace)
|
||||||
assert.Equal(t, agent.TraceMode, "traceMode")
|
assert.Equal(t, agent.TraceMode, "traceMode")
|
||||||
assert.Equal(t, agent.TraceType, "traceType")
|
assert.Equal(t, agent.TraceType, "traceType")
|
||||||
|
|
||||||
config.AgentConfig = "I am the wrong type"
|
|
||||||
_, err = getAgentInfo(config)
|
|
||||||
assert.Error(t, err)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func testEnvShowTOMLSettings(t *testing.T, tmpdir string, tmpfile *os.File) error {
|
func testEnvShowTOMLSettings(t *testing.T, tmpdir string, tmpfile *os.File) error {
|
||||||
@ -777,9 +761,7 @@ func testEnvShowTOMLSettings(t *testing.T, tmpdir string, tmpfile *os.File) erro
|
|||||||
Debug: false,
|
Debug: false,
|
||||||
}
|
}
|
||||||
|
|
||||||
agent := AgentInfo{
|
agent := AgentInfo{}
|
||||||
Type: "agent-type",
|
|
||||||
}
|
|
||||||
|
|
||||||
expectedHostDetails, err := getExpectedHostDetails(tmpdir)
|
expectedHostDetails, err := getExpectedHostDetails(tmpdir)
|
||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
@ -839,9 +821,7 @@ func testEnvShowJSONSettings(t *testing.T, tmpdir string, tmpfile *os.File) erro
|
|||||||
Debug: false,
|
Debug: false,
|
||||||
}
|
}
|
||||||
|
|
||||||
agent := AgentInfo{
|
agent := AgentInfo{}
|
||||||
Type: "agent-type",
|
|
||||||
}
|
|
||||||
|
|
||||||
expectedHostDetails, err := getExpectedHostDetails(tmpdir)
|
expectedHostDetails, err := getExpectedHostDetails(tmpdir)
|
||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
|
@ -242,7 +242,6 @@ func newTestRuntimeConfig(dir, consolePath string, create bool) (oci.RuntimeConf
|
|||||||
return oci.RuntimeConfig{
|
return oci.RuntimeConfig{
|
||||||
HypervisorType: vc.QemuHypervisor,
|
HypervisorType: vc.QemuHypervisor,
|
||||||
HypervisorConfig: hypervisorConfig,
|
HypervisorConfig: hypervisorConfig,
|
||||||
AgentType: vc.KataContainersAgent,
|
|
||||||
ProxyType: vc.KataProxyType,
|
ProxyType: vc.KataProxyType,
|
||||||
Console: consolePath,
|
Console: consolePath,
|
||||||
}, nil
|
}, nil
|
||||||
|
@ -209,7 +209,6 @@ func newTestRuntimeConfig(dir, consolePath string, create bool) (oci.RuntimeConf
|
|||||||
return oci.RuntimeConfig{
|
return oci.RuntimeConfig{
|
||||||
HypervisorType: vc.QemuHypervisor,
|
HypervisorType: vc.QemuHypervisor,
|
||||||
HypervisorConfig: hypervisorConfig,
|
HypervisorConfig: hypervisorConfig,
|
||||||
AgentType: vc.KataContainersAgent,
|
|
||||||
ProxyType: vc.KataBuiltInProxyType,
|
ProxyType: vc.KataBuiltInProxyType,
|
||||||
Console: consolePath,
|
Console: consolePath,
|
||||||
}, nil
|
}, nil
|
||||||
|
@ -25,7 +25,6 @@ import (
|
|||||||
|
|
||||||
const (
|
const (
|
||||||
defaultHypervisor = vc.QemuHypervisor
|
defaultHypervisor = vc.QemuHypervisor
|
||||||
defaultAgent = vc.KataContainersAgent
|
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
@ -56,9 +55,6 @@ const (
|
|||||||
// supported proxy component types
|
// supported proxy component types
|
||||||
kataProxyTableType = "kata"
|
kataProxyTableType = "kata"
|
||||||
|
|
||||||
// supported agent component types
|
|
||||||
kataAgentTableType = "kata"
|
|
||||||
|
|
||||||
// the maximum amount of PCI bridges that can be cold plugged in a VM
|
// the maximum amount of PCI bridges that can be cold plugged in a VM
|
||||||
maxPCIBridges uint32 = 5
|
maxPCIBridges uint32 = 5
|
||||||
)
|
)
|
||||||
@ -932,37 +928,24 @@ func updateRuntimeConfigProxy(configPath string, tomlConf tomlConfig, config *oc
|
|||||||
|
|
||||||
func updateRuntimeConfigAgent(configPath string, tomlConf tomlConfig, config *oci.RuntimeConfig, builtIn bool) error {
|
func updateRuntimeConfigAgent(configPath string, tomlConf tomlConfig, config *oci.RuntimeConfig, builtIn bool) error {
|
||||||
if builtIn {
|
if builtIn {
|
||||||
var agentConfig vc.KataAgentConfig
|
|
||||||
|
|
||||||
// If the agent config section isn't a Kata one, just default
|
|
||||||
// to everything being disabled.
|
|
||||||
agentConfig, _ = config.AgentConfig.(vc.KataAgentConfig)
|
|
||||||
|
|
||||||
config.AgentType = vc.KataContainersAgent
|
|
||||||
config.AgentConfig = vc.KataAgentConfig{
|
config.AgentConfig = vc.KataAgentConfig{
|
||||||
LongLiveConn: true,
|
LongLiveConn: true,
|
||||||
UseVSock: config.HypervisorConfig.UseVSock,
|
UseVSock: config.HypervisorConfig.UseVSock,
|
||||||
Debug: agentConfig.Debug,
|
Debug: config.AgentConfig.Debug,
|
||||||
KernelModules: agentConfig.KernelModules,
|
KernelModules: config.AgentConfig.KernelModules,
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
for k, agent := range tomlConf.Agent {
|
for _, agent := range tomlConf.Agent {
|
||||||
switch k {
|
config.AgentConfig = vc.KataAgentConfig{
|
||||||
case kataAgentTableType:
|
UseVSock: config.HypervisorConfig.UseVSock,
|
||||||
config.AgentType = vc.KataContainersAgent
|
Debug: agent.debug(),
|
||||||
config.AgentConfig = vc.KataAgentConfig{
|
Trace: agent.trace(),
|
||||||
UseVSock: config.HypervisorConfig.UseVSock,
|
TraceMode: agent.traceMode(),
|
||||||
Debug: agent.debug(),
|
TraceType: agent.traceType(),
|
||||||
Trace: agent.trace(),
|
KernelModules: agent.kernelModules(),
|
||||||
TraceMode: agent.traceMode(),
|
|
||||||
TraceType: agent.traceType(),
|
|
||||||
KernelModules: agent.kernelModules(),
|
|
||||||
}
|
|
||||||
default:
|
|
||||||
return fmt.Errorf("%s agent type is not supported", k)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1005,19 +988,17 @@ func SetKernelParams(runtimeConfig *oci.RuntimeConfig) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// next, check for agent specific kernel params
|
// next, check for agent specific kernel params
|
||||||
if agentConfig, ok := runtimeConfig.AgentConfig.(vc.KataAgentConfig); ok {
|
err := vc.KataAgentSetDefaultTraceConfigOptions(&runtimeConfig.AgentConfig)
|
||||||
err := vc.KataAgentSetDefaultTraceConfigOptions(&agentConfig)
|
if err != nil {
|
||||||
if err != nil {
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
params := vc.KataAgentKernelParams(runtimeConfig.AgentConfig)
|
||||||
|
|
||||||
|
for _, p := range params {
|
||||||
|
if err := runtimeConfig.AddKernelParam(p); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
params := vc.KataAgentKernelParams(agentConfig)
|
|
||||||
|
|
||||||
for _, p := range params {
|
|
||||||
if err := runtimeConfig.AddKernelParam(p); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// now re-add the user-specified values so that they take priority.
|
// now re-add the user-specified values so that they take priority.
|
||||||
@ -1106,19 +1087,16 @@ func GetDefaultHypervisorConfig() vc.HypervisorConfig {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func initConfig() (config oci.RuntimeConfig, err error) {
|
func initConfig() (config oci.RuntimeConfig, err error) {
|
||||||
var defaultAgentConfig interface{}
|
|
||||||
|
|
||||||
err = config.InterNetworkModel.SetModel(defaultInterNetworkingModel)
|
err = config.InterNetworkModel.SetModel(defaultInterNetworkingModel)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return oci.RuntimeConfig{}, err
|
return oci.RuntimeConfig{}, err
|
||||||
}
|
}
|
||||||
|
|
||||||
defaultAgentConfig = vc.KataAgentConfig{}
|
defaultAgentConfig := vc.KataAgentConfig{}
|
||||||
|
|
||||||
config = oci.RuntimeConfig{
|
config = oci.RuntimeConfig{
|
||||||
HypervisorType: defaultHypervisor,
|
HypervisorType: defaultHypervisor,
|
||||||
HypervisorConfig: GetDefaultHypervisorConfig(),
|
HypervisorConfig: GetDefaultHypervisorConfig(),
|
||||||
AgentType: defaultAgent,
|
|
||||||
AgentConfig: defaultAgentConfig,
|
AgentConfig: defaultAgentConfig,
|
||||||
ProxyType: defaultProxy,
|
ProxyType: defaultProxy,
|
||||||
}
|
}
|
||||||
@ -1280,9 +1258,6 @@ func checkFactoryConfig(config oci.RuntimeConfig) error {
|
|||||||
if config.HypervisorType != vc.QemuHypervisor {
|
if config.HypervisorType != vc.QemuHypervisor {
|
||||||
return errors.New("VM cache just support qemu")
|
return errors.New("VM cache just support qemu")
|
||||||
}
|
}
|
||||||
if config.AgentType != vc.KataContainersAgent {
|
|
||||||
return errors.New("VM cache just support kata agent")
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
|
@ -190,7 +190,6 @@ func createAllRuntimeConfigFiles(dir, hypervisor string) (config testRuntimeConf
|
|||||||
HypervisorType: defaultHypervisor,
|
HypervisorType: defaultHypervisor,
|
||||||
HypervisorConfig: hypervisorConfig,
|
HypervisorConfig: hypervisorConfig,
|
||||||
|
|
||||||
AgentType: defaultAgent,
|
|
||||||
AgentConfig: agentConfig,
|
AgentConfig: agentConfig,
|
||||||
|
|
||||||
ProxyType: defaultProxy,
|
ProxyType: defaultProxy,
|
||||||
@ -609,7 +608,6 @@ func TestMinimalRuntimeConfig(t *testing.T) {
|
|||||||
HypervisorType: defaultHypervisor,
|
HypervisorType: defaultHypervisor,
|
||||||
HypervisorConfig: expectedHypervisorConfig,
|
HypervisorConfig: expectedHypervisorConfig,
|
||||||
|
|
||||||
AgentType: defaultAgent,
|
|
||||||
AgentConfig: expectedAgentConfig,
|
AgentConfig: expectedAgentConfig,
|
||||||
|
|
||||||
ProxyType: defaultProxy,
|
ProxyType: defaultProxy,
|
||||||
@ -1516,30 +1514,6 @@ func TestDefaultCPUFeatures(t *testing.T) {
|
|||||||
assert.Equal(cpuFeatures, h.cpuFeatures())
|
assert.Equal(cpuFeatures, h.cpuFeatures())
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestUpdateRuntimeConfiguration(t *testing.T) {
|
|
||||||
assert := assert.New(t)
|
|
||||||
|
|
||||||
assert.Equal(defaultAgent, vc.KataContainersAgent)
|
|
||||||
|
|
||||||
config := oci.RuntimeConfig{}
|
|
||||||
|
|
||||||
tomlConf := tomlConfig{
|
|
||||||
Agent: map[string]agent{
|
|
||||||
// force a non-default value
|
|
||||||
kataAgentTableType: {},
|
|
||||||
},
|
|
||||||
}
|
|
||||||
|
|
||||||
assert.NotEqual(config.AgentType, vc.AgentType(kataAgentTableType))
|
|
||||||
assert.NotEqual(config.AgentConfig, vc.KataAgentConfig{})
|
|
||||||
|
|
||||||
err := updateRuntimeConfig("", tomlConf, &config, false)
|
|
||||||
assert.NoError(err)
|
|
||||||
|
|
||||||
assert.Equal(config.AgentType, vc.AgentType(kataAgentTableType))
|
|
||||||
assert.Equal(config.AgentConfig, vc.KataAgentConfig{})
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestUpdateRuntimeConfigurationVMConfig(t *testing.T) {
|
func TestUpdateRuntimeConfigurationVMConfig(t *testing.T) {
|
||||||
assert := assert.New(t)
|
assert := assert.New(t)
|
||||||
|
|
||||||
@ -1589,8 +1563,6 @@ func TestUpdateRuntimeConfigurationFactoryConfig(t *testing.T) {
|
|||||||
func TestUpdateRuntimeConfigurationInvalidKernelParams(t *testing.T) {
|
func TestUpdateRuntimeConfigurationInvalidKernelParams(t *testing.T) {
|
||||||
assert := assert.New(t)
|
assert := assert.New(t)
|
||||||
|
|
||||||
assert.Equal(defaultAgent, vc.KataContainersAgent)
|
|
||||||
|
|
||||||
config := oci.RuntimeConfig{}
|
config := oci.RuntimeConfig{}
|
||||||
|
|
||||||
tomlConf := tomlConfig{}
|
tomlConf := tomlConfig{}
|
||||||
|
@ -64,7 +64,6 @@ func HandleFactory(ctx context.Context, vci vc.VC, runtimeConfig *oci.RuntimeCon
|
|||||||
VMConfig: vc.VMConfig{
|
VMConfig: vc.VMConfig{
|
||||||
HypervisorType: runtimeConfig.HypervisorType,
|
HypervisorType: runtimeConfig.HypervisorType,
|
||||||
HypervisorConfig: runtimeConfig.HypervisorConfig,
|
HypervisorConfig: runtimeConfig.HypervisorConfig,
|
||||||
AgentType: runtimeConfig.AgentType,
|
|
||||||
AgentConfig: runtimeConfig.AgentConfig,
|
AgentConfig: runtimeConfig.AgentConfig,
|
||||||
ProxyType: runtimeConfig.ProxyType,
|
ProxyType: runtimeConfig.ProxyType,
|
||||||
ProxyConfig: runtimeConfig.ProxyConfig,
|
ProxyConfig: runtimeConfig.ProxyConfig,
|
||||||
|
@ -105,7 +105,6 @@ func newTestRuntimeConfig(dir, consolePath string, create bool) (oci.RuntimeConf
|
|||||||
return oci.RuntimeConfig{
|
return oci.RuntimeConfig{
|
||||||
HypervisorType: vc.QemuHypervisor,
|
HypervisorType: vc.QemuHypervisor,
|
||||||
HypervisorConfig: hypervisorConfig,
|
HypervisorConfig: hypervisorConfig,
|
||||||
AgentType: vc.KataContainersAgent,
|
|
||||||
ProxyType: vc.KataProxyType,
|
ProxyType: vc.KataProxyType,
|
||||||
Console: consolePath,
|
Console: consolePath,
|
||||||
}, nil
|
}, nil
|
||||||
|
@ -6,7 +6,6 @@
|
|||||||
package virtcontainers
|
package virtcontainers
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
|
||||||
"syscall"
|
"syscall"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
@ -14,13 +13,29 @@ import (
|
|||||||
"github.com/kata-containers/kata-containers/src/runtime/virtcontainers/pkg/agent/protocols/grpc"
|
"github.com/kata-containers/kata-containers/src/runtime/virtcontainers/pkg/agent/protocols/grpc"
|
||||||
vcTypes "github.com/kata-containers/kata-containers/src/runtime/virtcontainers/pkg/types"
|
vcTypes "github.com/kata-containers/kata-containers/src/runtime/virtcontainers/pkg/types"
|
||||||
"github.com/kata-containers/kata-containers/src/runtime/virtcontainers/types"
|
"github.com/kata-containers/kata-containers/src/runtime/virtcontainers/types"
|
||||||
"github.com/mitchellh/mapstructure"
|
|
||||||
specs "github.com/opencontainers/runtime-spec/specs-go"
|
specs "github.com/opencontainers/runtime-spec/specs-go"
|
||||||
"golang.org/x/net/context"
|
"golang.org/x/net/context"
|
||||||
)
|
)
|
||||||
|
|
||||||
// AgentType describes the type of guest agent a Sandbox should run.
|
type newAgentFuncKey struct{}
|
||||||
type AgentType string
|
|
||||||
|
type newAgentFuncType func() agent
|
||||||
|
|
||||||
|
// getAgentFunc used to pass mock agent creation func to CreateSandbox passed in `ctx`
|
||||||
|
func getNewAgentFunc(ctx context.Context) newAgentFuncType {
|
||||||
|
v := ctx.Value(newAgentFuncKey{})
|
||||||
|
if v != nil {
|
||||||
|
if vv, ok := v.(newAgentFuncType); ok {
|
||||||
|
return vv
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return newKataAgent
|
||||||
|
}
|
||||||
|
|
||||||
|
// WithNewAgentFunc set newAgentFuncKey in `ctx`
|
||||||
|
func WithNewAgentFunc(ctx context.Context, f newAgentFuncType) context.Context {
|
||||||
|
return context.WithValue(ctx, newAgentFuncKey{}, f)
|
||||||
|
}
|
||||||
|
|
||||||
// ProcessListOptions contains the options used to list running
|
// ProcessListOptions contains the options used to list running
|
||||||
// processes inside the container
|
// processes inside the container
|
||||||
@ -39,12 +54,6 @@ type ProcessListOptions struct {
|
|||||||
type ProcessList []byte
|
type ProcessList []byte
|
||||||
|
|
||||||
const (
|
const (
|
||||||
// NoopAgentType is the No-Op agent.
|
|
||||||
NoopAgentType AgentType = "noop"
|
|
||||||
|
|
||||||
// KataContainersAgent is the Kata Containers agent.
|
|
||||||
KataContainersAgent AgentType = "kata"
|
|
||||||
|
|
||||||
// SocketTypeVSOCK is a VSOCK socket type for talking to an agent.
|
// SocketTypeVSOCK is a VSOCK socket type for talking to an agent.
|
||||||
SocketTypeVSOCK = "vsock"
|
SocketTypeVSOCK = "vsock"
|
||||||
|
|
||||||
@ -53,61 +62,6 @@ const (
|
|||||||
SocketTypeUNIX = "unix"
|
SocketTypeUNIX = "unix"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Set sets an agent type based on the input string.
|
|
||||||
func (agentType *AgentType) Set(value string) error {
|
|
||||||
switch value {
|
|
||||||
case "noop":
|
|
||||||
*agentType = NoopAgentType
|
|
||||||
return nil
|
|
||||||
case "kata":
|
|
||||||
*agentType = KataContainersAgent
|
|
||||||
return nil
|
|
||||||
default:
|
|
||||||
return fmt.Errorf("Unknown agent type %s", value)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// String converts an agent type to a string.
|
|
||||||
func (agentType *AgentType) String() string {
|
|
||||||
switch *agentType {
|
|
||||||
case NoopAgentType:
|
|
||||||
return string(NoopAgentType)
|
|
||||||
case KataContainersAgent:
|
|
||||||
return string(KataContainersAgent)
|
|
||||||
default:
|
|
||||||
return ""
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// newAgent returns an agent from an agent type.
|
|
||||||
func newAgent(agentType AgentType) agent {
|
|
||||||
switch agentType {
|
|
||||||
case NoopAgentType:
|
|
||||||
return &noopAgent{}
|
|
||||||
case KataContainersAgent:
|
|
||||||
return &kataAgent{}
|
|
||||||
default:
|
|
||||||
return &noopAgent{}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// newAgentConfig returns an agent config from a generic SandboxConfig interface.
|
|
||||||
func newAgentConfig(agentType AgentType, agentConfig interface{}) (interface{}, error) {
|
|
||||||
switch agentType {
|
|
||||||
case NoopAgentType:
|
|
||||||
return nil, nil
|
|
||||||
case KataContainersAgent:
|
|
||||||
var kataAgentConfig KataAgentConfig
|
|
||||||
err := mapstructure.Decode(agentConfig, &kataAgentConfig)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
return kataAgentConfig, nil
|
|
||||||
default:
|
|
||||||
return nil, nil
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// agent is the virtcontainers agent interface.
|
// agent is the virtcontainers agent interface.
|
||||||
// Agents are running in the guest VM and handling
|
// Agents are running in the guest VM and handling
|
||||||
// communications between the host and guest.
|
// communications between the host and guest.
|
||||||
@ -117,7 +71,7 @@ type agent interface {
|
|||||||
// init().
|
// init().
|
||||||
// After init() is called, agent implementations should be initialized and ready
|
// After init() is called, agent implementations should be initialized and ready
|
||||||
// to handle all other Agent interface methods.
|
// to handle all other Agent interface methods.
|
||||||
init(ctx context.Context, sandbox *Sandbox, config interface{}) (disableVMShutdown bool, err error)
|
init(ctx context.Context, sandbox *Sandbox, config KataAgentConfig) (disableVMShutdown bool, err error)
|
||||||
|
|
||||||
// capabilities should return a structure that specifies the capabilities
|
// capabilities should return a structure that specifies the capabilities
|
||||||
// supported by the agent.
|
// supported by the agent.
|
||||||
|
@ -1,108 +0,0 @@
|
|||||||
// Copyright (c) 2016 Intel Corporation
|
|
||||||
//
|
|
||||||
// SPDX-License-Identifier: Apache-2.0
|
|
||||||
//
|
|
||||||
|
|
||||||
package virtcontainers
|
|
||||||
|
|
||||||
import (
|
|
||||||
"testing"
|
|
||||||
|
|
||||||
"github.com/stretchr/testify/assert"
|
|
||||||
)
|
|
||||||
|
|
||||||
func testSetAgentType(t *testing.T, value string, expected AgentType) {
|
|
||||||
var agentType AgentType
|
|
||||||
assert := assert.New(t)
|
|
||||||
|
|
||||||
err := (&agentType).Set(value)
|
|
||||||
assert.NoError(err)
|
|
||||||
assert.Equal(agentType, expected)
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestSetNoopAgentType(t *testing.T) {
|
|
||||||
testSetAgentType(t, "noop", NoopAgentType)
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestSetKataAgentType(t *testing.T) {
|
|
||||||
testSetAgentType(t, "kata", KataContainersAgent)
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestSetUnknownAgentType(t *testing.T) {
|
|
||||||
var agentType AgentType
|
|
||||||
assert := assert.New(t)
|
|
||||||
|
|
||||||
err := (&agentType).Set("unknown")
|
|
||||||
assert.Error(err)
|
|
||||||
assert.NotEqual(agentType, NoopAgentType)
|
|
||||||
}
|
|
||||||
|
|
||||||
func testStringFromAgentType(t *testing.T, agentType AgentType, expected string) {
|
|
||||||
agentTypeStr := (&agentType).String()
|
|
||||||
assert.Equal(t, agentTypeStr, expected)
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestStringFromNoopAgentType(t *testing.T) {
|
|
||||||
testStringFromAgentType(t, NoopAgentType, "noop")
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestStringFromKataAgentType(t *testing.T) {
|
|
||||||
testStringFromAgentType(t, KataContainersAgent, "kata")
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestStringFromUnknownAgentType(t *testing.T) {
|
|
||||||
var agentType AgentType
|
|
||||||
testStringFromAgentType(t, agentType, "")
|
|
||||||
}
|
|
||||||
|
|
||||||
func testNewAgentFromAgentType(t *testing.T, agentType AgentType, expected agent) {
|
|
||||||
ag := newAgent(agentType)
|
|
||||||
assert.Exactly(t, ag, expected)
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestNewAgentFromNoopAgentType(t *testing.T) {
|
|
||||||
testNewAgentFromAgentType(t, NoopAgentType, &noopAgent{})
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestNewAgentFromKataAgentType(t *testing.T) {
|
|
||||||
testNewAgentFromAgentType(t, KataContainersAgent, &kataAgent{})
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestNewAgentFromUnknownAgentType(t *testing.T) {
|
|
||||||
var agentType AgentType
|
|
||||||
testNewAgentFromAgentType(t, agentType, &noopAgent{})
|
|
||||||
}
|
|
||||||
|
|
||||||
func testNewAgentConfig(t *testing.T, config SandboxConfig, expected interface{}) {
|
|
||||||
agentConfig, err := newAgentConfig(config.AgentType, config.AgentConfig)
|
|
||||||
assert.NoError(t, err)
|
|
||||||
assert.Exactly(t, agentConfig, expected)
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestNewAgentConfigFromNoopAgentType(t *testing.T) {
|
|
||||||
var agentConfig interface{}
|
|
||||||
|
|
||||||
sandboxConfig := SandboxConfig{
|
|
||||||
AgentType: NoopAgentType,
|
|
||||||
AgentConfig: agentConfig,
|
|
||||||
}
|
|
||||||
|
|
||||||
testNewAgentConfig(t, sandboxConfig, agentConfig)
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestNewAgentConfigFromKataAgentType(t *testing.T) {
|
|
||||||
agentConfig := KataAgentConfig{UseVSock: true}
|
|
||||||
|
|
||||||
sandboxConfig := SandboxConfig{
|
|
||||||
AgentType: KataContainersAgent,
|
|
||||||
AgentConfig: agentConfig,
|
|
||||||
}
|
|
||||||
|
|
||||||
testNewAgentConfig(t, sandboxConfig, agentConfig)
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestNewAgentConfigFromUnknownAgentType(t *testing.T) {
|
|
||||||
var agentConfig interface{}
|
|
||||||
|
|
||||||
testNewAgentConfig(t, SandboxConfig{}, agentConfig)
|
|
||||||
}
|
|
@ -382,7 +382,6 @@ func StatusSandbox(ctx context.Context, sandboxID string) (SandboxStatus, error)
|
|||||||
State: s.state,
|
State: s.state,
|
||||||
Hypervisor: s.config.HypervisorType,
|
Hypervisor: s.config.HypervisorType,
|
||||||
HypervisorConfig: s.config.HypervisorConfig,
|
HypervisorConfig: s.config.HypervisorConfig,
|
||||||
Agent: s.config.AgentType,
|
|
||||||
ContainersStatus: contStatusList,
|
ContainersStatus: contStatusList,
|
||||||
Annotations: s.config.Annotations,
|
Annotations: s.config.Annotations,
|
||||||
}
|
}
|
||||||
|
@ -31,6 +31,8 @@ const (
|
|||||||
containerID = "1"
|
containerID = "1"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
var newMockAgent = NewMockAgent
|
||||||
|
|
||||||
var sandboxAnnotations = map[string]string{
|
var sandboxAnnotations = map[string]string{
|
||||||
"sandbox.foo": "sandbox.bar",
|
"sandbox.foo": "sandbox.bar",
|
||||||
"sandbox.hello": "sandbox.world",
|
"sandbox.hello": "sandbox.world",
|
||||||
@ -112,13 +114,12 @@ func newTestSandboxConfigNoop() SandboxConfig {
|
|||||||
HypervisorType: MockHypervisor,
|
HypervisorType: MockHypervisor,
|
||||||
HypervisorConfig: hypervisorConfig,
|
HypervisorConfig: hypervisorConfig,
|
||||||
|
|
||||||
AgentType: NoopAgentType,
|
|
||||||
|
|
||||||
Containers: []ContainerConfig{container},
|
Containers: []ContainerConfig{container},
|
||||||
|
|
||||||
Annotations: sandboxAnnotations,
|
Annotations: sandboxAnnotations,
|
||||||
|
|
||||||
ProxyType: NoopProxyType,
|
ProxyType: NoopProxyType,
|
||||||
|
AgentConfig: KataAgentConfig{},
|
||||||
}
|
}
|
||||||
|
|
||||||
configFile := filepath.Join(bundlePath, "config.json")
|
configFile := filepath.Join(bundlePath, "config.json")
|
||||||
@ -137,8 +138,6 @@ func newTestSandboxConfigNoop() SandboxConfig {
|
|||||||
|
|
||||||
func newTestSandboxConfigKataAgent() SandboxConfig {
|
func newTestSandboxConfigKataAgent() SandboxConfig {
|
||||||
sandboxConfig := newTestSandboxConfigNoop()
|
sandboxConfig := newTestSandboxConfigNoop()
|
||||||
sandboxConfig.AgentType = KataContainersAgent
|
|
||||||
sandboxConfig.AgentConfig = KataAgentConfig{}
|
|
||||||
sandboxConfig.Containers = nil
|
sandboxConfig.Containers = nil
|
||||||
|
|
||||||
return sandboxConfig
|
return sandboxConfig
|
||||||
@ -150,12 +149,15 @@ func TestCreateSandboxNoopAgentSuccessful(t *testing.T) {
|
|||||||
|
|
||||||
config := newTestSandboxConfigNoop()
|
config := newTestSandboxConfigNoop()
|
||||||
|
|
||||||
p, err := CreateSandbox(context.Background(), config, nil)
|
ctx := WithNewAgentFunc(context.Background(), newMockAgent)
|
||||||
|
p, err := CreateSandbox(ctx, config, nil)
|
||||||
assert.NoError(err)
|
assert.NoError(err)
|
||||||
assert.NotNil(p)
|
assert.NotNil(p)
|
||||||
|
|
||||||
s, ok := p.(*Sandbox)
|
s, ok := p.(*Sandbox)
|
||||||
assert.True(ok)
|
assert.True(ok)
|
||||||
|
assert.NotNil(s)
|
||||||
|
|
||||||
sandboxDir := filepath.Join(s.newStore.RunStoragePath(), p.ID())
|
sandboxDir := filepath.Join(s.newStore.RunStoragePath(), p.ID())
|
||||||
_, err = os.Stat(sandboxDir)
|
_, err = os.Stat(sandboxDir)
|
||||||
assert.NoError(err)
|
assert.NoError(err)
|
||||||
@ -189,7 +191,8 @@ func TestCreateSandboxKataAgentSuccessful(t *testing.T) {
|
|||||||
assert.NoError(err)
|
assert.NoError(err)
|
||||||
defer kataProxyMock.Stop()
|
defer kataProxyMock.Stop()
|
||||||
|
|
||||||
p, err := CreateSandbox(context.Background(), config, nil)
|
ctx := WithNewAgentFunc(context.Background(), newMockAgent)
|
||||||
|
p, err := CreateSandbox(ctx, config, nil)
|
||||||
assert.NoError(err)
|
assert.NoError(err)
|
||||||
assert.NotNil(p)
|
assert.NotNil(p)
|
||||||
|
|
||||||
@ -206,7 +209,8 @@ func TestCreateSandboxFailing(t *testing.T) {
|
|||||||
|
|
||||||
config := SandboxConfig{}
|
config := SandboxConfig{}
|
||||||
|
|
||||||
p, err := CreateSandbox(context.Background(), config, nil)
|
ctx := WithNewAgentFunc(context.Background(), newMockAgent)
|
||||||
|
p, err := CreateSandbox(ctx, config, nil)
|
||||||
assert.Error(err)
|
assert.Error(err)
|
||||||
assert.Nil(p.(*Sandbox))
|
assert.Nil(p.(*Sandbox))
|
||||||
}
|
}
|
||||||
@ -215,7 +219,7 @@ func TestDeleteSandboxNoopAgentSuccessful(t *testing.T) {
|
|||||||
defer cleanUp()
|
defer cleanUp()
|
||||||
assert := assert.New(t)
|
assert := assert.New(t)
|
||||||
|
|
||||||
ctx := context.Background()
|
ctx := WithNewAgentFunc(context.Background(), newMockAgent)
|
||||||
config := newTestSandboxConfigNoop()
|
config := newTestSandboxConfigNoop()
|
||||||
|
|
||||||
p, err := CreateSandbox(ctx, config, nil)
|
p, err := CreateSandbox(ctx, config, nil)
|
||||||
@ -264,7 +268,7 @@ func TestDeleteSandboxKataAgentSuccessful(t *testing.T) {
|
|||||||
assert.NoError(err)
|
assert.NoError(err)
|
||||||
defer kataProxyMock.Stop()
|
defer kataProxyMock.Stop()
|
||||||
|
|
||||||
ctx := context.Background()
|
ctx := WithNewAgentFunc(context.Background(), newMockAgent)
|
||||||
p, err := CreateSandbox(ctx, config, nil)
|
p, err := CreateSandbox(ctx, config, nil)
|
||||||
assert.NoError(err)
|
assert.NoError(err)
|
||||||
assert.NotNil(p)
|
assert.NotNil(p)
|
||||||
@ -287,7 +291,8 @@ func TestDeleteSandboxFailing(t *testing.T) {
|
|||||||
defer cleanUp()
|
defer cleanUp()
|
||||||
assert := assert.New(t)
|
assert := assert.New(t)
|
||||||
|
|
||||||
p, err := DeleteSandbox(context.Background(), testSandboxID)
|
ctx := WithNewAgentFunc(context.Background(), newMockAgent)
|
||||||
|
p, err := DeleteSandbox(ctx, testSandboxID)
|
||||||
assert.Error(err)
|
assert.Error(err)
|
||||||
assert.Nil(p)
|
assert.Nil(p)
|
||||||
}
|
}
|
||||||
@ -298,7 +303,8 @@ func TestStartSandboxNoopAgentSuccessful(t *testing.T) {
|
|||||||
|
|
||||||
config := newTestSandboxConfigNoop()
|
config := newTestSandboxConfigNoop()
|
||||||
|
|
||||||
p, _, err := createAndStartSandbox(context.Background(), config)
|
ctx := WithNewAgentFunc(context.Background(), newMockAgent)
|
||||||
|
p, _, err := createAndStartSandbox(ctx, config)
|
||||||
assert.NoError(err)
|
assert.NoError(err)
|
||||||
assert.NotNil(p)
|
assert.NotNil(p)
|
||||||
}
|
}
|
||||||
@ -330,7 +336,7 @@ func TestStartSandboxKataAgentSuccessful(t *testing.T) {
|
|||||||
assert.NoError(err)
|
assert.NoError(err)
|
||||||
defer kataProxyMock.Stop()
|
defer kataProxyMock.Stop()
|
||||||
|
|
||||||
ctx := context.Background()
|
ctx := WithNewAgentFunc(context.Background(), newMockAgent)
|
||||||
p, _, err := createAndStartSandbox(ctx, config)
|
p, _, err := createAndStartSandbox(ctx, config)
|
||||||
assert.NoError(err)
|
assert.NoError(err)
|
||||||
assert.NotNil(p)
|
assert.NotNil(p)
|
||||||
@ -348,7 +354,8 @@ func TestStartSandboxFailing(t *testing.T) {
|
|||||||
defer cleanUp()
|
defer cleanUp()
|
||||||
assert := assert.New(t)
|
assert := assert.New(t)
|
||||||
|
|
||||||
p, err := StartSandbox(context.Background(), testSandboxID)
|
ctx := WithNewAgentFunc(context.Background(), newMockAgent)
|
||||||
|
p, err := StartSandbox(ctx, testSandboxID)
|
||||||
assert.Error(err)
|
assert.Error(err)
|
||||||
assert.Nil(p)
|
assert.Nil(p)
|
||||||
}
|
}
|
||||||
@ -362,7 +369,7 @@ func TestStopSandboxNoopAgentSuccessful(t *testing.T) {
|
|||||||
|
|
||||||
config := newTestSandboxConfigNoop()
|
config := newTestSandboxConfigNoop()
|
||||||
|
|
||||||
ctx := context.Background()
|
ctx := WithNewAgentFunc(context.Background(), newMockAgent)
|
||||||
p, _, err := createAndStartSandbox(ctx, config)
|
p, _, err := createAndStartSandbox(ctx, config)
|
||||||
assert.NoError(err)
|
assert.NoError(err)
|
||||||
assert.NotNil(p)
|
assert.NotNil(p)
|
||||||
@ -399,7 +406,7 @@ func TestStopSandboxKataAgentSuccessful(t *testing.T) {
|
|||||||
assert.NoError(err)
|
assert.NoError(err)
|
||||||
defer kataProxyMock.Stop()
|
defer kataProxyMock.Stop()
|
||||||
|
|
||||||
ctx := context.Background()
|
ctx := WithNewAgentFunc(context.Background(), newMockAgent)
|
||||||
p, _, err := createAndStartSandbox(ctx, config)
|
p, _, err := createAndStartSandbox(ctx, config)
|
||||||
assert.NoError(err)
|
assert.NoError(err)
|
||||||
assert.NotNil(p)
|
assert.NotNil(p)
|
||||||
@ -412,7 +419,8 @@ func TestStopSandboxKataAgentSuccessful(t *testing.T) {
|
|||||||
func TestStopSandboxFailing(t *testing.T) {
|
func TestStopSandboxFailing(t *testing.T) {
|
||||||
defer cleanUp()
|
defer cleanUp()
|
||||||
|
|
||||||
p, err := StopSandbox(context.Background(), testSandboxID, false)
|
ctx := WithNewAgentFunc(context.Background(), newMockAgent)
|
||||||
|
p, err := StopSandbox(ctx, testSandboxID, false)
|
||||||
assert.Error(t, err)
|
assert.Error(t, err)
|
||||||
assert.Nil(t, p)
|
assert.Nil(t, p)
|
||||||
}
|
}
|
||||||
@ -423,7 +431,8 @@ func TestRunSandboxNoopAgentSuccessful(t *testing.T) {
|
|||||||
|
|
||||||
config := newTestSandboxConfigNoop()
|
config := newTestSandboxConfigNoop()
|
||||||
|
|
||||||
p, err := RunSandbox(context.Background(), config, nil)
|
ctx := WithNewAgentFunc(context.Background(), newMockAgent)
|
||||||
|
p, err := RunSandbox(ctx, config, nil)
|
||||||
assert.NoError(err)
|
assert.NoError(err)
|
||||||
assert.NotNil(p)
|
assert.NotNil(p)
|
||||||
|
|
||||||
@ -462,7 +471,7 @@ func TestRunSandboxKataAgentSuccessful(t *testing.T) {
|
|||||||
assert.NoError(err)
|
assert.NoError(err)
|
||||||
defer kataProxyMock.Stop()
|
defer kataProxyMock.Stop()
|
||||||
|
|
||||||
ctx := context.Background()
|
ctx := WithNewAgentFunc(context.Background(), newMockAgent)
|
||||||
p, err := RunSandbox(ctx, config, nil)
|
p, err := RunSandbox(ctx, config, nil)
|
||||||
assert.NoError(err)
|
assert.NoError(err)
|
||||||
assert.NotNil(p)
|
assert.NotNil(p)
|
||||||
@ -484,7 +493,8 @@ func TestRunSandboxFailing(t *testing.T) {
|
|||||||
|
|
||||||
config := SandboxConfig{}
|
config := SandboxConfig{}
|
||||||
|
|
||||||
p, err := RunSandbox(context.Background(), config, nil)
|
ctx := WithNewAgentFunc(context.Background(), newMockAgent)
|
||||||
|
p, err := RunSandbox(ctx, config, nil)
|
||||||
assert.Error(err)
|
assert.Error(err)
|
||||||
assert.Nil(p)
|
assert.Nil(p)
|
||||||
}
|
}
|
||||||
@ -495,7 +505,7 @@ func TestListSandboxSuccessful(t *testing.T) {
|
|||||||
|
|
||||||
config := newTestSandboxConfigNoop()
|
config := newTestSandboxConfigNoop()
|
||||||
|
|
||||||
ctx := context.Background()
|
ctx := WithNewAgentFunc(context.Background(), newMockAgent)
|
||||||
p, err := CreateSandbox(ctx, config, nil)
|
p, err := CreateSandbox(ctx, config, nil)
|
||||||
assert.NoError(err)
|
assert.NoError(err)
|
||||||
assert.NotNil(p)
|
assert.NotNil(p)
|
||||||
@ -507,7 +517,8 @@ func TestListSandboxSuccessful(t *testing.T) {
|
|||||||
func TestListSandboxNoSandboxDirectory(t *testing.T) {
|
func TestListSandboxNoSandboxDirectory(t *testing.T) {
|
||||||
defer cleanUp()
|
defer cleanUp()
|
||||||
|
|
||||||
_, err := ListSandbox(context.Background())
|
ctx := WithNewAgentFunc(context.Background(), newMockAgent)
|
||||||
|
_, err := ListSandbox(ctx)
|
||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -540,7 +551,6 @@ func TestStatusSandboxSuccessfulStateReady(t *testing.T) {
|
|||||||
},
|
},
|
||||||
Hypervisor: MockHypervisor,
|
Hypervisor: MockHypervisor,
|
||||||
HypervisorConfig: hypervisorConfig,
|
HypervisorConfig: hypervisorConfig,
|
||||||
Agent: NoopAgentType,
|
|
||||||
ContainersStatus: []ContainerStatus{
|
ContainersStatus: []ContainerStatus{
|
||||||
{
|
{
|
||||||
ID: containerID,
|
ID: containerID,
|
||||||
@ -556,7 +566,7 @@ func TestStatusSandboxSuccessfulStateReady(t *testing.T) {
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
ctx := context.Background()
|
ctx := WithNewAgentFunc(context.Background(), newMockAgent)
|
||||||
p, err := CreateSandbox(ctx, config, nil)
|
p, err := CreateSandbox(ctx, config, nil)
|
||||||
assert.NoError(err)
|
assert.NoError(err)
|
||||||
assert.NotNil(p)
|
assert.NotNil(p)
|
||||||
@ -568,7 +578,7 @@ func TestStatusSandboxSuccessfulStateReady(t *testing.T) {
|
|||||||
// value will be.
|
// value will be.
|
||||||
expectedStatus.ContainersStatus[0].StartTime = status.ContainersStatus[0].StartTime
|
expectedStatus.ContainersStatus[0].StartTime = status.ContainersStatus[0].StartTime
|
||||||
|
|
||||||
assert.Equal(status, expectedStatus)
|
assert.Equal(expectedStatus, status)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestStatusSandboxSuccessfulStateRunning(t *testing.T) {
|
func TestStatusSandboxSuccessfulStateRunning(t *testing.T) {
|
||||||
@ -600,7 +610,6 @@ func TestStatusSandboxSuccessfulStateRunning(t *testing.T) {
|
|||||||
},
|
},
|
||||||
Hypervisor: MockHypervisor,
|
Hypervisor: MockHypervisor,
|
||||||
HypervisorConfig: hypervisorConfig,
|
HypervisorConfig: hypervisorConfig,
|
||||||
Agent: NoopAgentType,
|
|
||||||
ContainersStatus: []ContainerStatus{
|
ContainersStatus: []ContainerStatus{
|
||||||
{
|
{
|
||||||
ID: containerID,
|
ID: containerID,
|
||||||
@ -616,7 +625,7 @@ func TestStatusSandboxSuccessfulStateRunning(t *testing.T) {
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
ctx := context.Background()
|
ctx := WithNewAgentFunc(context.Background(), newMockAgent)
|
||||||
p, err := CreateSandbox(ctx, config, nil)
|
p, err := CreateSandbox(ctx, config, nil)
|
||||||
assert.NoError(err)
|
assert.NoError(err)
|
||||||
assert.NotNil(p)
|
assert.NotNil(p)
|
||||||
@ -632,7 +641,7 @@ func TestStatusSandboxSuccessfulStateRunning(t *testing.T) {
|
|||||||
// value will be.
|
// value will be.
|
||||||
expectedStatus.ContainersStatus[0].StartTime = status.ContainersStatus[0].StartTime
|
expectedStatus.ContainersStatus[0].StartTime = status.ContainersStatus[0].StartTime
|
||||||
|
|
||||||
assert.Exactly(status, expectedStatus)
|
assert.Exactly(expectedStatus, status)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestStatusSandboxFailingFetchSandboxConfig(t *testing.T) {
|
func TestStatusSandboxFailingFetchSandboxConfig(t *testing.T) {
|
||||||
@ -641,7 +650,7 @@ func TestStatusSandboxFailingFetchSandboxConfig(t *testing.T) {
|
|||||||
|
|
||||||
config := newTestSandboxConfigNoop()
|
config := newTestSandboxConfigNoop()
|
||||||
|
|
||||||
ctx := context.Background()
|
ctx := WithNewAgentFunc(context.Background(), newMockAgent)
|
||||||
p, err := CreateSandbox(ctx, config, nil)
|
p, err := CreateSandbox(ctx, config, nil)
|
||||||
assert.NoError(err)
|
assert.NoError(err)
|
||||||
assert.NotNil(p)
|
assert.NotNil(p)
|
||||||
@ -659,7 +668,7 @@ func TestStatusPodSandboxFailingFetchSandboxState(t *testing.T) {
|
|||||||
|
|
||||||
config := newTestSandboxConfigNoop()
|
config := newTestSandboxConfigNoop()
|
||||||
|
|
||||||
ctx := context.Background()
|
ctx := WithNewAgentFunc(context.Background(), newMockAgent)
|
||||||
p, err := CreateSandbox(ctx, config, nil)
|
p, err := CreateSandbox(ctx, config, nil)
|
||||||
assert.NoError(err)
|
assert.NoError(err)
|
||||||
assert.NotNil(p)
|
assert.NotNil(p)
|
||||||
@ -691,7 +700,7 @@ func TestCreateContainerSuccessful(t *testing.T) {
|
|||||||
contID := "100"
|
contID := "100"
|
||||||
config := newTestSandboxConfigNoop()
|
config := newTestSandboxConfigNoop()
|
||||||
|
|
||||||
ctx := context.Background()
|
ctx := WithNewAgentFunc(context.Background(), newMockAgent)
|
||||||
p, err := CreateSandbox(ctx, config, nil)
|
p, err := CreateSandbox(ctx, config, nil)
|
||||||
assert.NoError(err)
|
assert.NoError(err)
|
||||||
assert.NotNil(p)
|
assert.NotNil(p)
|
||||||
@ -720,7 +729,7 @@ func TestCreateContainerFailingNoSandbox(t *testing.T) {
|
|||||||
contID := "100"
|
contID := "100"
|
||||||
config := newTestSandboxConfigNoop()
|
config := newTestSandboxConfigNoop()
|
||||||
|
|
||||||
ctx := context.Background()
|
ctx := WithNewAgentFunc(context.Background(), newMockAgent)
|
||||||
p, err := CreateSandbox(ctx, config, nil)
|
p, err := CreateSandbox(ctx, config, nil)
|
||||||
assert.NoError(err)
|
assert.NoError(err)
|
||||||
assert.NotNil(p)
|
assert.NotNil(p)
|
||||||
@ -749,7 +758,7 @@ func TestDeleteContainerSuccessful(t *testing.T) {
|
|||||||
contID := "100"
|
contID := "100"
|
||||||
config := newTestSandboxConfigNoop()
|
config := newTestSandboxConfigNoop()
|
||||||
|
|
||||||
ctx := context.Background()
|
ctx := WithNewAgentFunc(context.Background(), newMockAgent)
|
||||||
p, err := CreateSandbox(ctx, config, nil)
|
p, err := CreateSandbox(ctx, config, nil)
|
||||||
assert.NoError(err)
|
assert.NoError(err)
|
||||||
assert.NotNil(p)
|
assert.NotNil(p)
|
||||||
@ -783,7 +792,9 @@ func TestDeleteContainerFailingNoSandbox(t *testing.T) {
|
|||||||
assert := assert.New(t)
|
assert := assert.New(t)
|
||||||
|
|
||||||
contID := "100"
|
contID := "100"
|
||||||
c, err := DeleteContainer(context.Background(), testSandboxID, contID)
|
|
||||||
|
ctx := WithNewAgentFunc(context.Background(), newMockAgent)
|
||||||
|
c, err := DeleteContainer(ctx, testSandboxID, contID)
|
||||||
assert.Error(err)
|
assert.Error(err)
|
||||||
assert.Nil(c)
|
assert.Nil(c)
|
||||||
}
|
}
|
||||||
@ -795,7 +806,7 @@ func TestDeleteContainerFailingNoContainer(t *testing.T) {
|
|||||||
contID := "100"
|
contID := "100"
|
||||||
config := newTestSandboxConfigNoop()
|
config := newTestSandboxConfigNoop()
|
||||||
|
|
||||||
ctx := context.Background()
|
ctx := WithNewAgentFunc(context.Background(), newMockAgent)
|
||||||
p, err := CreateSandbox(ctx, config, nil)
|
p, err := CreateSandbox(ctx, config, nil)
|
||||||
assert.NoError(err)
|
assert.NoError(err)
|
||||||
assert.NotNil(p)
|
assert.NotNil(p)
|
||||||
@ -818,7 +829,7 @@ func TestStartContainerNoopAgentSuccessful(t *testing.T) {
|
|||||||
contID := "100"
|
contID := "100"
|
||||||
config := newTestSandboxConfigNoop()
|
config := newTestSandboxConfigNoop()
|
||||||
|
|
||||||
ctx := context.Background()
|
ctx := WithNewAgentFunc(context.Background(), newMockAgent)
|
||||||
|
|
||||||
p, sandboxDir, err := createAndStartSandbox(ctx, config)
|
p, sandboxDir, err := createAndStartSandbox(ctx, config)
|
||||||
assert.NoError(err)
|
assert.NoError(err)
|
||||||
@ -842,7 +853,8 @@ func TestStartContainerFailingNoSandbox(t *testing.T) {
|
|||||||
defer cleanUp()
|
defer cleanUp()
|
||||||
|
|
||||||
contID := "100"
|
contID := "100"
|
||||||
c, err := StartContainer(context.Background(), testSandboxID, contID)
|
ctx := WithNewAgentFunc(context.Background(), newMockAgent)
|
||||||
|
c, err := StartContainer(ctx, testSandboxID, contID)
|
||||||
assert.Error(t, err)
|
assert.Error(t, err)
|
||||||
assert.Nil(t, c)
|
assert.Nil(t, c)
|
||||||
}
|
}
|
||||||
@ -854,7 +866,7 @@ func TestStartContainerFailingNoContainer(t *testing.T) {
|
|||||||
contID := "100"
|
contID := "100"
|
||||||
config := newTestSandboxConfigNoop()
|
config := newTestSandboxConfigNoop()
|
||||||
|
|
||||||
ctx := context.Background()
|
ctx := WithNewAgentFunc(context.Background(), newMockAgent)
|
||||||
p, err := CreateSandbox(ctx, config, nil)
|
p, err := CreateSandbox(ctx, config, nil)
|
||||||
assert.NoError(err)
|
assert.NoError(err)
|
||||||
assert.NotNil(p)
|
assert.NotNil(p)
|
||||||
@ -877,7 +889,7 @@ func TestStartContainerFailingSandboxNotStarted(t *testing.T) {
|
|||||||
contID := "100"
|
contID := "100"
|
||||||
config := newTestSandboxConfigNoop()
|
config := newTestSandboxConfigNoop()
|
||||||
|
|
||||||
ctx := context.Background()
|
ctx := WithNewAgentFunc(context.Background(), newMockAgent)
|
||||||
p, err := CreateSandbox(ctx, config, nil)
|
p, err := CreateSandbox(ctx, config, nil)
|
||||||
assert.NoError(err)
|
assert.NoError(err)
|
||||||
assert.NotNil(p)
|
assert.NotNil(p)
|
||||||
@ -912,7 +924,7 @@ func TestStopContainerNoopAgentSuccessful(t *testing.T) {
|
|||||||
contID := "100"
|
contID := "100"
|
||||||
config := newTestSandboxConfigNoop()
|
config := newTestSandboxConfigNoop()
|
||||||
|
|
||||||
ctx := context.Background()
|
ctx := WithNewAgentFunc(context.Background(), newMockAgent)
|
||||||
|
|
||||||
p, sandboxDir, err := createAndStartSandbox(ctx, config)
|
p, sandboxDir, err := createAndStartSandbox(ctx, config)
|
||||||
assert.NoError(err)
|
assert.NoError(err)
|
||||||
@ -944,7 +956,8 @@ func TestStopContainerFailingNoSandbox(t *testing.T) {
|
|||||||
defer cleanUp()
|
defer cleanUp()
|
||||||
|
|
||||||
contID := "100"
|
contID := "100"
|
||||||
c, err := StopContainer(context.Background(), testSandboxID, contID)
|
ctx := WithNewAgentFunc(context.Background(), newMockAgent)
|
||||||
|
c, err := StopContainer(ctx, testSandboxID, contID)
|
||||||
assert.Error(t, err)
|
assert.Error(t, err)
|
||||||
assert.Nil(t, c)
|
assert.Nil(t, c)
|
||||||
}
|
}
|
||||||
@ -959,7 +972,7 @@ func TestStopContainerFailingNoContainer(t *testing.T) {
|
|||||||
contID := "100"
|
contID := "100"
|
||||||
config := newTestSandboxConfigNoop()
|
config := newTestSandboxConfigNoop()
|
||||||
|
|
||||||
ctx := context.Background()
|
ctx := WithNewAgentFunc(context.Background(), newMockAgent)
|
||||||
p, err := CreateSandbox(ctx, config, nil)
|
p, err := CreateSandbox(ctx, config, nil)
|
||||||
assert.NoError(err)
|
assert.NoError(err)
|
||||||
assert.NotNil(p)
|
assert.NotNil(p)
|
||||||
@ -982,7 +995,7 @@ func testKillContainerFromContReadySuccessful(t *testing.T, signal syscall.Signa
|
|||||||
contID := "100"
|
contID := "100"
|
||||||
config := newTestSandboxConfigNoop()
|
config := newTestSandboxConfigNoop()
|
||||||
|
|
||||||
ctx := context.Background()
|
ctx := WithNewAgentFunc(context.Background(), newMockAgent)
|
||||||
|
|
||||||
p, sandboxDir, err := createAndStartSandbox(ctx, config)
|
p, sandboxDir, err := createAndStartSandbox(ctx, config)
|
||||||
assert.NoError(err)
|
assert.NoError(err)
|
||||||
@ -1020,7 +1033,7 @@ func TestEnterContainerNoopAgentSuccessful(t *testing.T) {
|
|||||||
contID := "100"
|
contID := "100"
|
||||||
config := newTestSandboxConfigNoop()
|
config := newTestSandboxConfigNoop()
|
||||||
|
|
||||||
ctx := context.Background()
|
ctx := WithNewAgentFunc(context.Background(), newMockAgent)
|
||||||
|
|
||||||
p, sandboxDir, err := createAndStartSandbox(ctx, config)
|
p, sandboxDir, err := createAndStartSandbox(ctx, config)
|
||||||
assert.NoError(err)
|
assert.NoError(err)
|
||||||
@ -1053,7 +1066,8 @@ func TestEnterContainerFailingNoSandbox(t *testing.T) {
|
|||||||
contID := "100"
|
contID := "100"
|
||||||
cmd := newBasicTestCmd()
|
cmd := newBasicTestCmd()
|
||||||
|
|
||||||
_, c, _, err := EnterContainer(context.Background(), testSandboxID, contID, cmd)
|
ctx := WithNewAgentFunc(context.Background(), newMockAgent)
|
||||||
|
_, c, _, err := EnterContainer(ctx, testSandboxID, contID, cmd)
|
||||||
assert.Error(err)
|
assert.Error(err)
|
||||||
assert.Nil(c)
|
assert.Nil(c)
|
||||||
}
|
}
|
||||||
@ -1065,7 +1079,7 @@ func TestEnterContainerFailingNoContainer(t *testing.T) {
|
|||||||
contID := "100"
|
contID := "100"
|
||||||
config := newTestSandboxConfigNoop()
|
config := newTestSandboxConfigNoop()
|
||||||
|
|
||||||
ctx := context.Background()
|
ctx := WithNewAgentFunc(context.Background(), newMockAgent)
|
||||||
p, err := CreateSandbox(ctx, config, nil)
|
p, err := CreateSandbox(ctx, config, nil)
|
||||||
assert.NoError(err)
|
assert.NoError(err)
|
||||||
assert.NotNil(p)
|
assert.NotNil(p)
|
||||||
@ -1090,7 +1104,7 @@ func TestEnterContainerFailingContNotStarted(t *testing.T) {
|
|||||||
contID := "100"
|
contID := "100"
|
||||||
config := newTestSandboxConfigNoop()
|
config := newTestSandboxConfigNoop()
|
||||||
|
|
||||||
ctx := context.Background()
|
ctx := WithNewAgentFunc(context.Background(), newMockAgent)
|
||||||
|
|
||||||
p, sandboxDir, err := createAndStartSandbox(ctx, config)
|
p, sandboxDir, err := createAndStartSandbox(ctx, config)
|
||||||
assert.NoError(err)
|
assert.NoError(err)
|
||||||
@ -1120,7 +1134,7 @@ func TestStatusContainerSuccessful(t *testing.T) {
|
|||||||
contID := "100"
|
contID := "100"
|
||||||
config := newTestSandboxConfigNoop()
|
config := newTestSandboxConfigNoop()
|
||||||
|
|
||||||
ctx := context.Background()
|
ctx := WithNewAgentFunc(context.Background(), newMockAgent)
|
||||||
p, err := CreateSandbox(ctx, config, nil)
|
p, err := CreateSandbox(ctx, config, nil)
|
||||||
assert.NoError(err)
|
assert.NoError(err)
|
||||||
assert.NotNil(p)
|
assert.NotNil(p)
|
||||||
@ -1162,7 +1176,7 @@ func TestStatusContainerStateReady(t *testing.T) {
|
|||||||
cgroupPath, err := vccgroups.RenameCgroupPath(vccgroups.DefaultCgroupPath)
|
cgroupPath, err := vccgroups.RenameCgroupPath(vccgroups.DefaultCgroupPath)
|
||||||
assert.NoError(err)
|
assert.NoError(err)
|
||||||
|
|
||||||
ctx := context.Background()
|
ctx := WithNewAgentFunc(context.Background(), newMockAgent)
|
||||||
p, err := CreateSandbox(ctx, config, nil)
|
p, err := CreateSandbox(ctx, config, nil)
|
||||||
assert.NoError(err)
|
assert.NoError(err)
|
||||||
assert.NotNil(p)
|
assert.NotNil(p)
|
||||||
@ -1209,7 +1223,7 @@ func TestStatusContainerStateReady(t *testing.T) {
|
|||||||
// value will be.
|
// value will be.
|
||||||
expectedStatus.StartTime = status.StartTime
|
expectedStatus.StartTime = status.StartTime
|
||||||
|
|
||||||
assert.Exactly(status, expectedStatus)
|
assert.Exactly(expectedStatus, status)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestStatusContainerStateRunning(t *testing.T) {
|
func TestStatusContainerStateRunning(t *testing.T) {
|
||||||
@ -1223,7 +1237,7 @@ func TestStatusContainerStateRunning(t *testing.T) {
|
|||||||
cgroupPath, err := vccgroups.RenameCgroupPath(vccgroups.DefaultCgroupPath)
|
cgroupPath, err := vccgroups.RenameCgroupPath(vccgroups.DefaultCgroupPath)
|
||||||
assert.NoError(err)
|
assert.NoError(err)
|
||||||
|
|
||||||
ctx := context.Background()
|
ctx := WithNewAgentFunc(context.Background(), newMockAgent)
|
||||||
p, err := CreateSandbox(ctx, config, nil)
|
p, err := CreateSandbox(ctx, config, nil)
|
||||||
assert.NoError(err)
|
assert.NoError(err)
|
||||||
assert.NotNil(p)
|
assert.NotNil(p)
|
||||||
@ -1278,7 +1292,7 @@ func TestStatusContainerStateRunning(t *testing.T) {
|
|||||||
// value will be.
|
// value will be.
|
||||||
expectedStatus.StartTime = status.StartTime
|
expectedStatus.StartTime = status.StartTime
|
||||||
|
|
||||||
assert.Exactly(status, expectedStatus)
|
assert.Exactly(expectedStatus, status)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestStatusContainerFailing(t *testing.T) {
|
func TestStatusContainerFailing(t *testing.T) {
|
||||||
@ -1288,7 +1302,7 @@ func TestStatusContainerFailing(t *testing.T) {
|
|||||||
contID := "100"
|
contID := "100"
|
||||||
config := newTestSandboxConfigNoop()
|
config := newTestSandboxConfigNoop()
|
||||||
|
|
||||||
ctx := context.Background()
|
ctx := WithNewAgentFunc(context.Background(), newMockAgent)
|
||||||
p, err := CreateSandbox(ctx, config, nil)
|
p, err := CreateSandbox(ctx, config, nil)
|
||||||
assert.NoError(err)
|
assert.NoError(err)
|
||||||
assert.NotNil(p)
|
assert.NotNil(p)
|
||||||
@ -1307,7 +1321,7 @@ func TestStatsContainerFailing(t *testing.T) {
|
|||||||
contID := "100"
|
contID := "100"
|
||||||
config := newTestSandboxConfigNoop()
|
config := newTestSandboxConfigNoop()
|
||||||
|
|
||||||
ctx := context.Background()
|
ctx := WithNewAgentFunc(context.Background(), newMockAgent)
|
||||||
p, err := CreateSandbox(ctx, config, nil)
|
p, err := CreateSandbox(ctx, config, nil)
|
||||||
assert.NoError(err)
|
assert.NoError(err)
|
||||||
assert.NotNil(p)
|
assert.NotNil(p)
|
||||||
@ -1325,7 +1339,7 @@ func TestStatsContainer(t *testing.T) {
|
|||||||
assert := assert.New(t)
|
assert := assert.New(t)
|
||||||
contID := "100"
|
contID := "100"
|
||||||
|
|
||||||
ctx := context.Background()
|
ctx := WithNewAgentFunc(context.Background(), newMockAgent)
|
||||||
_, err := StatsContainer(ctx, "", "")
|
_, err := StatsContainer(ctx, "", "")
|
||||||
assert.Error(err)
|
assert.Error(err)
|
||||||
|
|
||||||
@ -1360,7 +1374,7 @@ func TestStatsContainer(t *testing.T) {
|
|||||||
|
|
||||||
stats, err := StatsContainer(ctx, pImpl.id, contID)
|
stats, err := StatsContainer(ctx, pImpl.id, contID)
|
||||||
assert.NoError(err)
|
assert.NoError(err)
|
||||||
assert.Equal(stats, ContainerStats{})
|
assert.Equal(ContainerStats{}, stats)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestProcessListContainer(t *testing.T) {
|
func TestProcessListContainer(t *testing.T) {
|
||||||
@ -1374,7 +1388,7 @@ func TestProcessListContainer(t *testing.T) {
|
|||||||
Args: []string{"-ef"},
|
Args: []string{"-ef"},
|
||||||
}
|
}
|
||||||
|
|
||||||
ctx := context.Background()
|
ctx := WithNewAgentFunc(context.Background(), newMockAgent)
|
||||||
_, err := ProcessListContainer(ctx, "", "", options)
|
_, err := ProcessListContainer(ctx, "", "", options)
|
||||||
assert.Error(err)
|
assert.Error(err)
|
||||||
|
|
||||||
@ -1412,7 +1426,7 @@ func TestProcessListContainer(t *testing.T) {
|
|||||||
* Benchmarks
|
* Benchmarks
|
||||||
*/
|
*/
|
||||||
|
|
||||||
func createNewSandboxConfig(hType HypervisorType, aType AgentType, aConfig interface{}) SandboxConfig {
|
func createNewSandboxConfig(hType HypervisorType) SandboxConfig {
|
||||||
hypervisorConfig := HypervisorConfig{
|
hypervisorConfig := HypervisorConfig{
|
||||||
KernelPath: "/usr/share/kata-containers/vmlinux.container",
|
KernelPath: "/usr/share/kata-containers/vmlinux.container",
|
||||||
ImagePath: "/usr/share/kata-containers/kata-containers.img",
|
ImagePath: "/usr/share/kata-containers/kata-containers.img",
|
||||||
@ -1426,8 +1440,7 @@ func createNewSandboxConfig(hType HypervisorType, aType AgentType, aConfig inter
|
|||||||
HypervisorType: hType,
|
HypervisorType: hType,
|
||||||
HypervisorConfig: hypervisorConfig,
|
HypervisorConfig: hypervisorConfig,
|
||||||
|
|
||||||
AgentType: aType,
|
AgentConfig: KataAgentConfig{},
|
||||||
AgentConfig: aConfig,
|
|
||||||
|
|
||||||
NetworkConfig: netConfig,
|
NetworkConfig: netConfig,
|
||||||
|
|
||||||
@ -1466,7 +1479,7 @@ func createAndStartSandbox(ctx context.Context, config SandboxConfig) (sandbox V
|
|||||||
}
|
}
|
||||||
|
|
||||||
func createStartStopDeleteSandbox(b *testing.B, sandboxConfig SandboxConfig) {
|
func createStartStopDeleteSandbox(b *testing.B, sandboxConfig SandboxConfig) {
|
||||||
ctx := context.Background()
|
ctx := WithNewAgentFunc(context.Background(), newMockAgent)
|
||||||
|
|
||||||
p, _, err := createAndStartSandbox(ctx, sandboxConfig)
|
p, _, err := createAndStartSandbox(ctx, sandboxConfig)
|
||||||
if p == nil || err != nil {
|
if p == nil || err != nil {
|
||||||
@ -1488,14 +1501,14 @@ func createStartStopDeleteSandbox(b *testing.B, sandboxConfig SandboxConfig) {
|
|||||||
|
|
||||||
func BenchmarkCreateStartStopDeleteSandboxQemuHypervisorNoopAgentNetworkNoop(b *testing.B) {
|
func BenchmarkCreateStartStopDeleteSandboxQemuHypervisorNoopAgentNetworkNoop(b *testing.B) {
|
||||||
for i := 0; i < b.N; i++ {
|
for i := 0; i < b.N; i++ {
|
||||||
sandboxConfig := createNewSandboxConfig(QemuHypervisor, NoopAgentType, nil)
|
sandboxConfig := createNewSandboxConfig(QemuHypervisor)
|
||||||
createStartStopDeleteSandbox(b, sandboxConfig)
|
createStartStopDeleteSandbox(b, sandboxConfig)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func BenchmarkCreateStartStopDeleteSandboxMockHypervisorNoopAgentNetworkNoop(b *testing.B) {
|
func BenchmarkCreateStartStopDeleteSandboxMockHypervisorNoopAgentNetworkNoop(b *testing.B) {
|
||||||
for i := 0; i < b.N; i++ {
|
for i := 0; i < b.N; i++ {
|
||||||
sandboxConfig := createNewSandboxConfig(MockHypervisor, NoopAgentType, nil)
|
sandboxConfig := createNewSandboxConfig(MockHypervisor)
|
||||||
createStartStopDeleteSandbox(b, sandboxConfig)
|
createStartStopDeleteSandbox(b, sandboxConfig)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1505,8 +1518,7 @@ func TestFetchSandbox(t *testing.T) {
|
|||||||
|
|
||||||
config := newTestSandboxConfigNoop()
|
config := newTestSandboxConfigNoop()
|
||||||
|
|
||||||
ctx := context.Background()
|
ctx := WithNewAgentFunc(context.Background(), newMockAgent)
|
||||||
|
|
||||||
s, err := CreateSandbox(ctx, config, nil)
|
s, err := CreateSandbox(ctx, config, nil)
|
||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
assert.NotNil(t, s)
|
assert.NotNil(t, s)
|
||||||
@ -1523,8 +1535,7 @@ func TestFetchStatefulSandbox(t *testing.T) {
|
|||||||
|
|
||||||
config.Stateful = true
|
config.Stateful = true
|
||||||
|
|
||||||
ctx := context.Background()
|
ctx := WithNewAgentFunc(context.Background(), newMockAgent)
|
||||||
|
|
||||||
s, err := CreateSandbox(ctx, config, nil)
|
s, err := CreateSandbox(ctx, config, nil)
|
||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
assert.NotNil(t, s)
|
assert.NotNil(t, s)
|
||||||
@ -1537,7 +1548,8 @@ func TestFetchStatefulSandbox(t *testing.T) {
|
|||||||
func TestFetchNonExistingSandbox(t *testing.T) {
|
func TestFetchNonExistingSandbox(t *testing.T) {
|
||||||
defer cleanUp()
|
defer cleanUp()
|
||||||
|
|
||||||
_, err := FetchSandbox(context.Background(), "some-non-existing-sandbox-name")
|
ctx := WithNewAgentFunc(context.Background(), newMockAgent)
|
||||||
|
_, err := FetchSandbox(ctx, "some-non-existing-sandbox-name")
|
||||||
assert.NotNil(t, err, "fetch non-existing sandbox should fail")
|
assert.NotNil(t, err, "fetch non-existing sandbox should fail")
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1546,7 +1558,8 @@ func TestReleaseSandbox(t *testing.T) {
|
|||||||
|
|
||||||
config := newTestSandboxConfigNoop()
|
config := newTestSandboxConfigNoop()
|
||||||
|
|
||||||
s, err := CreateSandbox(context.Background(), config, nil)
|
ctx := WithNewAgentFunc(context.Background(), newMockAgent)
|
||||||
|
s, err := CreateSandbox(ctx, config, nil)
|
||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
assert.NotNil(t, s)
|
assert.NotNil(t, s)
|
||||||
|
|
||||||
@ -1561,7 +1574,7 @@ func TestUpdateContainer(t *testing.T) {
|
|||||||
|
|
||||||
defer cleanUp()
|
defer cleanUp()
|
||||||
|
|
||||||
ctx := context.Background()
|
ctx := WithNewAgentFunc(context.Background(), newMockAgent)
|
||||||
|
|
||||||
period := uint64(1000)
|
period := uint64(1000)
|
||||||
quota := int64(2000)
|
quota := int64(2000)
|
||||||
@ -1614,7 +1627,7 @@ func TestPauseResumeContainer(t *testing.T) {
|
|||||||
|
|
||||||
defer cleanUp()
|
defer cleanUp()
|
||||||
|
|
||||||
ctx := context.Background()
|
ctx := WithNewAgentFunc(context.Background(), newMockAgent)
|
||||||
|
|
||||||
assert := assert.New(t)
|
assert := assert.New(t)
|
||||||
err := PauseContainer(ctx, "", "")
|
err := PauseContainer(ctx, "", "")
|
||||||
@ -1669,7 +1682,7 @@ func TestNetworkOperation(t *testing.T) {
|
|||||||
}
|
}
|
||||||
inf.IPAddresses = append(inf.IPAddresses, &ip)
|
inf.IPAddresses = append(inf.IPAddresses, &ip)
|
||||||
|
|
||||||
ctx := context.Background()
|
ctx := WithNewAgentFunc(context.Background(), newMockAgent)
|
||||||
|
|
||||||
_, err := AddInterface(ctx, "", inf)
|
_, err := AddInterface(ctx, "", inf)
|
||||||
assert.Error(err)
|
assert.Error(err)
|
||||||
@ -1710,7 +1723,7 @@ func TestCleanupContainer(t *testing.T) {
|
|||||||
config := newTestSandboxConfigNoop()
|
config := newTestSandboxConfigNoop()
|
||||||
assert := assert.New(t)
|
assert := assert.New(t)
|
||||||
|
|
||||||
ctx := context.Background()
|
ctx := WithNewAgentFunc(context.Background(), newMockAgent)
|
||||||
|
|
||||||
p, _, err := createAndStartSandbox(ctx, config)
|
p, _, err := createAndStartSandbox(ctx, config)
|
||||||
if p == nil || err != nil {
|
if p == nil || err != nil {
|
||||||
|
@ -308,7 +308,7 @@ func TestContainerAddDriveDir(t *testing.T) {
|
|||||||
id: testSandboxID,
|
id: testSandboxID,
|
||||||
devManager: manager.NewDeviceManager(manager.VirtioSCSI, false, "", nil),
|
devManager: manager.NewDeviceManager(manager.VirtioSCSI, false, "", nil),
|
||||||
hypervisor: &mockHypervisor{},
|
hypervisor: &mockHypervisor{},
|
||||||
agent: &noopAgent{},
|
agent: &mockAgent{},
|
||||||
config: &SandboxConfig{
|
config: &SandboxConfig{
|
||||||
HypervisorConfig: HypervisorConfig{
|
HypervisorConfig: HypervisorConfig{
|
||||||
DisableBlockDeviceUse: false,
|
DisableBlockDeviceUse: false,
|
||||||
@ -364,7 +364,7 @@ func TestContainerRootfsPath(t *testing.T) {
|
|||||||
sandbox := &Sandbox{
|
sandbox := &Sandbox{
|
||||||
ctx: context.Background(),
|
ctx: context.Background(),
|
||||||
id: "rootfstestsandbox",
|
id: "rootfstestsandbox",
|
||||||
agent: &noopAgent{},
|
agent: &mockAgent{},
|
||||||
hypervisor: &mockHypervisor{},
|
hypervisor: &mockHypervisor{},
|
||||||
config: &SandboxConfig{
|
config: &SandboxConfig{
|
||||||
HypervisorConfig: HypervisorConfig{
|
HypervisorConfig: HypervisorConfig{
|
||||||
|
@ -36,7 +36,6 @@ sandbox lifecycle through the rest of the [sandbox API](#sandbox-functions).
|
|||||||
* [`Resources`](#resources)
|
* [`Resources`](#resources)
|
||||||
* [`HypervisorType`](#hypervisortype)
|
* [`HypervisorType`](#hypervisortype)
|
||||||
* [`HypervisorConfig`](#hypervisorconfig)
|
* [`HypervisorConfig`](#hypervisorconfig)
|
||||||
* [`AgentType`](#agenttype)
|
|
||||||
* [`ProxyType`](#proxytype)
|
* [`ProxyType`](#proxytype)
|
||||||
* [`ProxyConfig`](#proxyconfig)
|
* [`ProxyConfig`](#proxyconfig)
|
||||||
* [`ShimType`](#shimtype)
|
* [`ShimType`](#shimtype)
|
||||||
@ -66,7 +65,6 @@ type SandboxConfig struct {
|
|||||||
HypervisorType HypervisorType
|
HypervisorType HypervisorType
|
||||||
HypervisorConfig HypervisorConfig
|
HypervisorConfig HypervisorConfig
|
||||||
|
|
||||||
AgentType AgentType
|
|
||||||
AgentConfig interface{}
|
AgentConfig interface{}
|
||||||
|
|
||||||
ProxyType ProxyType
|
ProxyType ProxyType
|
||||||
@ -201,27 +199,6 @@ type HypervisorConfig struct {
|
|||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
##### `AgentType`
|
|
||||||
```Go
|
|
||||||
// AgentType describes the type of guest agent a Sandbox should run.
|
|
||||||
type AgentType string
|
|
||||||
|
|
||||||
const (
|
|
||||||
// NoopAgentType is the No-Op agent.
|
|
||||||
NoopAgentType AgentType = "noop"
|
|
||||||
|
|
||||||
// KataContainersAgent is the Kata Containers agent.
|
|
||||||
KataContainersAgent AgentType = "kata"
|
|
||||||
|
|
||||||
// SocketTypeVSOCK is a VSOCK socket type for talking to an agent.
|
|
||||||
SocketTypeVSOCK = "vsock"
|
|
||||||
|
|
||||||
// SocketTypeUNIX is a UNIX socket type for talking to an agent.
|
|
||||||
// It typically means the agent is living behind a host proxy.
|
|
||||||
SocketTypeUNIX = "unix"
|
|
||||||
)
|
|
||||||
```
|
|
||||||
|
|
||||||
##### `ProxyType`
|
##### `ProxyType`
|
||||||
```Go
|
```Go
|
||||||
// ProxyType describes a proxy type.
|
// ProxyType describes a proxy type.
|
||||||
@ -891,7 +868,6 @@ func Example_createAndStartSandbox() {
|
|||||||
HypervisorType: vc.QemuHypervisor,
|
HypervisorType: vc.QemuHypervisor,
|
||||||
HypervisorConfig: hypervisorConfig,
|
HypervisorConfig: hypervisorConfig,
|
||||||
|
|
||||||
AgentType: vc.KataContainersAgent
|
|
||||||
AgentConfig: agConfig,
|
AgentConfig: agConfig,
|
||||||
|
|
||||||
Containers: []vc.ContainerConfig{container},
|
Containers: []vc.ContainerConfig{container},
|
||||||
|
@ -58,7 +58,6 @@ func Example_createAndStartSandbox() {
|
|||||||
HypervisorType: vc.QemuHypervisor,
|
HypervisorType: vc.QemuHypervisor,
|
||||||
HypervisorConfig: hypervisorConfig,
|
HypervisorConfig: hypervisorConfig,
|
||||||
|
|
||||||
AgentType: vc.KataContainersAgent,
|
|
||||||
AgentConfig: agConfig,
|
AgentConfig: agConfig,
|
||||||
|
|
||||||
Containers: []vc.ContainerConfig{container},
|
Containers: []vc.ContainerConfig{container},
|
||||||
|
@ -28,12 +28,11 @@ func TestTemplateFactory(t *testing.T) {
|
|||||||
}
|
}
|
||||||
vmConfig := vc.VMConfig{
|
vmConfig := vc.VMConfig{
|
||||||
HypervisorType: vc.MockHypervisor,
|
HypervisorType: vc.MockHypervisor,
|
||||||
AgentType: vc.NoopAgentType,
|
|
||||||
ProxyType: vc.NoopProxyType,
|
ProxyType: vc.NoopProxyType,
|
||||||
HypervisorConfig: hyperConfig,
|
HypervisorConfig: hyperConfig,
|
||||||
}
|
}
|
||||||
|
|
||||||
ctx := context.Background()
|
ctx := vc.WithNewAgentFunc(context.Background(), vc.NewMockAgent)
|
||||||
|
|
||||||
// New
|
// New
|
||||||
f := New(ctx, 2, direct.New(ctx, vmConfig))
|
f := New(ctx, 2, direct.New(ctx, vmConfig))
|
||||||
|
@ -27,12 +27,11 @@ func TestTemplateFactory(t *testing.T) {
|
|||||||
}
|
}
|
||||||
vmConfig := vc.VMConfig{
|
vmConfig := vc.VMConfig{
|
||||||
HypervisorType: vc.MockHypervisor,
|
HypervisorType: vc.MockHypervisor,
|
||||||
AgentType: vc.NoopAgentType,
|
|
||||||
ProxyType: vc.NoopProxyType,
|
ProxyType: vc.NoopProxyType,
|
||||||
HypervisorConfig: hyperConfig,
|
HypervisorConfig: hyperConfig,
|
||||||
}
|
}
|
||||||
|
|
||||||
ctx := context.Background()
|
ctx := vc.WithNewAgentFunc(context.Background(), vc.NewMockAgent)
|
||||||
|
|
||||||
// New
|
// New
|
||||||
f := New(ctx, vmConfig)
|
f := New(ctx, vmConfig)
|
||||||
|
@ -121,10 +121,6 @@ func checkVMConfig(config1, config2 vc.VMConfig) error {
|
|||||||
return fmt.Errorf("hypervisor type does not match: %s vs. %s", config1.HypervisorType, config2.HypervisorType)
|
return fmt.Errorf("hypervisor type does not match: %s vs. %s", config1.HypervisorType, config2.HypervisorType)
|
||||||
}
|
}
|
||||||
|
|
||||||
if config1.AgentType != config2.AgentType {
|
|
||||||
return fmt.Errorf("agent type does not match: %s vs. %s", config1.AgentType, config2.AgentType)
|
|
||||||
}
|
|
||||||
|
|
||||||
// check hypervisor config details
|
// check hypervisor config details
|
||||||
resetHypervisorConfig(&config1)
|
resetHypervisorConfig(&config1)
|
||||||
resetHypervisorConfig(&config2)
|
resetHypervisorConfig(&config2)
|
||||||
@ -143,10 +139,6 @@ func (f *factory) checkConfig(config vc.VMConfig) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (f *factory) validateNewVMConfig(config vc.VMConfig) error {
|
func (f *factory) validateNewVMConfig(config vc.VMConfig) error {
|
||||||
if len(config.AgentType.String()) == 0 {
|
|
||||||
return fmt.Errorf("Missing agent type")
|
|
||||||
}
|
|
||||||
|
|
||||||
if len(config.ProxyType.String()) == 0 {
|
if len(config.ProxyType.String()) == 0 {
|
||||||
return fmt.Errorf("Missing proxy type")
|
return fmt.Errorf("Missing proxy type")
|
||||||
}
|
}
|
||||||
|
@ -33,7 +33,6 @@ func TestNewFactory(t *testing.T) {
|
|||||||
|
|
||||||
config.VMConfig = vc.VMConfig{
|
config.VMConfig = vc.VMConfig{
|
||||||
HypervisorType: vc.MockHypervisor,
|
HypervisorType: vc.MockHypervisor,
|
||||||
AgentType: vc.NoopAgentType,
|
|
||||||
ProxyType: vc.NoopProxyType,
|
ProxyType: vc.NoopProxyType,
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -122,7 +121,6 @@ func TestVMConfigValid(t *testing.T) {
|
|||||||
err := f.validateNewVMConfig(config)
|
err := f.validateNewVMConfig(config)
|
||||||
assert.NotNil(err)
|
assert.NotNil(err)
|
||||||
|
|
||||||
config.AgentType = vc.NoopAgentType
|
|
||||||
err = f.validateNewVMConfig(config)
|
err = f.validateNewVMConfig(config)
|
||||||
assert.NotNil(err)
|
assert.NotNil(err)
|
||||||
|
|
||||||
@ -148,11 +146,6 @@ func TestCheckVMConfig(t *testing.T) {
|
|||||||
err = checkVMConfig(config1, config2)
|
err = checkVMConfig(config1, config2)
|
||||||
assert.Nil(err)
|
assert.Nil(err)
|
||||||
|
|
||||||
config1.AgentType = vc.NoopAgentType
|
|
||||||
err = checkVMConfig(config1, config2)
|
|
||||||
assert.Error(err)
|
|
||||||
|
|
||||||
config2.AgentType = vc.NoopAgentType
|
|
||||||
err = checkVMConfig(config1, config2)
|
err = checkVMConfig(config1, config2)
|
||||||
assert.Nil(err)
|
assert.Nil(err)
|
||||||
|
|
||||||
@ -187,7 +180,6 @@ func TestFactoryGetVM(t *testing.T) {
|
|||||||
vmConfig := vc.VMConfig{
|
vmConfig := vc.VMConfig{
|
||||||
HypervisorType: vc.MockHypervisor,
|
HypervisorType: vc.MockHypervisor,
|
||||||
HypervisorConfig: hyperConfig,
|
HypervisorConfig: hyperConfig,
|
||||||
AgentType: vc.NoopAgentType,
|
|
||||||
ProxyType: vc.NoopProxyType,
|
ProxyType: vc.NoopProxyType,
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -335,7 +327,6 @@ func TestDeepCompare(t *testing.T) {
|
|||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
config.VMConfig = vc.VMConfig{
|
config.VMConfig = vc.VMConfig{
|
||||||
HypervisorType: vc.MockHypervisor,
|
HypervisorType: vc.MockHypervisor,
|
||||||
AgentType: vc.NoopAgentType,
|
|
||||||
ProxyType: vc.NoopProxyType,
|
ProxyType: vc.NoopProxyType,
|
||||||
}
|
}
|
||||||
testDir := fs.MockStorageRootPath()
|
testDir := fs.MockStorageRootPath()
|
||||||
|
@ -38,7 +38,6 @@ func TestTemplateFactory(t *testing.T) {
|
|||||||
vmConfig := vc.VMConfig{
|
vmConfig := vc.VMConfig{
|
||||||
HypervisorType: vc.MockHypervisor,
|
HypervisorType: vc.MockHypervisor,
|
||||||
HypervisorConfig: hyperConfig,
|
HypervisorConfig: hyperConfig,
|
||||||
AgentType: vc.NoopAgentType,
|
|
||||||
ProxyType: vc.NoopProxyType,
|
ProxyType: vc.NoopProxyType,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -13,7 +13,7 @@ import (
|
|||||||
|
|
||||||
func TestIOStream(t *testing.T) {
|
func TestIOStream(t *testing.T) {
|
||||||
hConfig := newHypervisorConfig(nil, nil)
|
hConfig := newHypervisorConfig(nil, nil)
|
||||||
s, err := testCreateSandbox(t, testSandboxID, MockHypervisor, hConfig, NoopAgentType, NetworkConfig{}, []ContainerConfig{}, nil)
|
s, err := testCreateSandbox(t, testSandboxID, MockHypervisor, hConfig, NetworkConfig{}, []ContainerConfig{}, nil)
|
||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
defer cleanUp()
|
defer cleanUp()
|
||||||
|
|
||||||
|
@ -131,6 +131,11 @@ const (
|
|||||||
grpcGetMetricsRequest = "grpc.GetMetricsRequest"
|
grpcGetMetricsRequest = "grpc.GetMetricsRequest"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// newKataAgent returns an agent from an agent type.
|
||||||
|
func newKataAgent() agent {
|
||||||
|
return &kataAgent{}
|
||||||
|
}
|
||||||
|
|
||||||
// The function is declared this way for mocking in unit tests
|
// The function is declared this way for mocking in unit tests
|
||||||
var kataHostSharedDir = func() string {
|
var kataHostSharedDir = func() string {
|
||||||
if rootless.IsRootless() {
|
if rootless.IsRootless() {
|
||||||
@ -316,21 +321,16 @@ func (k *kataAgent) handleTraceSettings(config KataAgentConfig) bool {
|
|||||||
return disableVMShutdown
|
return disableVMShutdown
|
||||||
}
|
}
|
||||||
|
|
||||||
func (k *kataAgent) init(ctx context.Context, sandbox *Sandbox, config interface{}) (disableVMShutdown bool, err error) {
|
func (k *kataAgent) init(ctx context.Context, sandbox *Sandbox, config KataAgentConfig) (disableVMShutdown bool, err error) {
|
||||||
// save
|
// save
|
||||||
k.ctx = sandbox.ctx
|
k.ctx = sandbox.ctx
|
||||||
|
|
||||||
span, _ := k.trace("init")
|
span, _ := k.trace("init")
|
||||||
defer span.Finish()
|
defer span.Finish()
|
||||||
|
|
||||||
switch c := config.(type) {
|
disableVMShutdown = k.handleTraceSettings(config)
|
||||||
case KataAgentConfig:
|
k.keepConn = config.LongLiveConn
|
||||||
disableVMShutdown = k.handleTraceSettings(c)
|
k.kmodules = config.KernelModules
|
||||||
k.keepConn = c.LongLiveConn
|
|
||||||
k.kmodules = c.KernelModules
|
|
||||||
default:
|
|
||||||
return false, vcTypes.ErrInvalidConfigType
|
|
||||||
}
|
|
||||||
|
|
||||||
k.proxy, err = newProxy(sandbox.config.ProxyType)
|
k.proxy, err = newProxy(sandbox.config.ProxyType)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -17,230 +17,234 @@ import (
|
|||||||
"golang.org/x/net/context"
|
"golang.org/x/net/context"
|
||||||
)
|
)
|
||||||
|
|
||||||
// noopAgent a.k.a. NO-OP Agent is an empty Agent implementation, for testing and
|
// mockAgent is an empty Agent implementation, for testing and
|
||||||
// mocking purposes.
|
// mocking purposes.
|
||||||
type noopAgent struct {
|
type mockAgent struct {
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewMockAgent() agent {
|
||||||
|
return &mockAgent{}
|
||||||
}
|
}
|
||||||
|
|
||||||
//start the proxy to watch the vm console. It does nothing.
|
//start the proxy to watch the vm console. It does nothing.
|
||||||
func (n *noopAgent) startProxy(sandbox *Sandbox) error {
|
func (n *mockAgent) startProxy(sandbox *Sandbox) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// init initializes the Noop agent, i.e. it does nothing.
|
// init initializes the Noop agent, i.e. it does nothing.
|
||||||
func (n *noopAgent) init(ctx context.Context, sandbox *Sandbox, config interface{}) (bool, error) {
|
func (n *mockAgent) init(ctx context.Context, sandbox *Sandbox, config KataAgentConfig) (bool, error) {
|
||||||
return false, nil
|
return false, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (n *noopAgent) longLiveConn() bool {
|
func (n *mockAgent) longLiveConn() bool {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
// createSandbox is the Noop agent sandbox creation implementation. It does nothing.
|
// createSandbox is the Noop agent sandbox creation implementation. It does nothing.
|
||||||
func (n *noopAgent) createSandbox(sandbox *Sandbox) error {
|
func (n *mockAgent) createSandbox(sandbox *Sandbox) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// capabilities returns empty capabilities, i.e no capabilties are supported.
|
// capabilities returns empty capabilities, i.e no capabilties are supported.
|
||||||
func (n *noopAgent) capabilities() types.Capabilities {
|
func (n *mockAgent) capabilities() types.Capabilities {
|
||||||
return types.Capabilities{}
|
return types.Capabilities{}
|
||||||
}
|
}
|
||||||
|
|
||||||
// disconnect is the Noop agent connection closer. It does nothing.
|
// disconnect is the Noop agent connection closer. It does nothing.
|
||||||
func (n *noopAgent) disconnect() error {
|
func (n *mockAgent) disconnect() error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// exec is the Noop agent command execution implementation. It does nothing.
|
// exec is the Noop agent command execution implementation. It does nothing.
|
||||||
func (n *noopAgent) exec(sandbox *Sandbox, c Container, cmd types.Cmd) (*Process, error) {
|
func (n *mockAgent) exec(sandbox *Sandbox, c Container, cmd types.Cmd) (*Process, error) {
|
||||||
return nil, nil
|
return nil, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// startSandbox is the Noop agent Sandbox starting implementation. It does nothing.
|
// startSandbox is the Noop agent Sandbox starting implementation. It does nothing.
|
||||||
func (n *noopAgent) startSandbox(sandbox *Sandbox) error {
|
func (n *mockAgent) startSandbox(sandbox *Sandbox) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// stopSandbox is the Noop agent Sandbox stopping implementation. It does nothing.
|
// stopSandbox is the Noop agent Sandbox stopping implementation. It does nothing.
|
||||||
func (n *noopAgent) stopSandbox(sandbox *Sandbox) error {
|
func (n *mockAgent) stopSandbox(sandbox *Sandbox) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// createContainer is the Noop agent Container creation implementation. It does nothing.
|
// createContainer is the Noop agent Container creation implementation. It does nothing.
|
||||||
func (n *noopAgent) createContainer(sandbox *Sandbox, c *Container) (*Process, error) {
|
func (n *mockAgent) createContainer(sandbox *Sandbox, c *Container) (*Process, error) {
|
||||||
return &Process{}, nil
|
return &Process{}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// startContainer is the Noop agent Container starting implementation. It does nothing.
|
// startContainer is the Noop agent Container starting implementation. It does nothing.
|
||||||
func (n *noopAgent) startContainer(sandbox *Sandbox, c *Container) error {
|
func (n *mockAgent) startContainer(sandbox *Sandbox, c *Container) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// stopContainer is the Noop agent Container stopping implementation. It does nothing.
|
// stopContainer is the Noop agent Container stopping implementation. It does nothing.
|
||||||
func (n *noopAgent) stopContainer(sandbox *Sandbox, c Container) error {
|
func (n *mockAgent) stopContainer(sandbox *Sandbox, c Container) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// signalProcess is the Noop agent Container signaling implementation. It does nothing.
|
// signalProcess is the Noop agent Container signaling implementation. It does nothing.
|
||||||
func (n *noopAgent) signalProcess(c *Container, processID string, signal syscall.Signal, all bool) error {
|
func (n *mockAgent) signalProcess(c *Container, processID string, signal syscall.Signal, all bool) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// processListContainer is the Noop agent Container ps implementation. It does nothing.
|
// processListContainer is the Noop agent Container ps implementation. It does nothing.
|
||||||
func (n *noopAgent) processListContainer(sandbox *Sandbox, c Container, options ProcessListOptions) (ProcessList, error) {
|
func (n *mockAgent) processListContainer(sandbox *Sandbox, c Container, options ProcessListOptions) (ProcessList, error) {
|
||||||
return nil, nil
|
return nil, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// updateContainer is the Noop agent Container update implementation. It does nothing.
|
// updateContainer is the Noop agent Container update implementation. It does nothing.
|
||||||
func (n *noopAgent) updateContainer(sandbox *Sandbox, c Container, resources specs.LinuxResources) error {
|
func (n *mockAgent) updateContainer(sandbox *Sandbox, c Container, resources specs.LinuxResources) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// memHotplugByProbe is the Noop agent notify meomory hotplug event via probe interface implementation. It does nothing.
|
// memHotplugByProbe is the Noop agent notify meomory hotplug event via probe interface implementation. It does nothing.
|
||||||
func (n *noopAgent) memHotplugByProbe(addr uint64, sizeMB uint32, memorySectionSizeMB uint32) error {
|
func (n *mockAgent) memHotplugByProbe(addr uint64, sizeMB uint32, memorySectionSizeMB uint32) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// onlineCPUMem is the Noop agent Container online CPU and Memory implementation. It does nothing.
|
// onlineCPUMem is the Noop agent Container online CPU and Memory implementation. It does nothing.
|
||||||
func (n *noopAgent) onlineCPUMem(cpus uint32, cpuOnly bool) error {
|
func (n *mockAgent) onlineCPUMem(cpus uint32, cpuOnly bool) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// updateInterface is the Noop agent Interface update implementation. It does nothing.
|
// updateInterface is the Noop agent Interface update implementation. It does nothing.
|
||||||
func (n *noopAgent) updateInterface(inf *vcTypes.Interface) (*vcTypes.Interface, error) {
|
func (n *mockAgent) updateInterface(inf *vcTypes.Interface) (*vcTypes.Interface, error) {
|
||||||
return nil, nil
|
return nil, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// listInterfaces is the Noop agent Interfaces list implementation. It does nothing.
|
// listInterfaces is the Noop agent Interfaces list implementation. It does nothing.
|
||||||
func (n *noopAgent) listInterfaces() ([]*vcTypes.Interface, error) {
|
func (n *mockAgent) listInterfaces() ([]*vcTypes.Interface, error) {
|
||||||
return nil, nil
|
return nil, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// updateRoutes is the Noop agent Routes update implementation. It does nothing.
|
// updateRoutes is the Noop agent Routes update implementation. It does nothing.
|
||||||
func (n *noopAgent) updateRoutes(routes []*vcTypes.Route) ([]*vcTypes.Route, error) {
|
func (n *mockAgent) updateRoutes(routes []*vcTypes.Route) ([]*vcTypes.Route, error) {
|
||||||
return nil, nil
|
return nil, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// listRoutes is the Noop agent Routes list implementation. It does nothing.
|
// listRoutes is the Noop agent Routes list implementation. It does nothing.
|
||||||
func (n *noopAgent) listRoutes() ([]*vcTypes.Route, error) {
|
func (n *mockAgent) listRoutes() ([]*vcTypes.Route, error) {
|
||||||
return nil, nil
|
return nil, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// check is the Noop agent health checker. It does nothing.
|
// check is the Noop agent health checker. It does nothing.
|
||||||
func (n *noopAgent) check() error {
|
func (n *mockAgent) check() error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// statsContainer is the Noop agent Container stats implementation. It does nothing.
|
// statsContainer is the Noop agent Container stats implementation. It does nothing.
|
||||||
func (n *noopAgent) statsContainer(sandbox *Sandbox, c Container) (*ContainerStats, error) {
|
func (n *mockAgent) statsContainer(sandbox *Sandbox, c Container) (*ContainerStats, error) {
|
||||||
return &ContainerStats{}, nil
|
return &ContainerStats{}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// waitProcess is the Noop agent process waiter. It does nothing.
|
// waitProcess is the Noop agent process waiter. It does nothing.
|
||||||
func (n *noopAgent) waitProcess(c *Container, processID string) (int32, error) {
|
func (n *mockAgent) waitProcess(c *Container, processID string) (int32, error) {
|
||||||
return 0, nil
|
return 0, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// winsizeProcess is the Noop agent process tty resizer. It does nothing.
|
// winsizeProcess is the Noop agent process tty resizer. It does nothing.
|
||||||
func (n *noopAgent) winsizeProcess(c *Container, processID string, height, width uint32) error {
|
func (n *mockAgent) winsizeProcess(c *Container, processID string, height, width uint32) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// writeProcessStdin is the Noop agent process stdin writer. It does nothing.
|
// writeProcessStdin is the Noop agent process stdin writer. It does nothing.
|
||||||
func (n *noopAgent) writeProcessStdin(c *Container, ProcessID string, data []byte) (int, error) {
|
func (n *mockAgent) writeProcessStdin(c *Container, ProcessID string, data []byte) (int, error) {
|
||||||
return 0, nil
|
return 0, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// closeProcessStdin is the Noop agent process stdin closer. It does nothing.
|
// closeProcessStdin is the Noop agent process stdin closer. It does nothing.
|
||||||
func (n *noopAgent) closeProcessStdin(c *Container, ProcessID string) error {
|
func (n *mockAgent) closeProcessStdin(c *Container, ProcessID string) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// readProcessStdout is the Noop agent process stdout reader. It does nothing.
|
// readProcessStdout is the Noop agent process stdout reader. It does nothing.
|
||||||
func (n *noopAgent) readProcessStdout(c *Container, processID string, data []byte) (int, error) {
|
func (n *mockAgent) readProcessStdout(c *Container, processID string, data []byte) (int, error) {
|
||||||
return 0, nil
|
return 0, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// readProcessStderr is the Noop agent process stderr reader. It does nothing.
|
// readProcessStderr is the Noop agent process stderr reader. It does nothing.
|
||||||
func (n *noopAgent) readProcessStderr(c *Container, processID string, data []byte) (int, error) {
|
func (n *mockAgent) readProcessStderr(c *Container, processID string, data []byte) (int, error) {
|
||||||
return 0, nil
|
return 0, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// pauseContainer is the Noop agent Container pause implementation. It does nothing.
|
// pauseContainer is the Noop agent Container pause implementation. It does nothing.
|
||||||
func (n *noopAgent) pauseContainer(sandbox *Sandbox, c Container) error {
|
func (n *mockAgent) pauseContainer(sandbox *Sandbox, c Container) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// resumeContainer is the Noop agent Container resume implementation. It does nothing.
|
// resumeContainer is the Noop agent Container resume implementation. It does nothing.
|
||||||
func (n *noopAgent) resumeContainer(sandbox *Sandbox, c Container) error {
|
func (n *mockAgent) resumeContainer(sandbox *Sandbox, c Container) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// configHypervisor is the Noop agent hypervisor configuration implementation. It does nothing.
|
// configHypervisor is the Noop agent hypervisor configuration implementation. It does nothing.
|
||||||
func (n *noopAgent) configure(h hypervisor, id, sharePath string, builtin bool, config interface{}) error {
|
func (n *mockAgent) configure(h hypervisor, id, sharePath string, builtin bool, config interface{}) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (n *noopAgent) configureFromGrpc(h hypervisor, id string, builtin bool, config interface{}) error {
|
func (n *mockAgent) configureFromGrpc(h hypervisor, id string, builtin bool, config interface{}) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// reseedRNG is the Noop agent RND reseeder. It does nothing.
|
// reseedRNG is the Noop agent RND reseeder. It does nothing.
|
||||||
func (n *noopAgent) reseedRNG(data []byte) error {
|
func (n *mockAgent) reseedRNG(data []byte) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// reuseAgent is the Noop agent reuser. It does nothing.
|
// reuseAgent is the Noop agent reuser. It does nothing.
|
||||||
func (n *noopAgent) reuseAgent(agent agent) error {
|
func (n *mockAgent) reuseAgent(agent agent) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// getAgentURL is the Noop agent url getter. It returns nothing.
|
// getAgentURL is the Noop agent url getter. It returns nothing.
|
||||||
func (n *noopAgent) getAgentURL() (string, error) {
|
func (n *mockAgent) getAgentURL() (string, error) {
|
||||||
return "", nil
|
return "", nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// setProxy is the Noop agent proxy setter. It does nothing.
|
// setProxy is the Noop agent proxy setter. It does nothing.
|
||||||
func (n *noopAgent) setProxy(sandbox *Sandbox, proxy proxy, pid int, url string) error {
|
func (n *mockAgent) setProxy(sandbox *Sandbox, proxy proxy, pid int, url string) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (n *noopAgent) setProxyFromGrpc(proxy proxy, pid int, url string) {
|
func (n *mockAgent) setProxyFromGrpc(proxy proxy, pid int, url string) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// getGuestDetails is the Noop agent GuestDetails queryer. It does nothing.
|
// getGuestDetails is the Noop agent GuestDetails queryer. It does nothing.
|
||||||
func (n *noopAgent) getGuestDetails(*grpc.GuestDetailsRequest) (*grpc.GuestDetailsResponse, error) {
|
func (n *mockAgent) getGuestDetails(*grpc.GuestDetailsRequest) (*grpc.GuestDetailsResponse, error) {
|
||||||
return nil, nil
|
return nil, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// setGuestDateTime is the Noop agent guest time setter. It does nothing.
|
// setGuestDateTime is the Noop agent guest time setter. It does nothing.
|
||||||
func (n *noopAgent) setGuestDateTime(time.Time) error {
|
func (n *mockAgent) setGuestDateTime(time.Time) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// copyFile is the Noop agent copy file. It does nothing.
|
// copyFile is the Noop agent copy file. It does nothing.
|
||||||
func (n *noopAgent) copyFile(src, dst string) error {
|
func (n *mockAgent) copyFile(src, dst string) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (n *noopAgent) markDead() {
|
func (n *mockAgent) markDead() {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (n *noopAgent) cleanup(s *Sandbox) {
|
func (n *mockAgent) cleanup(s *Sandbox) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// save is the Noop agent state saver. It does nothing.
|
// save is the Noop agent state saver. It does nothing.
|
||||||
func (n *noopAgent) save() (s persistapi.AgentState) {
|
func (n *mockAgent) save() (s persistapi.AgentState) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// load is the Noop agent state loader. It does nothing.
|
// load is the Noop agent state loader. It does nothing.
|
||||||
func (n *noopAgent) load(s persistapi.AgentState) {}
|
func (n *mockAgent) load(s persistapi.AgentState) {}
|
||||||
|
|
||||||
func (n *noopAgent) getOOMEvent() (string, error) {
|
func (n *mockAgent) getOOMEvent() (string, error) {
|
||||||
return "", nil
|
return "", nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (k *noopAgent) getAgentMetrics(req *grpc.GetMetricsRequest) (*grpc.Metrics, error) {
|
func (k *mockAgent) getAgentMetrics(req *grpc.GetMetricsRequest) (*grpc.Metrics, error) {
|
||||||
return nil, nil
|
return nil, nil
|
||||||
}
|
}
|
@ -19,7 +19,7 @@ func TestMonitorSuccess(t *testing.T) {
|
|||||||
assert := assert.New(t)
|
assert := assert.New(t)
|
||||||
|
|
||||||
// create a sandbox
|
// create a sandbox
|
||||||
s, err := testCreateSandbox(t, testSandboxID, MockHypervisor, hConfig, NoopAgentType, NetworkConfig{}, []ContainerConfig{contConfig}, nil)
|
s, err := testCreateSandbox(t, testSandboxID, MockHypervisor, hConfig, NetworkConfig{}, []ContainerConfig{contConfig}, nil)
|
||||||
assert.NoError(err)
|
assert.NoError(err)
|
||||||
defer cleanUp()
|
defer cleanUp()
|
||||||
|
|
||||||
@ -43,7 +43,7 @@ func TestMonitorClosedChannel(t *testing.T) {
|
|||||||
assert := assert.New(t)
|
assert := assert.New(t)
|
||||||
|
|
||||||
// create a sandbox
|
// create a sandbox
|
||||||
s, err := testCreateSandbox(t, testSandboxID, MockHypervisor, hConfig, NoopAgentType, NetworkConfig{}, []ContainerConfig{contConfig}, nil)
|
s, err := testCreateSandbox(t, testSandboxID, MockHypervisor, hConfig, NetworkConfig{}, []ContainerConfig{contConfig}, nil)
|
||||||
assert.NoError(err)
|
assert.NoError(err)
|
||||||
defer cleanUp()
|
defer cleanUp()
|
||||||
|
|
||||||
|
@ -1,248 +0,0 @@
|
|||||||
//
|
|
||||||
// Copyright (c) 2016 Intel Corporation
|
|
||||||
//
|
|
||||||
// SPDX-License-Identifier: Apache-2.0
|
|
||||||
//
|
|
||||||
|
|
||||||
package virtcontainers
|
|
||||||
|
|
||||||
import (
|
|
||||||
"context"
|
|
||||||
"testing"
|
|
||||||
|
|
||||||
"github.com/kata-containers/kata-containers/src/runtime/virtcontainers/types"
|
|
||||||
"github.com/stretchr/testify/assert"
|
|
||||||
)
|
|
||||||
|
|
||||||
func testCreateNoopContainer() (*Sandbox, *Container, error) {
|
|
||||||
defer cleanUp()
|
|
||||||
|
|
||||||
contID := "100"
|
|
||||||
config := newTestSandboxConfigNoop()
|
|
||||||
|
|
||||||
ctx := context.Background()
|
|
||||||
p, err := CreateSandbox(ctx, config, nil)
|
|
||||||
if err != nil {
|
|
||||||
return nil, nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
contConfig := newTestContainerConfigNoop(contID)
|
|
||||||
|
|
||||||
p, c, err := CreateContainer(ctx, p.ID(), contConfig)
|
|
||||||
if err != nil {
|
|
||||||
return nil, nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
return p.(*Sandbox), c.(*Container), nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestNoopAgentInit(t *testing.T) {
|
|
||||||
n := &noopAgent{}
|
|
||||||
sandbox := &Sandbox{}
|
|
||||||
assert := assert.New(t)
|
|
||||||
|
|
||||||
disableVMShutdown, err := n.init(context.Background(), sandbox, nil)
|
|
||||||
assert.NoError(err)
|
|
||||||
assert.False(disableVMShutdown)
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestNoopAgentExec(t *testing.T) {
|
|
||||||
n := &noopAgent{}
|
|
||||||
cmd := types.Cmd{}
|
|
||||||
assert := assert.New(t)
|
|
||||||
|
|
||||||
sandbox, container, err := testCreateNoopContainer()
|
|
||||||
assert.NoError(err)
|
|
||||||
defer cleanUp()
|
|
||||||
|
|
||||||
_, err = n.exec(sandbox, *container, cmd)
|
|
||||||
assert.NoError(err)
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestNoopAgentStartSandbox(t *testing.T) {
|
|
||||||
n := &noopAgent{}
|
|
||||||
sandbox := &Sandbox{}
|
|
||||||
assert := assert.New(t)
|
|
||||||
|
|
||||||
err := n.startSandbox(sandbox)
|
|
||||||
assert.NoError(err)
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestNoopAgentStopSandbox(t *testing.T) {
|
|
||||||
n := &noopAgent{}
|
|
||||||
sandbox := &Sandbox{}
|
|
||||||
assert := assert.New(t)
|
|
||||||
|
|
||||||
err := n.stopSandbox(sandbox)
|
|
||||||
assert.NoError(err)
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestNoopAgentCreateContainer(t *testing.T) {
|
|
||||||
n := &noopAgent{}
|
|
||||||
assert := assert.New(t)
|
|
||||||
sandbox, container, err := testCreateNoopContainer()
|
|
||||||
assert.NoError(err)
|
|
||||||
defer cleanUp()
|
|
||||||
|
|
||||||
err = n.startSandbox(sandbox)
|
|
||||||
assert.NoError(err)
|
|
||||||
|
|
||||||
_, err = n.createContainer(sandbox, container)
|
|
||||||
assert.NoError(err)
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestNoopAgentStartContainer(t *testing.T) {
|
|
||||||
n := &noopAgent{}
|
|
||||||
assert := assert.New(t)
|
|
||||||
|
|
||||||
sandbox, container, err := testCreateNoopContainer()
|
|
||||||
assert.NoError(err)
|
|
||||||
defer cleanUp()
|
|
||||||
|
|
||||||
err = n.startContainer(sandbox, container)
|
|
||||||
assert.NoError(err)
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestNoopAgentStopContainer(t *testing.T) {
|
|
||||||
n := &noopAgent{}
|
|
||||||
assert := assert.New(t)
|
|
||||||
sandbox, container, err := testCreateNoopContainer()
|
|
||||||
assert.NoError(err)
|
|
||||||
defer cleanUp()
|
|
||||||
|
|
||||||
err = n.stopContainer(sandbox, *container)
|
|
||||||
assert.NoError(err)
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestNoopAgentStatsContainer(t *testing.T) {
|
|
||||||
n := &noopAgent{}
|
|
||||||
assert := assert.New(t)
|
|
||||||
sandbox, container, err := testCreateNoopContainer()
|
|
||||||
assert.NoError(err)
|
|
||||||
|
|
||||||
defer cleanUp()
|
|
||||||
_, err = n.statsContainer(sandbox, *container)
|
|
||||||
assert.NoError(err)
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestNoopAgentPauseContainer(t *testing.T) {
|
|
||||||
n := &noopAgent{}
|
|
||||||
assert := assert.New(t)
|
|
||||||
sandbox, container, err := testCreateNoopContainer()
|
|
||||||
assert.NoError(err)
|
|
||||||
|
|
||||||
defer cleanUp()
|
|
||||||
err = n.pauseContainer(sandbox, *container)
|
|
||||||
assert.NoError(err)
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestNoopAgentResumeContainer(t *testing.T) {
|
|
||||||
n := &noopAgent{}
|
|
||||||
assert := assert.New(t)
|
|
||||||
sandbox, container, err := testCreateNoopContainer()
|
|
||||||
assert.NoError(err)
|
|
||||||
defer cleanUp()
|
|
||||||
err = n.resumeContainer(sandbox, *container)
|
|
||||||
assert.NoError(err)
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestNoopAgentConfigure(t *testing.T) {
|
|
||||||
n := &noopAgent{}
|
|
||||||
h := &mockHypervisor{}
|
|
||||||
id := "foobar"
|
|
||||||
sharePath := "foobarDir"
|
|
||||||
assert := assert.New(t)
|
|
||||||
err := n.configure(h, id, sharePath, true, nil)
|
|
||||||
assert.NoError(err)
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestNoopAgentStartProxy(t *testing.T) {
|
|
||||||
assert := assert.New(t)
|
|
||||||
n := &noopAgent{}
|
|
||||||
sandbox, _, err := testCreateNoopContainer()
|
|
||||||
|
|
||||||
assert.NoError(err)
|
|
||||||
defer cleanUp()
|
|
||||||
err = n.startProxy(sandbox)
|
|
||||||
assert.NoError(err)
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestNoopAgentProcessListContainer(t *testing.T) {
|
|
||||||
assert := assert.New(t)
|
|
||||||
n := &noopAgent{}
|
|
||||||
sandbox, container, err := testCreateNoopContainer()
|
|
||||||
assert.NoError(err)
|
|
||||||
defer cleanUp()
|
|
||||||
_, err = n.processListContainer(sandbox, *container, ProcessListOptions{})
|
|
||||||
assert.NoError(err)
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestNoopAgentReseedRNG(t *testing.T) {
|
|
||||||
assert := assert.New(t)
|
|
||||||
n := &noopAgent{}
|
|
||||||
err := n.reseedRNG([]byte{})
|
|
||||||
assert.NoError(err)
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestNoopAgentUpdateInterface(t *testing.T) {
|
|
||||||
assert := assert.New(t)
|
|
||||||
n := &noopAgent{}
|
|
||||||
_, err := n.updateInterface(nil)
|
|
||||||
assert.NoError(err)
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestNoopAgentListInterfaces(t *testing.T) {
|
|
||||||
assert := assert.New(t)
|
|
||||||
n := &noopAgent{}
|
|
||||||
_, err := n.listInterfaces()
|
|
||||||
assert.NoError(err)
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestNoopAgentUpdateRoutes(t *testing.T) {
|
|
||||||
assert := assert.New(t)
|
|
||||||
n := &noopAgent{}
|
|
||||||
_, err := n.updateRoutes(nil)
|
|
||||||
assert.NoError(err)
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestNoopAgentListRoutes(t *testing.T) {
|
|
||||||
n := &noopAgent{}
|
|
||||||
assert := assert.New(t)
|
|
||||||
_, err := n.listRoutes()
|
|
||||||
assert.NoError(err)
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestNoopAgentRSetProxy(t *testing.T) {
|
|
||||||
n := &noopAgent{}
|
|
||||||
p := &noopProxy{}
|
|
||||||
s := &Sandbox{}
|
|
||||||
assert := assert.New(t)
|
|
||||||
err := n.setProxy(s, p, 0, "")
|
|
||||||
assert.NoError(err)
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestNoopGetAgentUrl(t *testing.T) {
|
|
||||||
assert := assert.New(t)
|
|
||||||
n := &noopAgent{}
|
|
||||||
|
|
||||||
url, err := n.getAgentURL()
|
|
||||||
assert.Nil(err)
|
|
||||||
assert.Empty(url)
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestNoopCopyFile(t *testing.T) {
|
|
||||||
assert := assert.New(t)
|
|
||||||
n := &noopAgent{}
|
|
||||||
|
|
||||||
err := n.copyFile("", "")
|
|
||||||
assert.Nil(err)
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestNoopGetOOMEvent(t *testing.T) {
|
|
||||||
assert := assert.New(t)
|
|
||||||
n := &noopAgent{}
|
|
||||||
|
|
||||||
containerID, err := n.getOOMEvent()
|
|
||||||
assert.Nil(err)
|
|
||||||
assert.Empty(containerID)
|
|
||||||
}
|
|
@ -13,7 +13,6 @@ import (
|
|||||||
"github.com/kata-containers/kata-containers/src/runtime/virtcontainers/persist"
|
"github.com/kata-containers/kata-containers/src/runtime/virtcontainers/persist"
|
||||||
persistapi "github.com/kata-containers/kata-containers/src/runtime/virtcontainers/persist/api"
|
persistapi "github.com/kata-containers/kata-containers/src/runtime/virtcontainers/persist/api"
|
||||||
"github.com/kata-containers/kata-containers/src/runtime/virtcontainers/types"
|
"github.com/kata-containers/kata-containers/src/runtime/virtcontainers/types"
|
||||||
"github.com/mitchellh/mapstructure"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
@ -177,7 +176,6 @@ func (s *Sandbox) dumpConfig(ss *persistapi.SandboxState) {
|
|||||||
sconfig := s.config
|
sconfig := s.config
|
||||||
ss.Config = persistapi.SandboxConfig{
|
ss.Config = persistapi.SandboxConfig{
|
||||||
HypervisorType: string(sconfig.HypervisorType),
|
HypervisorType: string(sconfig.HypervisorType),
|
||||||
AgentType: string(sconfig.AgentType),
|
|
||||||
ProxyType: string(sconfig.ProxyType),
|
ProxyType: string(sconfig.ProxyType),
|
||||||
ProxyConfig: persistapi.ProxyConfig{
|
ProxyConfig: persistapi.ProxyConfig{
|
||||||
Path: sconfig.ProxyConfig.Path,
|
Path: sconfig.ProxyConfig.Path,
|
||||||
@ -258,17 +256,9 @@ func (s *Sandbox) dumpConfig(ss *persistapi.SandboxState) {
|
|||||||
TxRateLimiterMaxRate: sconfig.HypervisorConfig.TxRateLimiterMaxRate,
|
TxRateLimiterMaxRate: sconfig.HypervisorConfig.TxRateLimiterMaxRate,
|
||||||
}
|
}
|
||||||
|
|
||||||
if sconfig.AgentType == "kata" {
|
ss.Config.KataAgentConfig = &persistapi.KataAgentConfig{
|
||||||
var sagent KataAgentConfig
|
LongLiveConn: sconfig.AgentConfig.LongLiveConn,
|
||||||
err := mapstructure.Decode(sconfig.AgentConfig, &sagent)
|
UseVSock: sconfig.AgentConfig.UseVSock,
|
||||||
if err != nil {
|
|
||||||
s.Logger().WithError(err).Error("internal error: KataAgentConfig failed to decode")
|
|
||||||
} else {
|
|
||||||
ss.Config.KataAgentConfig = &persistapi.KataAgentConfig{
|
|
||||||
LongLiveConn: sagent.LongLiveConn,
|
|
||||||
UseVSock: sagent.UseVSock,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, contConf := range sconfig.Containers {
|
for _, contConf := range sconfig.Containers {
|
||||||
@ -454,7 +444,6 @@ func loadSandboxConfig(id string) (*SandboxConfig, error) {
|
|||||||
sconfig := &SandboxConfig{
|
sconfig := &SandboxConfig{
|
||||||
ID: id,
|
ID: id,
|
||||||
HypervisorType: HypervisorType(savedConf.HypervisorType),
|
HypervisorType: HypervisorType(savedConf.HypervisorType),
|
||||||
AgentType: AgentType(savedConf.AgentType),
|
|
||||||
ProxyType: ProxyType(savedConf.ProxyType),
|
ProxyType: ProxyType(savedConf.ProxyType),
|
||||||
ProxyConfig: ProxyConfig{
|
ProxyConfig: ProxyConfig{
|
||||||
Path: savedConf.ProxyConfig.Path,
|
Path: savedConf.ProxyConfig.Path,
|
||||||
@ -536,11 +525,9 @@ func loadSandboxConfig(id string) (*SandboxConfig, error) {
|
|||||||
TxRateLimiterMaxRate: hconf.TxRateLimiterMaxRate,
|
TxRateLimiterMaxRate: hconf.TxRateLimiterMaxRate,
|
||||||
}
|
}
|
||||||
|
|
||||||
if savedConf.AgentType == "kata" {
|
sconfig.AgentConfig = KataAgentConfig{
|
||||||
sconfig.AgentConfig = KataAgentConfig{
|
LongLiveConn: savedConf.KataAgentConfig.LongLiveConn,
|
||||||
LongLiveConn: savedConf.KataAgentConfig.LongLiveConn,
|
UseVSock: savedConf.KataAgentConfig.UseVSock,
|
||||||
UseVSock: savedConf.KataAgentConfig.UseVSock,
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, contConf := range savedConf.ContainerConfigs {
|
for _, contConf := range savedConf.ContainerConfigs {
|
||||||
|
@ -234,7 +234,6 @@ type SandboxConfig struct {
|
|||||||
HypervisorConfig HypervisorConfig
|
HypervisorConfig HypervisorConfig
|
||||||
|
|
||||||
// only one agent config can be non-nil according to agent type
|
// only one agent config can be non-nil according to agent type
|
||||||
AgentType string
|
|
||||||
KataAgentConfig *KataAgentConfig `json:",omitempty"`
|
KataAgentConfig *KataAgentConfig `json:",omitempty"`
|
||||||
|
|
||||||
ProxyType string
|
ProxyType string
|
||||||
|
@ -96,8 +96,7 @@ type RuntimeConfig struct {
|
|||||||
|
|
||||||
NetmonConfig vc.NetmonConfig
|
NetmonConfig vc.NetmonConfig
|
||||||
|
|
||||||
AgentType vc.AgentType
|
AgentConfig vc.KataAgentConfig
|
||||||
AgentConfig interface{}
|
|
||||||
|
|
||||||
ProxyType vc.ProxyType
|
ProxyType vc.ProxyType
|
||||||
ProxyConfig vc.ProxyConfig
|
ProxyConfig vc.ProxyConfig
|
||||||
@ -784,10 +783,7 @@ func addRuntimeConfigOverrides(ocispec specs.Spec, sbConfig *vc.SandboxConfig) e
|
|||||||
}
|
}
|
||||||
|
|
||||||
func addAgentConfigOverrides(ocispec specs.Spec, config *vc.SandboxConfig) error {
|
func addAgentConfigOverrides(ocispec specs.Spec, config *vc.SandboxConfig) error {
|
||||||
c, ok := config.AgentConfig.(vc.KataAgentConfig)
|
c := config.AgentConfig
|
||||||
if !ok {
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
if value, ok := ocispec.Annotations[vcAnnotations.KernelModules]; ok {
|
if value, ok := ocispec.Annotations[vcAnnotations.KernelModules]; ok {
|
||||||
modules := strings.Split(value, KernelModulesSeparator)
|
modules := strings.Split(value, KernelModulesSeparator)
|
||||||
@ -850,7 +846,6 @@ func SandboxConfig(ocispec specs.Spec, runtime RuntimeConfig, bundlePath, cid, c
|
|||||||
HypervisorType: runtime.HypervisorType,
|
HypervisorType: runtime.HypervisorType,
|
||||||
HypervisorConfig: runtime.HypervisorConfig,
|
HypervisorConfig: runtime.HypervisorConfig,
|
||||||
|
|
||||||
AgentType: runtime.AgentType,
|
|
||||||
AgentConfig: runtime.AgentConfig,
|
AgentConfig: runtime.AgentConfig,
|
||||||
|
|
||||||
ProxyType: runtime.ProxyType,
|
ProxyType: runtime.ProxyType,
|
||||||
|
@ -71,7 +71,6 @@ func TestMinimalSandboxConfig(t *testing.T) {
|
|||||||
|
|
||||||
runtimeConfig := RuntimeConfig{
|
runtimeConfig := RuntimeConfig{
|
||||||
HypervisorType: vc.QemuHypervisor,
|
HypervisorType: vc.QemuHypervisor,
|
||||||
AgentType: vc.KataContainersAgent,
|
|
||||||
ProxyType: vc.KataProxyType,
|
ProxyType: vc.KataProxyType,
|
||||||
Console: consolePath,
|
Console: consolePath,
|
||||||
}
|
}
|
||||||
@ -170,7 +169,6 @@ func TestMinimalSandboxConfig(t *testing.T) {
|
|||||||
Hostname: "testHostname",
|
Hostname: "testHostname",
|
||||||
|
|
||||||
HypervisorType: vc.QemuHypervisor,
|
HypervisorType: vc.QemuHypervisor,
|
||||||
AgentType: vc.KataContainersAgent,
|
|
||||||
ProxyType: vc.KataProxyType,
|
ProxyType: vc.KataProxyType,
|
||||||
|
|
||||||
NetworkConfig: expectedNetworkConfig,
|
NetworkConfig: expectedNetworkConfig,
|
||||||
|
@ -663,7 +663,6 @@ func TestVCMockSetVMFactory(t *testing.T) {
|
|||||||
}
|
}
|
||||||
vmConfig := vc.VMConfig{
|
vmConfig := vc.VMConfig{
|
||||||
HypervisorType: vc.MockHypervisor,
|
HypervisorType: vc.MockHypervisor,
|
||||||
AgentType: vc.NoopAgentType,
|
|
||||||
HypervisorConfig: hyperConfig,
|
HypervisorConfig: hyperConfig,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -57,7 +57,6 @@ type SandboxStatus struct {
|
|||||||
State types.SandboxState
|
State types.SandboxState
|
||||||
Hypervisor HypervisorType
|
Hypervisor HypervisorType
|
||||||
HypervisorConfig HypervisorConfig
|
HypervisorConfig HypervisorConfig
|
||||||
Agent AgentType
|
|
||||||
ContainersStatus []ContainerStatus
|
ContainersStatus []ContainerStatus
|
||||||
|
|
||||||
// Annotations allow clients to store arbitrary values,
|
// Annotations allow clients to store arbitrary values,
|
||||||
@ -81,8 +80,7 @@ type SandboxConfig struct {
|
|||||||
HypervisorType HypervisorType
|
HypervisorType HypervisorType
|
||||||
HypervisorConfig HypervisorConfig
|
HypervisorConfig HypervisorConfig
|
||||||
|
|
||||||
AgentType AgentType
|
AgentConfig KataAgentConfig
|
||||||
AgentConfig interface{}
|
|
||||||
|
|
||||||
ProxyType ProxyType
|
ProxyType ProxyType
|
||||||
ProxyConfig ProxyConfig
|
ProxyConfig ProxyConfig
|
||||||
@ -326,7 +324,6 @@ func (s *Sandbox) Status() SandboxStatus {
|
|||||||
State: s.state,
|
State: s.state,
|
||||||
Hypervisor: s.config.HypervisorType,
|
Hypervisor: s.config.HypervisorType,
|
||||||
HypervisorConfig: s.config.HypervisorConfig,
|
HypervisorConfig: s.config.HypervisorConfig,
|
||||||
Agent: s.config.AgentType,
|
|
||||||
ContainersStatus: contStatusList,
|
ContainersStatus: contStatusList,
|
||||||
Annotations: s.config.Annotations,
|
Annotations: s.config.Annotations,
|
||||||
}
|
}
|
||||||
@ -507,7 +504,9 @@ func newSandbox(ctx context.Context, sandboxConfig SandboxConfig, factory Factor
|
|||||||
return nil, fmt.Errorf("Invalid sandbox configuration")
|
return nil, fmt.Errorf("Invalid sandbox configuration")
|
||||||
}
|
}
|
||||||
|
|
||||||
agent := newAgent(sandboxConfig.AgentType)
|
// create agent instance
|
||||||
|
newAagentFunc := getNewAgentFunc(ctx)
|
||||||
|
agent := newAagentFunc()
|
||||||
|
|
||||||
hypervisor, err := newHypervisor(sandboxConfig.HypervisorType)
|
hypervisor, err := newHypervisor(sandboxConfig.HypervisorType)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -571,12 +570,7 @@ func newSandbox(ctx context.Context, sandboxConfig SandboxConfig, factory Factor
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
agentConfig, err := newAgentConfig(sandboxConfig.AgentType, sandboxConfig.AgentConfig)
|
if s.disableVMShutdown, err = s.agent.init(ctx, s, sandboxConfig.AgentConfig); err != nil {
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
if s.disableVMShutdown, err = s.agent.init(ctx, s, agentConfig); err != nil {
|
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -972,7 +966,6 @@ func (s *Sandbox) startVM() (err error) {
|
|||||||
vm, err := s.factory.GetVM(ctx, VMConfig{
|
vm, err := s.factory.GetVM(ctx, VMConfig{
|
||||||
HypervisorType: s.config.HypervisorType,
|
HypervisorType: s.config.HypervisorType,
|
||||||
HypervisorConfig: s.config.HypervisorConfig,
|
HypervisorConfig: s.config.HypervisorConfig,
|
||||||
AgentType: s.config.AgentType,
|
|
||||||
AgentConfig: s.config.AgentConfig,
|
AgentConfig: s.config.AgentConfig,
|
||||||
ProxyType: s.config.ProxyType,
|
ProxyType: s.config.ProxyType,
|
||||||
ProxyConfig: s.config.ProxyConfig,
|
ProxyConfig: s.config.ProxyConfig,
|
||||||
|
@ -45,7 +45,7 @@ func newHypervisorConfig(kernelParams []Param, hParams []Param) HypervisorConfig
|
|||||||
}
|
}
|
||||||
|
|
||||||
func testCreateSandbox(t *testing.T, id string,
|
func testCreateSandbox(t *testing.T, id string,
|
||||||
htype HypervisorType, hconfig HypervisorConfig, atype AgentType,
|
htype HypervisorType, hconfig HypervisorConfig,
|
||||||
nconfig NetworkConfig, containers []ContainerConfig,
|
nconfig NetworkConfig, containers []ContainerConfig,
|
||||||
volumes []types.Volume) (*Sandbox, error) {
|
volumes []types.Volume) (*Sandbox, error) {
|
||||||
|
|
||||||
@ -53,14 +53,14 @@ func testCreateSandbox(t *testing.T, id string,
|
|||||||
ID: id,
|
ID: id,
|
||||||
HypervisorType: htype,
|
HypervisorType: htype,
|
||||||
HypervisorConfig: hconfig,
|
HypervisorConfig: hconfig,
|
||||||
AgentType: atype,
|
|
||||||
NetworkConfig: nconfig,
|
NetworkConfig: nconfig,
|
||||||
Volumes: volumes,
|
Volumes: volumes,
|
||||||
Containers: containers,
|
Containers: containers,
|
||||||
Annotations: sandboxAnnotations,
|
Annotations: sandboxAnnotations,
|
||||||
}
|
}
|
||||||
|
|
||||||
sandbox, err := createSandbox(context.Background(), sconfig, nil)
|
ctx := WithNewAgentFunc(context.Background(), newMockAgent)
|
||||||
|
sandbox, err := createSandbox(ctx, sconfig, nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("Could not create sandbox: %s", err)
|
return nil, fmt.Errorf("Could not create sandbox: %s", err)
|
||||||
}
|
}
|
||||||
@ -85,20 +85,20 @@ func testCreateSandbox(t *testing.T, id string,
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestCreateEmptySandbox(t *testing.T) {
|
func TestCreateEmptySandbox(t *testing.T) {
|
||||||
_, err := testCreateSandbox(t, testSandboxID, MockHypervisor, HypervisorConfig{}, NoopAgentType, NetworkConfig{}, nil, nil)
|
_, err := testCreateSandbox(t, testSandboxID, MockHypervisor, HypervisorConfig{}, NetworkConfig{}, nil, nil)
|
||||||
assert.Error(t, err)
|
assert.Error(t, err)
|
||||||
defer cleanUp()
|
defer cleanUp()
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestCreateEmptyHypervisorSandbox(t *testing.T) {
|
func TestCreateEmptyHypervisorSandbox(t *testing.T) {
|
||||||
_, err := testCreateSandbox(t, testSandboxID, QemuHypervisor, HypervisorConfig{}, NoopAgentType, NetworkConfig{}, nil, nil)
|
_, err := testCreateSandbox(t, testSandboxID, QemuHypervisor, HypervisorConfig{}, NetworkConfig{}, nil, nil)
|
||||||
assert.Error(t, err)
|
assert.Error(t, err)
|
||||||
defer cleanUp()
|
defer cleanUp()
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestCreateMockSandbox(t *testing.T) {
|
func TestCreateMockSandbox(t *testing.T) {
|
||||||
hConfig := newHypervisorConfig(nil, nil)
|
hConfig := newHypervisorConfig(nil, nil)
|
||||||
_, err := testCreateSandbox(t, testSandboxID, MockHypervisor, hConfig, NoopAgentType, NetworkConfig{}, nil, nil)
|
_, err := testCreateSandbox(t, testSandboxID, MockHypervisor, hConfig, NetworkConfig{}, nil, nil)
|
||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
defer cleanUp()
|
defer cleanUp()
|
||||||
}
|
}
|
||||||
@ -164,7 +164,7 @@ func TestCalculateSandboxMem(t *testing.T) {
|
|||||||
|
|
||||||
func TestCreateSandboxEmptyID(t *testing.T) {
|
func TestCreateSandboxEmptyID(t *testing.T) {
|
||||||
hConfig := newHypervisorConfig(nil, nil)
|
hConfig := newHypervisorConfig(nil, nil)
|
||||||
_, err := testCreateSandbox(t, "", MockHypervisor, hConfig, NoopAgentType, NetworkConfig{}, nil, nil)
|
_, err := testCreateSandbox(t, "", MockHypervisor, hConfig, NetworkConfig{}, nil, nil)
|
||||||
assert.Error(t, err)
|
assert.Error(t, err)
|
||||||
defer cleanUp()
|
defer cleanUp()
|
||||||
}
|
}
|
||||||
@ -172,7 +172,7 @@ func TestCreateSandboxEmptyID(t *testing.T) {
|
|||||||
func testSandboxStateTransition(t *testing.T, state types.StateString, newState types.StateString) error {
|
func testSandboxStateTransition(t *testing.T, state types.StateString, newState types.StateString) error {
|
||||||
hConfig := newHypervisorConfig(nil, nil)
|
hConfig := newHypervisorConfig(nil, nil)
|
||||||
|
|
||||||
p, err := testCreateSandbox(t, testSandboxID, MockHypervisor, hConfig, NoopAgentType, NetworkConfig{}, nil, nil)
|
p, err := testCreateSandbox(t, testSandboxID, MockHypervisor, hConfig, NetworkConfig{}, nil, nil)
|
||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
defer cleanUp()
|
defer cleanUp()
|
||||||
|
|
||||||
@ -455,7 +455,7 @@ func TestSandboxSetSandboxAndContainerState(t *testing.T) {
|
|||||||
assert := assert.New(t)
|
assert := assert.New(t)
|
||||||
|
|
||||||
// create a sandbox
|
// create a sandbox
|
||||||
p, err := testCreateSandbox(t, testSandboxID, MockHypervisor, hConfig, NoopAgentType, NetworkConfig{}, []ContainerConfig{contConfig}, nil)
|
p, err := testCreateSandbox(t, testSandboxID, MockHypervisor, hConfig, NetworkConfig{}, []ContainerConfig{contConfig}, nil)
|
||||||
assert.NoError(err)
|
assert.NoError(err)
|
||||||
defer cleanUp()
|
defer cleanUp()
|
||||||
|
|
||||||
@ -613,7 +613,7 @@ func TestSandboxGetContainer(t *testing.T) {
|
|||||||
assert.Error(err)
|
assert.Error(err)
|
||||||
|
|
||||||
hConfig := newHypervisorConfig(nil, nil)
|
hConfig := newHypervisorConfig(nil, nil)
|
||||||
p, err := testCreateSandbox(t, testSandboxID, MockHypervisor, hConfig, NoopAgentType, NetworkConfig{}, nil, nil)
|
p, err := testCreateSandbox(t, testSandboxID, MockHypervisor, hConfig, NetworkConfig{}, nil, nil)
|
||||||
assert.NoError(err)
|
assert.NoError(err)
|
||||||
defer cleanUp()
|
defer cleanUp()
|
||||||
|
|
||||||
@ -652,7 +652,7 @@ func TestContainerStateSetFstype(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
hConfig := newHypervisorConfig(nil, nil)
|
hConfig := newHypervisorConfig(nil, nil)
|
||||||
sandbox, err := testCreateSandbox(t, testSandboxID, MockHypervisor, hConfig, NoopAgentType, NetworkConfig{}, containers, nil)
|
sandbox, err := testCreateSandbox(t, testSandboxID, MockHypervisor, hConfig, NetworkConfig{}, containers, nil)
|
||||||
assert.Nil(err)
|
assert.Nil(err)
|
||||||
defer cleanUp()
|
defer cleanUp()
|
||||||
|
|
||||||
@ -948,7 +948,7 @@ func TestRemoveContainerSuccess(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestCreateContainer(t *testing.T) {
|
func TestCreateContainer(t *testing.T) {
|
||||||
s, err := testCreateSandbox(t, testSandboxID, MockHypervisor, newHypervisorConfig(nil, nil), NoopAgentType, NetworkConfig{}, nil, nil)
|
s, err := testCreateSandbox(t, testSandboxID, MockHypervisor, newHypervisorConfig(nil, nil), NetworkConfig{}, nil, nil)
|
||||||
assert.Nil(t, err, "VirtContainers should not allow empty sandboxes")
|
assert.Nil(t, err, "VirtContainers should not allow empty sandboxes")
|
||||||
defer cleanUp()
|
defer cleanUp()
|
||||||
|
|
||||||
@ -965,7 +965,7 @@ func TestCreateContainer(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestDeleteContainer(t *testing.T) {
|
func TestDeleteContainer(t *testing.T) {
|
||||||
s, err := testCreateSandbox(t, testSandboxID, MockHypervisor, newHypervisorConfig(nil, nil), NoopAgentType, NetworkConfig{}, nil, nil)
|
s, err := testCreateSandbox(t, testSandboxID, MockHypervisor, newHypervisorConfig(nil, nil), NetworkConfig{}, nil, nil)
|
||||||
assert.Nil(t, err, "VirtContainers should not allow empty sandboxes")
|
assert.Nil(t, err, "VirtContainers should not allow empty sandboxes")
|
||||||
defer cleanUp()
|
defer cleanUp()
|
||||||
|
|
||||||
@ -982,7 +982,7 @@ func TestDeleteContainer(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestStartContainer(t *testing.T) {
|
func TestStartContainer(t *testing.T) {
|
||||||
s, err := testCreateSandbox(t, testSandboxID, MockHypervisor, newHypervisorConfig(nil, nil), NoopAgentType, NetworkConfig{}, nil, nil)
|
s, err := testCreateSandbox(t, testSandboxID, MockHypervisor, newHypervisorConfig(nil, nil), NetworkConfig{}, nil, nil)
|
||||||
assert.Nil(t, err, "VirtContainers should not allow empty sandboxes")
|
assert.Nil(t, err, "VirtContainers should not allow empty sandboxes")
|
||||||
defer cleanUp()
|
defer cleanUp()
|
||||||
|
|
||||||
@ -1002,7 +1002,7 @@ func TestStartContainer(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestStatusContainer(t *testing.T) {
|
func TestStatusContainer(t *testing.T) {
|
||||||
s, err := testCreateSandbox(t, testSandboxID, MockHypervisor, newHypervisorConfig(nil, nil), NoopAgentType, NetworkConfig{}, nil, nil)
|
s, err := testCreateSandbox(t, testSandboxID, MockHypervisor, newHypervisorConfig(nil, nil), NetworkConfig{}, nil, nil)
|
||||||
assert.Nil(t, err, "VirtContainers should not allow empty sandboxes")
|
assert.Nil(t, err, "VirtContainers should not allow empty sandboxes")
|
||||||
defer cleanUp()
|
defer cleanUp()
|
||||||
|
|
||||||
@ -1022,7 +1022,7 @@ func TestStatusContainer(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestStatusSandbox(t *testing.T) {
|
func TestStatusSandbox(t *testing.T) {
|
||||||
s, err := testCreateSandbox(t, testSandboxID, MockHypervisor, newHypervisorConfig(nil, nil), NoopAgentType, NetworkConfig{}, nil, nil)
|
s, err := testCreateSandbox(t, testSandboxID, MockHypervisor, newHypervisorConfig(nil, nil), NetworkConfig{}, nil, nil)
|
||||||
assert.Nil(t, err, "VirtContainers should not allow empty sandboxes")
|
assert.Nil(t, err, "VirtContainers should not allow empty sandboxes")
|
||||||
defer cleanUp()
|
defer cleanUp()
|
||||||
|
|
||||||
@ -1030,7 +1030,7 @@ func TestStatusSandbox(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestEnterContainer(t *testing.T) {
|
func TestEnterContainer(t *testing.T) {
|
||||||
s, err := testCreateSandbox(t, testSandboxID, MockHypervisor, newHypervisorConfig(nil, nil), NoopAgentType, NetworkConfig{}, nil, nil)
|
s, err := testCreateSandbox(t, testSandboxID, MockHypervisor, newHypervisorConfig(nil, nil), NetworkConfig{}, nil, nil)
|
||||||
assert.Nil(t, err, "VirtContainers should not allow empty sandboxes")
|
assert.Nil(t, err, "VirtContainers should not allow empty sandboxes")
|
||||||
defer cleanUp()
|
defer cleanUp()
|
||||||
|
|
||||||
@ -1055,7 +1055,7 @@ func TestEnterContainer(t *testing.T) {
|
|||||||
|
|
||||||
func TestDeleteStoreWhenCreateContainerFail(t *testing.T) {
|
func TestDeleteStoreWhenCreateContainerFail(t *testing.T) {
|
||||||
hypervisorConfig := newHypervisorConfig(nil, nil)
|
hypervisorConfig := newHypervisorConfig(nil, nil)
|
||||||
s, err := testCreateSandbox(t, testSandboxID, MockHypervisor, hypervisorConfig, NoopAgentType, NetworkConfig{}, nil, nil)
|
s, err := testCreateSandbox(t, testSandboxID, MockHypervisor, hypervisorConfig, NetworkConfig{}, nil, nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
@ -1071,7 +1071,7 @@ func TestDeleteStoreWhenCreateContainerFail(t *testing.T) {
|
|||||||
|
|
||||||
func TestDeleteStoreWhenNewContainerFail(t *testing.T) {
|
func TestDeleteStoreWhenNewContainerFail(t *testing.T) {
|
||||||
hConfig := newHypervisorConfig(nil, nil)
|
hConfig := newHypervisorConfig(nil, nil)
|
||||||
p, err := testCreateSandbox(t, testSandboxID, MockHypervisor, hConfig, NoopAgentType, NetworkConfig{}, nil, nil)
|
p, err := testCreateSandbox(t, testSandboxID, MockHypervisor, hConfig, NetworkConfig{}, nil, nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
@ -1093,7 +1093,7 @@ func TestDeleteStoreWhenNewContainerFail(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestMonitor(t *testing.T) {
|
func TestMonitor(t *testing.T) {
|
||||||
s, err := testCreateSandbox(t, testSandboxID, MockHypervisor, newHypervisorConfig(nil, nil), NoopAgentType, NetworkConfig{}, nil, nil)
|
s, err := testCreateSandbox(t, testSandboxID, MockHypervisor, newHypervisorConfig(nil, nil), NetworkConfig{}, nil, nil)
|
||||||
assert.Nil(t, err, "VirtContainers should not allow empty sandboxes")
|
assert.Nil(t, err, "VirtContainers should not allow empty sandboxes")
|
||||||
defer cleanUp()
|
defer cleanUp()
|
||||||
|
|
||||||
@ -1113,7 +1113,7 @@ func TestMonitor(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestWaitProcess(t *testing.T) {
|
func TestWaitProcess(t *testing.T) {
|
||||||
s, err := testCreateSandbox(t, testSandboxID, MockHypervisor, newHypervisorConfig(nil, nil), NoopAgentType, NetworkConfig{}, nil, nil)
|
s, err := testCreateSandbox(t, testSandboxID, MockHypervisor, newHypervisorConfig(nil, nil), NetworkConfig{}, nil, nil)
|
||||||
assert.Nil(t, err, "VirtContainers should not allow empty sandboxes")
|
assert.Nil(t, err, "VirtContainers should not allow empty sandboxes")
|
||||||
defer cleanUp()
|
defer cleanUp()
|
||||||
|
|
||||||
@ -1143,7 +1143,7 @@ func TestWaitProcess(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestSignalProcess(t *testing.T) {
|
func TestSignalProcess(t *testing.T) {
|
||||||
s, err := testCreateSandbox(t, testSandboxID, MockHypervisor, newHypervisorConfig(nil, nil), NoopAgentType, NetworkConfig{}, nil, nil)
|
s, err := testCreateSandbox(t, testSandboxID, MockHypervisor, newHypervisorConfig(nil, nil), NetworkConfig{}, nil, nil)
|
||||||
assert.Nil(t, err, "VirtContainers should not allow empty sandboxes")
|
assert.Nil(t, err, "VirtContainers should not allow empty sandboxes")
|
||||||
defer cleanUp()
|
defer cleanUp()
|
||||||
|
|
||||||
@ -1173,7 +1173,7 @@ func TestSignalProcess(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestWinsizeProcess(t *testing.T) {
|
func TestWinsizeProcess(t *testing.T) {
|
||||||
s, err := testCreateSandbox(t, testSandboxID, MockHypervisor, newHypervisorConfig(nil, nil), NoopAgentType, NetworkConfig{}, nil, nil)
|
s, err := testCreateSandbox(t, testSandboxID, MockHypervisor, newHypervisorConfig(nil, nil), NetworkConfig{}, nil, nil)
|
||||||
assert.Nil(t, err, "VirtContainers should not allow empty sandboxes")
|
assert.Nil(t, err, "VirtContainers should not allow empty sandboxes")
|
||||||
defer cleanUp()
|
defer cleanUp()
|
||||||
|
|
||||||
@ -1203,7 +1203,7 @@ func TestWinsizeProcess(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestContainerProcessIOStream(t *testing.T) {
|
func TestContainerProcessIOStream(t *testing.T) {
|
||||||
s, err := testCreateSandbox(t, testSandboxID, MockHypervisor, newHypervisorConfig(nil, nil), NoopAgentType, NetworkConfig{}, nil, nil)
|
s, err := testCreateSandbox(t, testSandboxID, MockHypervisor, newHypervisorConfig(nil, nil), NetworkConfig{}, nil, nil)
|
||||||
assert.Nil(t, err, "VirtContainers should not allow empty sandboxes")
|
assert.Nil(t, err, "VirtContainers should not allow empty sandboxes")
|
||||||
defer cleanUp()
|
defer cleanUp()
|
||||||
|
|
||||||
@ -1467,7 +1467,6 @@ func TestSandboxCreationFromConfigRollbackFromCreateSandbox(t *testing.T) {
|
|||||||
ID: testSandboxID,
|
ID: testSandboxID,
|
||||||
HypervisorType: QemuHypervisor,
|
HypervisorType: QemuHypervisor,
|
||||||
HypervisorConfig: hConf,
|
HypervisorConfig: hConf,
|
||||||
AgentType: KataContainersAgent,
|
|
||||||
NetworkConfig: NetworkConfig{},
|
NetworkConfig: NetworkConfig{},
|
||||||
Volumes: nil,
|
Volumes: nil,
|
||||||
Containers: nil,
|
Containers: nil,
|
||||||
@ -1496,7 +1495,6 @@ func TestSandboxUpdateResources(t *testing.T) {
|
|||||||
testSandboxID,
|
testSandboxID,
|
||||||
MockHypervisor,
|
MockHypervisor,
|
||||||
hConfig,
|
hConfig,
|
||||||
NoopAgentType,
|
|
||||||
NetworkConfig{},
|
NetworkConfig{},
|
||||||
[]ContainerConfig{contConfig1, contConfig2},
|
[]ContainerConfig{contConfig1, contConfig2},
|
||||||
nil)
|
nil)
|
||||||
|
@ -8,7 +8,6 @@ package virtcontainers
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"time"
|
"time"
|
||||||
@ -44,8 +43,7 @@ type VMConfig struct {
|
|||||||
HypervisorType HypervisorType
|
HypervisorType HypervisorType
|
||||||
HypervisorConfig HypervisorConfig
|
HypervisorConfig HypervisorConfig
|
||||||
|
|
||||||
AgentType AgentType
|
AgentConfig KataAgentConfig
|
||||||
AgentConfig interface{}
|
|
||||||
|
|
||||||
ProxyType ProxyType
|
ProxyType ProxyType
|
||||||
ProxyConfig ProxyConfig
|
ProxyConfig ProxyConfig
|
||||||
@ -63,12 +61,7 @@ func (c *VMConfig) ToGrpc() (*pb.GrpcVMConfig, error) {
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
aconf, ok := c.AgentConfig.(KataAgentConfig)
|
agentConfig, err := json.Marshal(&c.AgentConfig)
|
||||||
if !ok {
|
|
||||||
return nil, fmt.Errorf("agent type is not supported by VM cache")
|
|
||||||
}
|
|
||||||
|
|
||||||
agentConfig, err := json.Marshal(&aconf)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@ -87,10 +80,6 @@ func GrpcToVMConfig(j *pb.GrpcVMConfig) (*VMConfig, error) {
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
if config.AgentType != KataContainersAgent {
|
|
||||||
return nil, fmt.Errorf("agent type %s is not supported by VM cache", config.AgentType)
|
|
||||||
}
|
|
||||||
|
|
||||||
var kataConfig KataAgentConfig
|
var kataConfig KataAgentConfig
|
||||||
err = json.Unmarshal(j.AgentConfig, &kataConfig)
|
err = json.Unmarshal(j.AgentConfig, &kataConfig)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
@ -176,7 +165,9 @@ func NewVM(ctx context.Context, config VMConfig) (*VM, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 2. setup agent
|
// 2. setup agent
|
||||||
agent := newAgent(config.AgentType)
|
newAagentFunc := getNewAgentFunc(ctx)
|
||||||
|
agent := newAagentFunc()
|
||||||
|
|
||||||
vmSharePath := buildVMSharePath(id, store.RunVMStoragePath())
|
vmSharePath := buildVMSharePath(id, store.RunVMStoragePath())
|
||||||
err = agent.configure(hypervisor, id, vmSharePath, isProxyBuiltIn(config.ProxyType), config.AgentConfig)
|
err = agent.configure(hypervisor, id, vmSharePath, isProxyBuiltIn(config.ProxyType), config.AgentConfig)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -260,7 +251,9 @@ func NewVMFromGrpc(ctx context.Context, v *pb.GrpcVM, config VMConfig) (*VM, err
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
agent := newAgent(config.AgentType)
|
// create agent instance
|
||||||
|
newAagentFunc := getNewAgentFunc(ctx)
|
||||||
|
agent := newAagentFunc()
|
||||||
agent.configureFromGrpc(hypervisor, v.Id, isProxyBuiltIn(config.ProxyType), config.AgentConfig)
|
agent.configureFromGrpc(hypervisor, v.Id, isProxyBuiltIn(config.ProxyType), config.AgentConfig)
|
||||||
|
|
||||||
proxy, err := newProxy(config.ProxyType)
|
proxy, err := newProxy(config.ProxyType)
|
||||||
|
@ -24,7 +24,6 @@ func TestNewVM(t *testing.T) {
|
|||||||
|
|
||||||
config := VMConfig{
|
config := VMConfig{
|
||||||
HypervisorType: MockHypervisor,
|
HypervisorType: MockHypervisor,
|
||||||
AgentType: NoopAgentType,
|
|
||||||
ProxyType: NoopProxyType,
|
ProxyType: NoopProxyType,
|
||||||
}
|
}
|
||||||
hyperConfig := HypervisorConfig{
|
hyperConfig := HypervisorConfig{
|
||||||
@ -32,7 +31,7 @@ func TestNewVM(t *testing.T) {
|
|||||||
ImagePath: testDir,
|
ImagePath: testDir,
|
||||||
}
|
}
|
||||||
|
|
||||||
ctx := context.Background()
|
ctx := WithNewAgentFunc(context.Background(), newMockAgent)
|
||||||
|
|
||||||
var vm *VM
|
var vm *VM
|
||||||
_, err = NewVM(ctx, config)
|
_, err = NewVM(ctx, config)
|
||||||
@ -103,11 +102,10 @@ func TestSetupProxy(t *testing.T) {
|
|||||||
|
|
||||||
config := VMConfig{
|
config := VMConfig{
|
||||||
HypervisorType: MockHypervisor,
|
HypervisorType: MockHypervisor,
|
||||||
AgentType: NoopAgentType,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
hypervisor := &mockHypervisor{}
|
hypervisor := &mockHypervisor{}
|
||||||
agent := &noopAgent{}
|
agent := &mockAgent{}
|
||||||
|
|
||||||
// wrong proxy type
|
// wrong proxy type
|
||||||
config.ProxyType = ProxyType("invalidProxyType")
|
config.ProxyType = ProxyType("invalidProxyType")
|
||||||
@ -124,7 +122,6 @@ func TestVMConfigGrpc(t *testing.T) {
|
|||||||
config := VMConfig{
|
config := VMConfig{
|
||||||
HypervisorType: QemuHypervisor,
|
HypervisorType: QemuHypervisor,
|
||||||
HypervisorConfig: newQemuConfig(),
|
HypervisorConfig: newQemuConfig(),
|
||||||
AgentType: KataContainersAgent,
|
|
||||||
AgentConfig: KataAgentConfig{false, true, false, false, 0, "", "", []string{}},
|
AgentConfig: KataAgentConfig{false, true, false, false, 0, "", "", []string{}},
|
||||||
ProxyType: NoopProxyType,
|
ProxyType: NoopProxyType,
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user