diff --git a/src/runtime/cmd/kata-runtime/factory_test.go b/src/runtime/cmd/kata-runtime/factory_test.go index f980bc5a56..3ab861420b 100644 --- a/src/runtime/cmd/kata-runtime/factory_test.go +++ b/src/runtime/cmd/kata-runtime/factory_test.go @@ -44,7 +44,7 @@ func TestFactoryCLIFunctionInit(t *testing.T) { tmpdir := t.TempDir() - runtimeConfig, err := newTestRuntimeConfig(tmpdir, testConsole, true) + runtimeConfig, err := newTestRuntimeConfig(tmpdir, true) assert.NoError(err) set := flag.NewFlagSet("", 0) @@ -91,7 +91,7 @@ func TestFactoryCLIFunctionDestroy(t *testing.T) { tmpdir := t.TempDir() - runtimeConfig, err := newTestRuntimeConfig(tmpdir, testConsole, true) + runtimeConfig, err := newTestRuntimeConfig(tmpdir, true) assert.NoError(err) set := flag.NewFlagSet("", 0) @@ -123,7 +123,7 @@ func TestFactoryCLIFunctionStatus(t *testing.T) { tmpdir := t.TempDir() - runtimeConfig, err := newTestRuntimeConfig(tmpdir, testConsole, true) + runtimeConfig, err := newTestRuntimeConfig(tmpdir, true) assert.NoError(err) set := flag.NewFlagSet("", 0) diff --git a/src/runtime/cmd/kata-runtime/main_test.go b/src/runtime/cmd/kata-runtime/main_test.go index 95c7dc59d5..f8f98c3c47 100644 --- a/src/runtime/cmd/kata-runtime/main_test.go +++ b/src/runtime/cmd/kata-runtime/main_test.go @@ -33,8 +33,6 @@ const ( testDirMode = os.FileMode(0750) testFileMode = os.FileMode(0640) testExeFileMode = os.FileMode(0750) - - testConsole = "/dev/pts/999" ) var ( @@ -151,7 +149,7 @@ func newTestHypervisorConfig(dir string, create bool) (vc.HypervisorConfig, erro } // 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 == "" { return oci.RuntimeConfig{}, errors.New("BUG: need directory") } @@ -164,7 +162,6 @@ func newTestRuntimeConfig(dir, consolePath string, create bool) (oci.RuntimeConf return oci.RuntimeConfig{ HypervisorType: vc.QemuHypervisor, HypervisorConfig: hypervisorConfig, - Console: consolePath, }, nil } diff --git a/src/runtime/pkg/containerd-shim-v2/create.go b/src/runtime/pkg/containerd-shim-v2/create.go index eba829e2dd..6b14a94c7a 100644 --- a/src/runtime/pkg/containerd-shim-v2/create.go +++ b/src/runtime/pkg/containerd-shim-v2/create.go @@ -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 // 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 { 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 { return nil, err } diff --git a/src/runtime/pkg/containerd-shim-v2/create_test.go b/src/runtime/pkg/containerd-shim-v2/create_test.go index 994de7c436..121d5ea4db 100644 --- a/src/runtime/pkg/containerd-shim-v2/create_test.go +++ b/src/runtime/pkg/containerd-shim-v2/create_test.go @@ -51,7 +51,7 @@ func TestCreateSandboxSuccess(t *testing.T) { tmpdir, bundlePath, ociConfigFile := ktu.SetupOCIConfigFile(t) - runtimeConfig, err := newTestRuntimeConfig(tmpdir, testConsole, true) + runtimeConfig, err := newTestRuntimeConfig(tmpdir, true) assert.NoError(err) spec, err := compatoci.ParseConfigJSON(bundlePath) @@ -99,7 +99,7 @@ func TestCreateSandboxFail(t *testing.T) { tmpdir, bundlePath, ociConfigFile := ktu.SetupOCIConfigFile(t) - runtimeConfig, err := newTestRuntimeConfig(tmpdir, testConsole, true) + runtimeConfig, err := newTestRuntimeConfig(tmpdir, true) assert.NoError(err) spec, err := compatoci.ParseConfigJSON(bundlePath) @@ -136,7 +136,7 @@ func TestCreateSandboxConfigFail(t *testing.T) { tmpdir, bundlePath, _ := ktu.SetupOCIConfigFile(t) - runtimeConfig, err := newTestRuntimeConfig(tmpdir, testConsole, true) + runtimeConfig, err := newTestRuntimeConfig(tmpdir, true) assert.NoError(err) spec, err := compatoci.ParseConfigJSON(bundlePath) @@ -185,7 +185,7 @@ func TestCreateContainerSuccess(t *testing.T) { tmpdir, bundlePath, ociConfigFile := ktu.SetupOCIConfigFile(t) - runtimeConfig, err := newTestRuntimeConfig(tmpdir, testConsole, true) + runtimeConfig, err := newTestRuntimeConfig(tmpdir, true) assert.NoError(err) spec, err := compatoci.ParseConfigJSON(bundlePath) @@ -224,7 +224,7 @@ func TestCreateContainerFail(t *testing.T) { tmpdir, bundlePath, ociConfigFile := ktu.SetupOCIConfigFile(t) - runtimeConfig, err := newTestRuntimeConfig(tmpdir, testConsole, true) + runtimeConfig, err := newTestRuntimeConfig(tmpdir, true) assert.NoError(err) spec, err := compatoci.ParseConfigJSON(bundlePath) @@ -274,7 +274,7 @@ func TestCreateContainerConfigFail(t *testing.T) { tmpdir, bundlePath, ociConfigFile := ktu.SetupOCIConfigFile(t) - runtimeConfig, err := newTestRuntimeConfig(tmpdir, testConsole, true) + runtimeConfig, err := newTestRuntimeConfig(tmpdir, true) assert.NoError(err) spec, err := compatoci.ParseConfigJSON(bundlePath) diff --git a/src/runtime/pkg/containerd-shim-v2/utils_test.go b/src/runtime/pkg/containerd-shim-v2/utils_test.go index 35b489920b..32195bcce0 100644 --- a/src/runtime/pkg/containerd-shim-v2/utils_test.go +++ b/src/runtime/pkg/containerd-shim-v2/utils_test.go @@ -28,7 +28,6 @@ const ( testSandboxID = "777-77-77777777" testContainerID = "42" - testConsole = "/dev/pts/888" testContainerTypeAnnotation = "io.kubernetes.cri.container-type" testSandboxIDAnnotation = "io.kubernetes.cri.sandbox-id" @@ -91,7 +90,7 @@ func newTestHypervisorConfig(dir string, create bool) (vc.HypervisorConfig, erro } // 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 == "" { return oci.RuntimeConfig{}, errors.New("BUG: need directory") } @@ -104,7 +103,6 @@ func newTestRuntimeConfig(dir, consolePath string, create bool) (oci.RuntimeConf return oci.RuntimeConfig{ HypervisorType: vc.QemuHypervisor, HypervisorConfig: hypervisorConfig, - Console: consolePath, }, nil } diff --git a/src/runtime/pkg/katautils/create.go b/src/runtime/pkg/katautils/create.go index e456d37276..ffcaa07154 100644 --- a/src/runtime/pkg/katautils/create.go +++ b/src/runtime/pkg/katautils/create.go @@ -111,12 +111,12 @@ func SetEphemeralStorageType(ociSpec specs.Spec, disableGuestEmptyDir bool) spec // CreateSandbox create a sandbox container 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) katatrace.AddTags(span, "container_id", containerID) 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 { return nil, vc.Process{}, err } @@ -219,7 +219,7 @@ func checkForFIPS(sandboxConfig *vc.SandboxConfig) error { } // 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 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) - contConfig, err := oci.ContainerConfig(ociSpec, bundlePath, containerID, console, disableOutput) + contConfig, err := oci.ContainerConfig(ociSpec, bundlePath, containerID, disableOutput) if err != nil { return vc.Process{}, err } diff --git a/src/runtime/pkg/katautils/create_test.go b/src/runtime/pkg/katautils/create_test.go index 15b4561137..b1e4cf2a90 100644 --- a/src/runtime/pkg/katautils/create_test.go +++ b/src/runtime/pkg/katautils/create_test.go @@ -28,7 +28,6 @@ import ( ) const ( - testConsole = "/dev/pts/999" testContainerTypeAnnotation = "io.kubernetes.cri-o.ContainerType" testSandboxIDAnnotation = "io.kubernetes.cri-o.SandboxID" testContainerTypeContainer = "container" @@ -50,7 +49,7 @@ func init() { } // 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 == "" { return oci.RuntimeConfig{}, errors.New("BUG: need directory") } @@ -63,7 +62,6 @@ func newTestRuntimeConfig(dir, consolePath string, create bool) (oci.RuntimeConf return oci.RuntimeConfig{ HypervisorType: vc.QemuHypervisor, HypervisorConfig: hypervisorConfig, - Console: consolePath, }, nil } @@ -213,7 +211,7 @@ func TestCreateSandboxConfigFail(t *testing.T) { tmpdir, bundlePath, _ := ktu.SetupOCIConfigFile(t) - runtimeConfig, err := newTestRuntimeConfig(tmpdir, testConsole, true) + runtimeConfig, err := newTestRuntimeConfig(tmpdir, true) assert.NoError(err) spec, err := compatoci.ParseConfigJSON(bundlePath) @@ -233,7 +231,7 @@ func TestCreateSandboxConfigFail(t *testing.T) { 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) } @@ -246,7 +244,7 @@ func TestCreateSandboxFail(t *testing.T) { tmpdir, bundlePath, _ := ktu.SetupOCIConfigFile(t) - runtimeConfig, err := newTestRuntimeConfig(tmpdir, testConsole, true) + runtimeConfig, err := newTestRuntimeConfig(tmpdir, true) assert.NoError(err) spec, err := compatoci.ParseConfigJSON(bundlePath) @@ -254,7 +252,7 @@ func TestCreateSandboxFail(t *testing.T) { 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.True(vcmock.IsMockError(err)) } @@ -268,7 +266,7 @@ func TestCreateSandboxAnnotations(t *testing.T) { tmpdir, bundlePath, _ := ktu.SetupOCIConfigFile(t) - runtimeConfig, err := newTestRuntimeConfig(tmpdir, testConsole, true) + runtimeConfig, err := newTestRuntimeConfig(tmpdir, true) assert.NoError(err) spec, err := compatoci.ParseConfigJSON(bundlePath) @@ -290,7 +288,7 @@ func TestCreateSandboxAnnotations(t *testing.T) { 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) netNsPath, err := sandbox.Annotations("nerdctl/network-namespace") @@ -356,7 +354,7 @@ func TestCreateContainerContainerConfigFail(t *testing.T) { rootFs := vc.RootFs{Mounted: true} 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.False(vcmock.IsMockError(err)) assert.True(strings.Contains(err.Error(), containerType)) @@ -383,7 +381,7 @@ func TestCreateContainerFail(t *testing.T) { rootFs := vc.RootFs{Mounted: true} 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.True(vcmock.IsMockError(err)) } @@ -417,7 +415,7 @@ func TestCreateContainer(t *testing.T) { rootFs := vc.RootFs{Mounted: true} 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) } } diff --git a/src/runtime/pkg/oci/utils.go b/src/runtime/pkg/oci/utils.go index 71423cf0cc..5fb8ea1d5d 100644 --- a/src/runtime/pkg/oci/utils.go +++ b/src/runtime/pkg/oci/utils.go @@ -105,7 +105,6 @@ type RuntimeConfig struct { //Experimental features enabled Experimental []exp.Feature - Console string JaegerEndpoint string JaegerUser string JaegerPassword string @@ -861,8 +860,8 @@ func addAgentConfigOverrides(ocispec specs.Spec, config *vc.SandboxConfig) error // SandboxConfig converts an OCI compatible runtime configuration file // to a virtcontainers sandbox configuration structure. -func SandboxConfig(ocispec specs.Spec, runtime RuntimeConfig, bundlePath, cid, console string, detach, systemdCgroup bool) (vc.SandboxConfig, error) { - containerConfig, err := ContainerConfig(ocispec, bundlePath, cid, console, detach) +func SandboxConfig(ocispec specs.Spec, runtime RuntimeConfig, bundlePath, cid string, detach, systemdCgroup bool) (vc.SandboxConfig, error) { + containerConfig, err := ContainerConfig(ocispec, bundlePath, cid, detach) if err != nil { 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 // 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} if !filepath.IsAbs(rootfs.Target) { 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), PrimaryGroup: strconv.FormatUint(uint64(ocispec.Process.User.GID), 10), Interactive: ocispec.Process.Terminal, - Console: console, Detach: detach, NoNewPrivileges: ocispec.Process.NoNewPrivileges, } diff --git a/src/runtime/pkg/oci/utils_test.go b/src/runtime/pkg/oci/utils_test.go index 2ddd42d111..6fe136b5d4 100644 --- a/src/runtime/pkg/oci/utils_test.go +++ b/src/runtime/pkg/oci/utils_test.go @@ -38,7 +38,6 @@ const ( var ( tempRoot = "" tempBundlePath = "" - consolePath = "" ) func createConfig(fileName string, fileData string) (string, error) { @@ -72,7 +71,6 @@ func TestMinimalSandboxConfig(t *testing.T) { runtimeConfig := RuntimeConfig{ HypervisorType: vc.QemuHypervisor, - Console: consolePath, } capList := []string{"CAP_AUDIT_WRITE", "CAP_KILL", "CAP_NET_BIND_SERVICE"} @@ -94,7 +92,6 @@ func TestMinimalSandboxConfig(t *testing.T) { PrimaryGroup: "0", SupplementaryGroups: []string{"10", "29"}, Interactive: true, - Console: consolePath, NoNewPrivileges: true, Capabilities: &specs.LinuxCapabilities{ Bounding: capList, @@ -181,7 +178,7 @@ func TestMinimalSandboxConfig(t *testing.T) { 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.Exactly(sandboxConfig, expectedSandboxConfig) @@ -452,7 +449,6 @@ func TestMain(m *testing.M) { } tempBundlePath = filepath.Join(tempRoot, "ocibundle") - consolePath = filepath.Join(tempRoot, "console") /* Create temp bundle directory if necessary */ err = os.MkdirAll(tempBundlePath, dirMode) @@ -513,7 +509,6 @@ func TestAddAssetAnnotations(t *testing.T) { runtimeConfig := RuntimeConfig{ HypervisorType: vc.QemuHypervisor, - Console: consolePath, } // Try annotations without enabling them first @@ -567,7 +562,6 @@ func TestAddAgentAnnotations(t *testing.T) { runtimeConfig := RuntimeConfig{ HypervisorType: vc.QemuHypervisor, - Console: consolePath, } ocispec.Annotations[vcAnnotations.KernelModules] = strings.Join(expectedAgentConfig.KernelModules, KernelModulesSeparator) @@ -594,7 +588,6 @@ func TestContainerPipeSizeAnnotation(t *testing.T) { runtimeConfig := RuntimeConfig{ HypervisorType: vc.QemuHypervisor, - Console: consolePath, } ocispec.Annotations[vcAnnotations.AgentContainerPipeSize] = "foo" @@ -629,7 +622,6 @@ func TestAddHypervisorAnnotations(t *testing.T) { runtimeConfig := RuntimeConfig{ HypervisorType: vc.QemuHypervisor, - Console: consolePath, } runtimeConfig.HypervisorConfig.EnableAnnotations = []string{".*"} runtimeConfig.HypervisorConfig.FileBackedMemRootList = []string{"/dev/shm*"} @@ -743,7 +735,6 @@ func TestAddProtectedHypervisorAnnotations(t *testing.T) { runtimeConfig := RuntimeConfig{ HypervisorType: vc.QemuHypervisor, - Console: consolePath, } ocispec.Annotations[vcAnnotations.KernelParams] = "vsyscall=emulate iommu=on" err := addAnnotations(ocispec, &config, runtimeConfig) @@ -809,7 +800,6 @@ func TestAddRuntimeAnnotations(t *testing.T) { runtimeConfig := RuntimeConfig{ HypervisorType: vc.QemuHypervisor, - Console: consolePath, } ocispec.Annotations[vcAnnotations.DisableGuestSeccomp] = "true" diff --git a/src/runtime/virtcontainers/types/sandbox.go b/src/runtime/virtcontainers/types/sandbox.go index f4fc3e503f..5149b04232 100644 --- a/src/runtime/virtcontainers/types/sandbox.go +++ b/src/runtime/virtcontainers/types/sandbox.go @@ -314,7 +314,6 @@ type Cmd struct { User string PrimaryGroup string WorkDir string - Console string Args []string Envs []EnvVar