mirror of
https://github.com/kata-containers/kata-containers.git
synced 2025-06-23 22:17:19 +00:00
runtime: delete Console from Cmd type
There is much code related to this property, but it is not used anymore. Fixes: #4553 Signed-off-by: liubin <liubin0329@gmail.com>
This commit is contained in:
parent
916ffb75d7
commit
a5a25ed13d
@ -44,7 +44,7 @@ func TestFactoryCLIFunctionInit(t *testing.T) {
|
|||||||
|
|
||||||
tmpdir := t.TempDir()
|
tmpdir := t.TempDir()
|
||||||
|
|
||||||
runtimeConfig, err := newTestRuntimeConfig(tmpdir, testConsole, true)
|
runtimeConfig, err := newTestRuntimeConfig(tmpdir, true)
|
||||||
assert.NoError(err)
|
assert.NoError(err)
|
||||||
|
|
||||||
set := flag.NewFlagSet("", 0)
|
set := flag.NewFlagSet("", 0)
|
||||||
@ -91,7 +91,7 @@ func TestFactoryCLIFunctionDestroy(t *testing.T) {
|
|||||||
|
|
||||||
tmpdir := t.TempDir()
|
tmpdir := t.TempDir()
|
||||||
|
|
||||||
runtimeConfig, err := newTestRuntimeConfig(tmpdir, testConsole, true)
|
runtimeConfig, err := newTestRuntimeConfig(tmpdir, true)
|
||||||
assert.NoError(err)
|
assert.NoError(err)
|
||||||
|
|
||||||
set := flag.NewFlagSet("", 0)
|
set := flag.NewFlagSet("", 0)
|
||||||
@ -123,7 +123,7 @@ func TestFactoryCLIFunctionStatus(t *testing.T) {
|
|||||||
|
|
||||||
tmpdir := t.TempDir()
|
tmpdir := t.TempDir()
|
||||||
|
|
||||||
runtimeConfig, err := newTestRuntimeConfig(tmpdir, testConsole, true)
|
runtimeConfig, err := newTestRuntimeConfig(tmpdir, true)
|
||||||
assert.NoError(err)
|
assert.NoError(err)
|
||||||
|
|
||||||
set := flag.NewFlagSet("", 0)
|
set := flag.NewFlagSet("", 0)
|
||||||
|
@ -33,8 +33,6 @@ const (
|
|||||||
testDirMode = os.FileMode(0750)
|
testDirMode = os.FileMode(0750)
|
||||||
testFileMode = os.FileMode(0640)
|
testFileMode = os.FileMode(0640)
|
||||||
testExeFileMode = os.FileMode(0750)
|
testExeFileMode = os.FileMode(0750)
|
||||||
|
|
||||||
testConsole = "/dev/pts/999"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
@ -151,7 +149,7 @@ func newTestHypervisorConfig(dir string, create bool) (vc.HypervisorConfig, erro
|
|||||||
}
|
}
|
||||||
|
|
||||||
// newTestRuntimeConfig creates a new RuntimeConfig
|
// newTestRuntimeConfig creates a new RuntimeConfig
|
||||||
func newTestRuntimeConfig(dir, consolePath string, create bool) (oci.RuntimeConfig, error) {
|
func newTestRuntimeConfig(dir string, create bool) (oci.RuntimeConfig, error) {
|
||||||
if dir == "" {
|
if dir == "" {
|
||||||
return oci.RuntimeConfig{}, errors.New("BUG: need directory")
|
return oci.RuntimeConfig{}, errors.New("BUG: need directory")
|
||||||
}
|
}
|
||||||
@ -164,7 +162,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,
|
||||||
Console: consolePath,
|
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -144,7 +144,7 @@ func create(ctx context.Context, s *service, r *taskAPI.CreateTaskRequest) (*con
|
|||||||
// ctx will be canceled after this rpc service call, but the sandbox will live
|
// ctx will be canceled after this rpc service call, but the sandbox will live
|
||||||
// across multiple rpc service calls.
|
// across multiple rpc service calls.
|
||||||
//
|
//
|
||||||
sandbox, _, err := katautils.CreateSandbox(s.ctx, vci, *ociSpec, *s.config, rootFs, r.ID, bundlePath, "", disableOutput, false)
|
sandbox, _, err := katautils.CreateSandbox(s.ctx, vci, *ociSpec, *s.config, rootFs, r.ID, bundlePath, disableOutput, false)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@ -179,7 +179,7 @@ func create(ctx context.Context, s *service, r *taskAPI.CreateTaskRequest) (*con
|
|||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
|
|
||||||
_, err = katautils.CreateContainer(ctx, s.sandbox, *ociSpec, rootFs, r.ID, bundlePath, "", disableOutput, runtimeConfig.DisableGuestEmptyDir)
|
_, err = katautils.CreateContainer(ctx, s.sandbox, *ociSpec, rootFs, r.ID, bundlePath, disableOutput, runtimeConfig.DisableGuestEmptyDir)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
@ -51,7 +51,7 @@ func TestCreateSandboxSuccess(t *testing.T) {
|
|||||||
|
|
||||||
tmpdir, bundlePath, ociConfigFile := ktu.SetupOCIConfigFile(t)
|
tmpdir, bundlePath, ociConfigFile := ktu.SetupOCIConfigFile(t)
|
||||||
|
|
||||||
runtimeConfig, err := newTestRuntimeConfig(tmpdir, testConsole, true)
|
runtimeConfig, err := newTestRuntimeConfig(tmpdir, true)
|
||||||
assert.NoError(err)
|
assert.NoError(err)
|
||||||
|
|
||||||
spec, err := compatoci.ParseConfigJSON(bundlePath)
|
spec, err := compatoci.ParseConfigJSON(bundlePath)
|
||||||
@ -99,7 +99,7 @@ func TestCreateSandboxFail(t *testing.T) {
|
|||||||
|
|
||||||
tmpdir, bundlePath, ociConfigFile := ktu.SetupOCIConfigFile(t)
|
tmpdir, bundlePath, ociConfigFile := ktu.SetupOCIConfigFile(t)
|
||||||
|
|
||||||
runtimeConfig, err := newTestRuntimeConfig(tmpdir, testConsole, true)
|
runtimeConfig, err := newTestRuntimeConfig(tmpdir, true)
|
||||||
assert.NoError(err)
|
assert.NoError(err)
|
||||||
|
|
||||||
spec, err := compatoci.ParseConfigJSON(bundlePath)
|
spec, err := compatoci.ParseConfigJSON(bundlePath)
|
||||||
@ -136,7 +136,7 @@ func TestCreateSandboxConfigFail(t *testing.T) {
|
|||||||
|
|
||||||
tmpdir, bundlePath, _ := ktu.SetupOCIConfigFile(t)
|
tmpdir, bundlePath, _ := ktu.SetupOCIConfigFile(t)
|
||||||
|
|
||||||
runtimeConfig, err := newTestRuntimeConfig(tmpdir, testConsole, true)
|
runtimeConfig, err := newTestRuntimeConfig(tmpdir, true)
|
||||||
assert.NoError(err)
|
assert.NoError(err)
|
||||||
|
|
||||||
spec, err := compatoci.ParseConfigJSON(bundlePath)
|
spec, err := compatoci.ParseConfigJSON(bundlePath)
|
||||||
@ -185,7 +185,7 @@ func TestCreateContainerSuccess(t *testing.T) {
|
|||||||
|
|
||||||
tmpdir, bundlePath, ociConfigFile := ktu.SetupOCIConfigFile(t)
|
tmpdir, bundlePath, ociConfigFile := ktu.SetupOCIConfigFile(t)
|
||||||
|
|
||||||
runtimeConfig, err := newTestRuntimeConfig(tmpdir, testConsole, true)
|
runtimeConfig, err := newTestRuntimeConfig(tmpdir, true)
|
||||||
assert.NoError(err)
|
assert.NoError(err)
|
||||||
|
|
||||||
spec, err := compatoci.ParseConfigJSON(bundlePath)
|
spec, err := compatoci.ParseConfigJSON(bundlePath)
|
||||||
@ -224,7 +224,7 @@ func TestCreateContainerFail(t *testing.T) {
|
|||||||
|
|
||||||
tmpdir, bundlePath, ociConfigFile := ktu.SetupOCIConfigFile(t)
|
tmpdir, bundlePath, ociConfigFile := ktu.SetupOCIConfigFile(t)
|
||||||
|
|
||||||
runtimeConfig, err := newTestRuntimeConfig(tmpdir, testConsole, true)
|
runtimeConfig, err := newTestRuntimeConfig(tmpdir, true)
|
||||||
assert.NoError(err)
|
assert.NoError(err)
|
||||||
|
|
||||||
spec, err := compatoci.ParseConfigJSON(bundlePath)
|
spec, err := compatoci.ParseConfigJSON(bundlePath)
|
||||||
@ -274,7 +274,7 @@ func TestCreateContainerConfigFail(t *testing.T) {
|
|||||||
|
|
||||||
tmpdir, bundlePath, ociConfigFile := ktu.SetupOCIConfigFile(t)
|
tmpdir, bundlePath, ociConfigFile := ktu.SetupOCIConfigFile(t)
|
||||||
|
|
||||||
runtimeConfig, err := newTestRuntimeConfig(tmpdir, testConsole, true)
|
runtimeConfig, err := newTestRuntimeConfig(tmpdir, true)
|
||||||
assert.NoError(err)
|
assert.NoError(err)
|
||||||
|
|
||||||
spec, err := compatoci.ParseConfigJSON(bundlePath)
|
spec, err := compatoci.ParseConfigJSON(bundlePath)
|
||||||
|
@ -28,7 +28,6 @@ const (
|
|||||||
|
|
||||||
testSandboxID = "777-77-77777777"
|
testSandboxID = "777-77-77777777"
|
||||||
testContainerID = "42"
|
testContainerID = "42"
|
||||||
testConsole = "/dev/pts/888"
|
|
||||||
|
|
||||||
testContainerTypeAnnotation = "io.kubernetes.cri.container-type"
|
testContainerTypeAnnotation = "io.kubernetes.cri.container-type"
|
||||||
testSandboxIDAnnotation = "io.kubernetes.cri.sandbox-id"
|
testSandboxIDAnnotation = "io.kubernetes.cri.sandbox-id"
|
||||||
@ -91,7 +90,7 @@ func newTestHypervisorConfig(dir string, create bool) (vc.HypervisorConfig, erro
|
|||||||
}
|
}
|
||||||
|
|
||||||
// newTestRuntimeConfig creates a new RuntimeConfig
|
// newTestRuntimeConfig creates a new RuntimeConfig
|
||||||
func newTestRuntimeConfig(dir, consolePath string, create bool) (oci.RuntimeConfig, error) {
|
func newTestRuntimeConfig(dir string, create bool) (oci.RuntimeConfig, error) {
|
||||||
if dir == "" {
|
if dir == "" {
|
||||||
return oci.RuntimeConfig{}, errors.New("BUG: need directory")
|
return oci.RuntimeConfig{}, errors.New("BUG: need directory")
|
||||||
}
|
}
|
||||||
@ -104,7 +103,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,
|
||||||
Console: consolePath,
|
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -111,12 +111,12 @@ func SetEphemeralStorageType(ociSpec specs.Spec, disableGuestEmptyDir bool) spec
|
|||||||
|
|
||||||
// CreateSandbox create a sandbox container
|
// CreateSandbox create a sandbox container
|
||||||
func CreateSandbox(ctx context.Context, vci vc.VC, ociSpec specs.Spec, runtimeConfig oci.RuntimeConfig, rootFs vc.RootFs,
|
func CreateSandbox(ctx context.Context, vci vc.VC, ociSpec specs.Spec, runtimeConfig oci.RuntimeConfig, rootFs vc.RootFs,
|
||||||
containerID, bundlePath, console string, disableOutput, systemdCgroup bool) (_ vc.VCSandbox, _ vc.Process, err error) {
|
containerID, bundlePath string, disableOutput, systemdCgroup bool) (_ vc.VCSandbox, _ vc.Process, err error) {
|
||||||
span, ctx := katatrace.Trace(ctx, nil, "CreateSandbox", createTracingTags)
|
span, ctx := katatrace.Trace(ctx, nil, "CreateSandbox", createTracingTags)
|
||||||
katatrace.AddTags(span, "container_id", containerID)
|
katatrace.AddTags(span, "container_id", containerID)
|
||||||
defer span.End()
|
defer span.End()
|
||||||
|
|
||||||
sandboxConfig, err := oci.SandboxConfig(ociSpec, runtimeConfig, bundlePath, containerID, console, disableOutput, systemdCgroup)
|
sandboxConfig, err := oci.SandboxConfig(ociSpec, runtimeConfig, bundlePath, containerID, disableOutput, systemdCgroup)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, vc.Process{}, err
|
return nil, vc.Process{}, err
|
||||||
}
|
}
|
||||||
@ -219,7 +219,7 @@ func checkForFIPS(sandboxConfig *vc.SandboxConfig) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// CreateContainer create a container
|
// CreateContainer create a container
|
||||||
func CreateContainer(ctx context.Context, sandbox vc.VCSandbox, ociSpec specs.Spec, rootFs vc.RootFs, containerID, bundlePath, console string, disableOutput bool, disableGuestEmptyDir bool) (vc.Process, error) {
|
func CreateContainer(ctx context.Context, sandbox vc.VCSandbox, ociSpec specs.Spec, rootFs vc.RootFs, containerID, bundlePath string, disableOutput bool, disableGuestEmptyDir bool) (vc.Process, error) {
|
||||||
var c vc.VCContainer
|
var c vc.VCContainer
|
||||||
|
|
||||||
span, ctx := katatrace.Trace(ctx, nil, "CreateContainer", createTracingTags)
|
span, ctx := katatrace.Trace(ctx, nil, "CreateContainer", createTracingTags)
|
||||||
@ -228,7 +228,7 @@ func CreateContainer(ctx context.Context, sandbox vc.VCSandbox, ociSpec specs.Sp
|
|||||||
|
|
||||||
ociSpec = SetEphemeralStorageType(ociSpec, disableGuestEmptyDir)
|
ociSpec = SetEphemeralStorageType(ociSpec, disableGuestEmptyDir)
|
||||||
|
|
||||||
contConfig, err := oci.ContainerConfig(ociSpec, bundlePath, containerID, console, disableOutput)
|
contConfig, err := oci.ContainerConfig(ociSpec, bundlePath, containerID, disableOutput)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return vc.Process{}, err
|
return vc.Process{}, err
|
||||||
}
|
}
|
||||||
|
@ -28,7 +28,6 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
testConsole = "/dev/pts/999"
|
|
||||||
testContainerTypeAnnotation = "io.kubernetes.cri-o.ContainerType"
|
testContainerTypeAnnotation = "io.kubernetes.cri-o.ContainerType"
|
||||||
testSandboxIDAnnotation = "io.kubernetes.cri-o.SandboxID"
|
testSandboxIDAnnotation = "io.kubernetes.cri-o.SandboxID"
|
||||||
testContainerTypeContainer = "container"
|
testContainerTypeContainer = "container"
|
||||||
@ -50,7 +49,7 @@ func init() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// newTestRuntimeConfig creates a new RuntimeConfig
|
// newTestRuntimeConfig creates a new RuntimeConfig
|
||||||
func newTestRuntimeConfig(dir, consolePath string, create bool) (oci.RuntimeConfig, error) {
|
func newTestRuntimeConfig(dir string, create bool) (oci.RuntimeConfig, error) {
|
||||||
if dir == "" {
|
if dir == "" {
|
||||||
return oci.RuntimeConfig{}, errors.New("BUG: need directory")
|
return oci.RuntimeConfig{}, errors.New("BUG: need directory")
|
||||||
}
|
}
|
||||||
@ -63,7 +62,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,
|
||||||
Console: consolePath,
|
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -213,7 +211,7 @@ func TestCreateSandboxConfigFail(t *testing.T) {
|
|||||||
|
|
||||||
tmpdir, bundlePath, _ := ktu.SetupOCIConfigFile(t)
|
tmpdir, bundlePath, _ := ktu.SetupOCIConfigFile(t)
|
||||||
|
|
||||||
runtimeConfig, err := newTestRuntimeConfig(tmpdir, testConsole, true)
|
runtimeConfig, err := newTestRuntimeConfig(tmpdir, true)
|
||||||
assert.NoError(err)
|
assert.NoError(err)
|
||||||
|
|
||||||
spec, err := compatoci.ParseConfigJSON(bundlePath)
|
spec, err := compatoci.ParseConfigJSON(bundlePath)
|
||||||
@ -233,7 +231,7 @@ func TestCreateSandboxConfigFail(t *testing.T) {
|
|||||||
|
|
||||||
rootFs := vc.RootFs{Mounted: true}
|
rootFs := vc.RootFs{Mounted: true}
|
||||||
|
|
||||||
_, _, err = CreateSandbox(context.Background(), testingImpl, spec, runtimeConfig, rootFs, testContainerID, bundlePath, testConsole, true, true)
|
_, _, err = CreateSandbox(context.Background(), testingImpl, spec, runtimeConfig, rootFs, testContainerID, bundlePath, true, true)
|
||||||
assert.Error(err)
|
assert.Error(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -246,7 +244,7 @@ func TestCreateSandboxFail(t *testing.T) {
|
|||||||
|
|
||||||
tmpdir, bundlePath, _ := ktu.SetupOCIConfigFile(t)
|
tmpdir, bundlePath, _ := ktu.SetupOCIConfigFile(t)
|
||||||
|
|
||||||
runtimeConfig, err := newTestRuntimeConfig(tmpdir, testConsole, true)
|
runtimeConfig, err := newTestRuntimeConfig(tmpdir, true)
|
||||||
assert.NoError(err)
|
assert.NoError(err)
|
||||||
|
|
||||||
spec, err := compatoci.ParseConfigJSON(bundlePath)
|
spec, err := compatoci.ParseConfigJSON(bundlePath)
|
||||||
@ -254,7 +252,7 @@ func TestCreateSandboxFail(t *testing.T) {
|
|||||||
|
|
||||||
rootFs := vc.RootFs{Mounted: true}
|
rootFs := vc.RootFs{Mounted: true}
|
||||||
|
|
||||||
_, _, err = CreateSandbox(context.Background(), testingImpl, spec, runtimeConfig, rootFs, testContainerID, bundlePath, testConsole, true, true)
|
_, _, err = CreateSandbox(context.Background(), testingImpl, spec, runtimeConfig, rootFs, testContainerID, bundlePath, true, true)
|
||||||
assert.Error(err)
|
assert.Error(err)
|
||||||
assert.True(vcmock.IsMockError(err))
|
assert.True(vcmock.IsMockError(err))
|
||||||
}
|
}
|
||||||
@ -268,7 +266,7 @@ func TestCreateSandboxAnnotations(t *testing.T) {
|
|||||||
|
|
||||||
tmpdir, bundlePath, _ := ktu.SetupOCIConfigFile(t)
|
tmpdir, bundlePath, _ := ktu.SetupOCIConfigFile(t)
|
||||||
|
|
||||||
runtimeConfig, err := newTestRuntimeConfig(tmpdir, testConsole, true)
|
runtimeConfig, err := newTestRuntimeConfig(tmpdir, true)
|
||||||
assert.NoError(err)
|
assert.NoError(err)
|
||||||
|
|
||||||
spec, err := compatoci.ParseConfigJSON(bundlePath)
|
spec, err := compatoci.ParseConfigJSON(bundlePath)
|
||||||
@ -290,7 +288,7 @@ func TestCreateSandboxAnnotations(t *testing.T) {
|
|||||||
testingImpl.CreateSandboxFunc = nil
|
testingImpl.CreateSandboxFunc = nil
|
||||||
}()
|
}()
|
||||||
|
|
||||||
sandbox, _, err := CreateSandbox(context.Background(), testingImpl, spec, runtimeConfig, rootFs, testContainerID, bundlePath, testConsole, true, true)
|
sandbox, _, err := CreateSandbox(context.Background(), testingImpl, spec, runtimeConfig, rootFs, testContainerID, bundlePath, true, true)
|
||||||
assert.NoError(err)
|
assert.NoError(err)
|
||||||
|
|
||||||
netNsPath, err := sandbox.Annotations("nerdctl/network-namespace")
|
netNsPath, err := sandbox.Annotations("nerdctl/network-namespace")
|
||||||
@ -356,7 +354,7 @@ func TestCreateContainerContainerConfigFail(t *testing.T) {
|
|||||||
rootFs := vc.RootFs{Mounted: true}
|
rootFs := vc.RootFs{Mounted: true}
|
||||||
|
|
||||||
for _, disableOutput := range []bool{true, false} {
|
for _, disableOutput := range []bool{true, false} {
|
||||||
_, err = CreateContainer(context.Background(), mockSandbox, spec, rootFs, testContainerID, bundlePath, testConsole, disableOutput, false)
|
_, err = CreateContainer(context.Background(), mockSandbox, spec, rootFs, testContainerID, bundlePath, disableOutput, false)
|
||||||
assert.Error(err)
|
assert.Error(err)
|
||||||
assert.False(vcmock.IsMockError(err))
|
assert.False(vcmock.IsMockError(err))
|
||||||
assert.True(strings.Contains(err.Error(), containerType))
|
assert.True(strings.Contains(err.Error(), containerType))
|
||||||
@ -383,7 +381,7 @@ func TestCreateContainerFail(t *testing.T) {
|
|||||||
rootFs := vc.RootFs{Mounted: true}
|
rootFs := vc.RootFs{Mounted: true}
|
||||||
|
|
||||||
for _, disableOutput := range []bool{true, false} {
|
for _, disableOutput := range []bool{true, false} {
|
||||||
_, err = CreateContainer(context.Background(), mockSandbox, spec, rootFs, testContainerID, bundlePath, testConsole, disableOutput, false)
|
_, err = CreateContainer(context.Background(), mockSandbox, spec, rootFs, testContainerID, bundlePath, disableOutput, false)
|
||||||
assert.Error(err)
|
assert.Error(err)
|
||||||
assert.True(vcmock.IsMockError(err))
|
assert.True(vcmock.IsMockError(err))
|
||||||
}
|
}
|
||||||
@ -417,7 +415,7 @@ func TestCreateContainer(t *testing.T) {
|
|||||||
rootFs := vc.RootFs{Mounted: true}
|
rootFs := vc.RootFs{Mounted: true}
|
||||||
|
|
||||||
for _, disableOutput := range []bool{true, false} {
|
for _, disableOutput := range []bool{true, false} {
|
||||||
_, err = CreateContainer(context.Background(), mockSandbox, spec, rootFs, testContainerID, bundlePath, testConsole, disableOutput, false)
|
_, err = CreateContainer(context.Background(), mockSandbox, spec, rootFs, testContainerID, bundlePath, disableOutput, false)
|
||||||
assert.NoError(err)
|
assert.NoError(err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -105,7 +105,6 @@ type RuntimeConfig struct {
|
|||||||
//Experimental features enabled
|
//Experimental features enabled
|
||||||
Experimental []exp.Feature
|
Experimental []exp.Feature
|
||||||
|
|
||||||
Console string
|
|
||||||
JaegerEndpoint string
|
JaegerEndpoint string
|
||||||
JaegerUser string
|
JaegerUser string
|
||||||
JaegerPassword string
|
JaegerPassword string
|
||||||
@ -861,8 +860,8 @@ func addAgentConfigOverrides(ocispec specs.Spec, config *vc.SandboxConfig) error
|
|||||||
|
|
||||||
// SandboxConfig converts an OCI compatible runtime configuration file
|
// SandboxConfig converts an OCI compatible runtime configuration file
|
||||||
// to a virtcontainers sandbox configuration structure.
|
// to a virtcontainers sandbox configuration structure.
|
||||||
func SandboxConfig(ocispec specs.Spec, runtime RuntimeConfig, bundlePath, cid, console string, detach, systemdCgroup bool) (vc.SandboxConfig, error) {
|
func SandboxConfig(ocispec specs.Spec, runtime RuntimeConfig, bundlePath, cid string, detach, systemdCgroup bool) (vc.SandboxConfig, error) {
|
||||||
containerConfig, err := ContainerConfig(ocispec, bundlePath, cid, console, detach)
|
containerConfig, err := ContainerConfig(ocispec, bundlePath, cid, detach)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return vc.SandboxConfig{}, err
|
return vc.SandboxConfig{}, err
|
||||||
}
|
}
|
||||||
@ -947,7 +946,7 @@ func SandboxConfig(ocispec specs.Spec, runtime RuntimeConfig, bundlePath, cid, c
|
|||||||
|
|
||||||
// ContainerConfig converts an OCI compatible runtime configuration
|
// ContainerConfig converts an OCI compatible runtime configuration
|
||||||
// file to a virtcontainers container configuration structure.
|
// file to a virtcontainers container configuration structure.
|
||||||
func ContainerConfig(ocispec specs.Spec, bundlePath, cid, console string, detach bool) (vc.ContainerConfig, error) {
|
func ContainerConfig(ocispec specs.Spec, bundlePath, cid string, detach bool) (vc.ContainerConfig, error) {
|
||||||
rootfs := vc.RootFs{Target: ocispec.Root.Path, Mounted: true}
|
rootfs := vc.RootFs{Target: ocispec.Root.Path, Mounted: true}
|
||||||
if !filepath.IsAbs(rootfs.Target) {
|
if !filepath.IsAbs(rootfs.Target) {
|
||||||
rootfs.Target = filepath.Join(bundlePath, ocispec.Root.Path)
|
rootfs.Target = filepath.Join(bundlePath, ocispec.Root.Path)
|
||||||
@ -962,7 +961,6 @@ func ContainerConfig(ocispec specs.Spec, bundlePath, cid, console string, detach
|
|||||||
User: strconv.FormatUint(uint64(ocispec.Process.User.UID), 10),
|
User: strconv.FormatUint(uint64(ocispec.Process.User.UID), 10),
|
||||||
PrimaryGroup: strconv.FormatUint(uint64(ocispec.Process.User.GID), 10),
|
PrimaryGroup: strconv.FormatUint(uint64(ocispec.Process.User.GID), 10),
|
||||||
Interactive: ocispec.Process.Terminal,
|
Interactive: ocispec.Process.Terminal,
|
||||||
Console: console,
|
|
||||||
Detach: detach,
|
Detach: detach,
|
||||||
NoNewPrivileges: ocispec.Process.NoNewPrivileges,
|
NoNewPrivileges: ocispec.Process.NoNewPrivileges,
|
||||||
}
|
}
|
||||||
|
@ -38,7 +38,6 @@ const (
|
|||||||
var (
|
var (
|
||||||
tempRoot = ""
|
tempRoot = ""
|
||||||
tempBundlePath = ""
|
tempBundlePath = ""
|
||||||
consolePath = ""
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func createConfig(fileName string, fileData string) (string, error) {
|
func createConfig(fileName string, fileData string) (string, error) {
|
||||||
@ -72,7 +71,6 @@ func TestMinimalSandboxConfig(t *testing.T) {
|
|||||||
|
|
||||||
runtimeConfig := RuntimeConfig{
|
runtimeConfig := RuntimeConfig{
|
||||||
HypervisorType: vc.QemuHypervisor,
|
HypervisorType: vc.QemuHypervisor,
|
||||||
Console: consolePath,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
capList := []string{"CAP_AUDIT_WRITE", "CAP_KILL", "CAP_NET_BIND_SERVICE"}
|
capList := []string{"CAP_AUDIT_WRITE", "CAP_KILL", "CAP_NET_BIND_SERVICE"}
|
||||||
@ -94,7 +92,6 @@ func TestMinimalSandboxConfig(t *testing.T) {
|
|||||||
PrimaryGroup: "0",
|
PrimaryGroup: "0",
|
||||||
SupplementaryGroups: []string{"10", "29"},
|
SupplementaryGroups: []string{"10", "29"},
|
||||||
Interactive: true,
|
Interactive: true,
|
||||||
Console: consolePath,
|
|
||||||
NoNewPrivileges: true,
|
NoNewPrivileges: true,
|
||||||
Capabilities: &specs.LinuxCapabilities{
|
Capabilities: &specs.LinuxCapabilities{
|
||||||
Bounding: capList,
|
Bounding: capList,
|
||||||
@ -181,7 +178,7 @@ func TestMinimalSandboxConfig(t *testing.T) {
|
|||||||
SystemdCgroup: true,
|
SystemdCgroup: true,
|
||||||
}
|
}
|
||||||
|
|
||||||
sandboxConfig, err := SandboxConfig(spec, runtimeConfig, tempBundlePath, containerID, consolePath, false, true)
|
sandboxConfig, err := SandboxConfig(spec, runtimeConfig, tempBundlePath, containerID, false, true)
|
||||||
assert.NoError(err)
|
assert.NoError(err)
|
||||||
|
|
||||||
assert.Exactly(sandboxConfig, expectedSandboxConfig)
|
assert.Exactly(sandboxConfig, expectedSandboxConfig)
|
||||||
@ -452,7 +449,6 @@ func TestMain(m *testing.M) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
tempBundlePath = filepath.Join(tempRoot, "ocibundle")
|
tempBundlePath = filepath.Join(tempRoot, "ocibundle")
|
||||||
consolePath = filepath.Join(tempRoot, "console")
|
|
||||||
|
|
||||||
/* Create temp bundle directory if necessary */
|
/* Create temp bundle directory if necessary */
|
||||||
err = os.MkdirAll(tempBundlePath, dirMode)
|
err = os.MkdirAll(tempBundlePath, dirMode)
|
||||||
@ -513,7 +509,6 @@ func TestAddAssetAnnotations(t *testing.T) {
|
|||||||
|
|
||||||
runtimeConfig := RuntimeConfig{
|
runtimeConfig := RuntimeConfig{
|
||||||
HypervisorType: vc.QemuHypervisor,
|
HypervisorType: vc.QemuHypervisor,
|
||||||
Console: consolePath,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Try annotations without enabling them first
|
// Try annotations without enabling them first
|
||||||
@ -567,7 +562,6 @@ func TestAddAgentAnnotations(t *testing.T) {
|
|||||||
|
|
||||||
runtimeConfig := RuntimeConfig{
|
runtimeConfig := RuntimeConfig{
|
||||||
HypervisorType: vc.QemuHypervisor,
|
HypervisorType: vc.QemuHypervisor,
|
||||||
Console: consolePath,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ocispec.Annotations[vcAnnotations.KernelModules] = strings.Join(expectedAgentConfig.KernelModules, KernelModulesSeparator)
|
ocispec.Annotations[vcAnnotations.KernelModules] = strings.Join(expectedAgentConfig.KernelModules, KernelModulesSeparator)
|
||||||
@ -594,7 +588,6 @@ func TestContainerPipeSizeAnnotation(t *testing.T) {
|
|||||||
|
|
||||||
runtimeConfig := RuntimeConfig{
|
runtimeConfig := RuntimeConfig{
|
||||||
HypervisorType: vc.QemuHypervisor,
|
HypervisorType: vc.QemuHypervisor,
|
||||||
Console: consolePath,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ocispec.Annotations[vcAnnotations.AgentContainerPipeSize] = "foo"
|
ocispec.Annotations[vcAnnotations.AgentContainerPipeSize] = "foo"
|
||||||
@ -629,7 +622,6 @@ func TestAddHypervisorAnnotations(t *testing.T) {
|
|||||||
|
|
||||||
runtimeConfig := RuntimeConfig{
|
runtimeConfig := RuntimeConfig{
|
||||||
HypervisorType: vc.QemuHypervisor,
|
HypervisorType: vc.QemuHypervisor,
|
||||||
Console: consolePath,
|
|
||||||
}
|
}
|
||||||
runtimeConfig.HypervisorConfig.EnableAnnotations = []string{".*"}
|
runtimeConfig.HypervisorConfig.EnableAnnotations = []string{".*"}
|
||||||
runtimeConfig.HypervisorConfig.FileBackedMemRootList = []string{"/dev/shm*"}
|
runtimeConfig.HypervisorConfig.FileBackedMemRootList = []string{"/dev/shm*"}
|
||||||
@ -743,7 +735,6 @@ func TestAddProtectedHypervisorAnnotations(t *testing.T) {
|
|||||||
|
|
||||||
runtimeConfig := RuntimeConfig{
|
runtimeConfig := RuntimeConfig{
|
||||||
HypervisorType: vc.QemuHypervisor,
|
HypervisorType: vc.QemuHypervisor,
|
||||||
Console: consolePath,
|
|
||||||
}
|
}
|
||||||
ocispec.Annotations[vcAnnotations.KernelParams] = "vsyscall=emulate iommu=on"
|
ocispec.Annotations[vcAnnotations.KernelParams] = "vsyscall=emulate iommu=on"
|
||||||
err := addAnnotations(ocispec, &config, runtimeConfig)
|
err := addAnnotations(ocispec, &config, runtimeConfig)
|
||||||
@ -809,7 +800,6 @@ func TestAddRuntimeAnnotations(t *testing.T) {
|
|||||||
|
|
||||||
runtimeConfig := RuntimeConfig{
|
runtimeConfig := RuntimeConfig{
|
||||||
HypervisorType: vc.QemuHypervisor,
|
HypervisorType: vc.QemuHypervisor,
|
||||||
Console: consolePath,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ocispec.Annotations[vcAnnotations.DisableGuestSeccomp] = "true"
|
ocispec.Annotations[vcAnnotations.DisableGuestSeccomp] = "true"
|
||||||
|
@ -314,7 +314,6 @@ type Cmd struct {
|
|||||||
User string
|
User string
|
||||||
PrimaryGroup string
|
PrimaryGroup string
|
||||||
WorkDir string
|
WorkDir string
|
||||||
Console string
|
|
||||||
|
|
||||||
Args []string
|
Args []string
|
||||||
Envs []EnvVar
|
Envs []EnvVar
|
||||||
|
Loading…
Reference in New Issue
Block a user