From c42507903db4bfeb2edec5cff54e3172d79bd99b Mon Sep 17 00:00:00 2001 From: Gabi Beyer Date: Mon, 25 Mar 2019 15:40:47 -0700 Subject: [PATCH] vc: Deprecate CC proxy and shim Clear Containers proxy and shim are no longer supported. This was mentioned in issue #1113. Their functionalities are thus removed from the runtime. Fixes #1419 Signed-off-by: Gabi Beyer --- cli/main_test.go | 4 +- pkg/katautils/config.go | 10 +- pkg/katautils/create_test.go | 4 +- virtcontainers/Makefile | 11 +- virtcontainers/api_test.go | 110 ----- virtcontainers/cc_proxy.go | 47 -- virtcontainers/cc_proxy_test.go | 28 -- virtcontainers/cc_shim.go | 49 --- virtcontainers/cc_shim_test.go | 357 --------------- virtcontainers/documentation/api/1.0/api.md | 6 - virtcontainers/kata_shim_test.go | 61 ++- virtcontainers/network.go | 6 +- virtcontainers/pkg/mock/cc_proxy_mock.go | 460 -------------------- virtcontainers/pkg/mock/mock.go | 3 - virtcontainers/pkg/oci/utils_test.go | 12 +- virtcontainers/proxy.go | 16 - virtcontainers/proxy_test.go | 31 +- virtcontainers/shim.go | 11 +- virtcontainers/shim/mock/cc-shim/shim.go | 21 - virtcontainers/shim_test.go | 28 +- 20 files changed, 79 insertions(+), 1196 deletions(-) delete mode 100644 virtcontainers/cc_proxy.go delete mode 100644 virtcontainers/cc_proxy_test.go delete mode 100644 virtcontainers/cc_shim.go delete mode 100644 virtcontainers/cc_shim_test.go delete mode 100644 virtcontainers/pkg/mock/cc_proxy_mock.go delete mode 100644 virtcontainers/shim/mock/cc-shim/shim.go diff --git a/cli/main_test.go b/cli/main_test.go index 0f3743af3..72ef8290d 100644 --- a/cli/main_test.go +++ b/cli/main_test.go @@ -243,8 +243,8 @@ func newTestRuntimeConfig(dir, consolePath string, create bool) (oci.RuntimeConf HypervisorType: vc.QemuHypervisor, HypervisorConfig: hypervisorConfig, AgentType: vc.KataContainersAgent, - ProxyType: vc.CCProxyType, - ShimType: vc.CCShimType, + ProxyType: vc.KataProxyType, + ShimType: vc.KataShimType, Console: consolePath, }, nil } diff --git a/pkg/katautils/config.go b/pkg/katautils/config.go index 54d5e754b..4adcd2a69 100644 --- a/pkg/katautils/config.go +++ b/pkg/katautils/config.go @@ -52,11 +52,9 @@ const ( qemuHypervisorTableType = "qemu" // supported proxy component types - ccProxyTableType = "cc" kataProxyTableType = "kata" // supported shim component types - ccShimTableType = "cc" kataShimTableType = "kata" // supported agent component types @@ -605,10 +603,10 @@ func updateRuntimeConfigProxy(configPath string, tomlConf tomlConfig, config *oc for k, proxy := range tomlConf.Proxy { switch k { - case ccProxyTableType: - config.ProxyType = vc.CCProxyType case kataProxyTableType: config.ProxyType = vc.KataProxyType + default: + return fmt.Errorf("%s proxy type not supported", k) } path, err := proxy.path() @@ -660,10 +658,10 @@ func updateRuntimeConfigShim(configPath string, tomlConf tomlConfig, config *oci for k, shim := range tomlConf.Shim { switch k { - case ccShimTableType: - config.ShimType = vc.CCShimType case kataShimTableType: config.ShimType = vc.KataShimType + default: + return fmt.Errorf("%s shim is not supported", k) } shConfig, err := newShimConfig(shim) diff --git a/pkg/katautils/create_test.go b/pkg/katautils/create_test.go index b0dc18215..0acb8121e 100644 --- a/pkg/katautils/create_test.go +++ b/pkg/katautils/create_test.go @@ -121,8 +121,8 @@ func newTestRuntimeConfig(dir, consolePath string, create bool) (oci.RuntimeConf HypervisorType: vc.QemuHypervisor, HypervisorConfig: hypervisorConfig, AgentType: vc.KataContainersAgent, - ProxyType: vc.CCProxyType, - ShimType: vc.CCShimType, + ProxyType: vc.KataProxyType, + ShimType: vc.KataShimType, Console: consolePath, }, nil } diff --git a/virtcontainers/Makefile b/virtcontainers/Makefile index 7ce512bae..68b613e37 100644 --- a/virtcontainers/Makefile +++ b/virtcontainers/Makefile @@ -10,8 +10,6 @@ VC_BIN_DIR := $(BIN_DIR)/virtcontainers/bin TEST_BIN_DIR := $(VC_BIN_DIR)/test HOOK_DIR := hook/mock HOOK_BIN := hook -CC_SHIM_DIR := shim/mock/cc-shim -CC_SHIM_BIN := cc-shim KATA_SHIM_DIR := shim/mock/kata-shim KATA_SHIM_BIN := kata-shim MK_DIR := $(shell dirname $(realpath $(lastword $(MAKEFILE_LIST)))) @@ -36,13 +34,10 @@ build: hook: $(QUIET_GOBUILD)go build -o $(HOOK_DIR)/$@ $(HOOK_DIR)/*.go -cc-shim: - $(QUIET_GOBUILD)go build -o $(CC_SHIM_DIR)/$@ $(CC_SHIM_DIR)/*.go - kata-shim: $(QUIET_GOBUILD)go build -o $(KATA_SHIM_DIR)/$@ $(KATA_SHIM_DIR)/*.go -binaries: hook cc-shim kata-shim +binaries: hook kata-shim # # Tests @@ -55,7 +50,6 @@ check-go-static: check-go-test: bash $(MK_DIR)/../.ci/go-test.sh \ - $(TEST_BIN_DIR)/$(CC_SHIM_BIN) \ $(TEST_BIN_DIR)/$(KATA_SHIM_BIN) \ $(TEST_BIN_DIR)/$(HOOK_BIN) @@ -75,7 +69,6 @@ install: @mkdir -p $(VC_BIN_DIR) @mkdir -p $(TEST_BIN_DIR) $(call INSTALL_TEST_EXEC,$(HOOK_DIR)/$(HOOK_BIN)) - $(call INSTALL_TEST_EXEC,$(CC_SHIM_DIR)/$(CC_SHIM_BIN)) $(call INSTALL_TEST_EXEC,$(KATA_SHIM_DIR)/$(KATA_SHIM_BIN)) # @@ -92,7 +85,6 @@ endef uninstall: $(call UNINSTALL_TEST_EXEC,$(HOOK_BIN)) - $(call UNINSTALL_TEST_EXEC,$(CC_SHIM_BIN)) $(call UNINSTALL_TEST_EXEC,$(KATA_SHIM_BIN)) # @@ -106,7 +98,6 @@ $(shell test -e "$(1)" && test "$(1)" != "/" && echo "$(1)") endef CLEAN_FILES += $(HOOK_DIR)/$(HOOK_BIN) -CLEAN_FILES += $(SHIM_DIR)/$(CC_SHIM_BIN) CLEAN_FILES += $(SHIM_DIR)/$(KATA_SHIM_BIN) clean: diff --git a/virtcontainers/api_test.go b/virtcontainers/api_test.go index 23af6e7f8..b8e3c35bf 100644 --- a/virtcontainers/api_test.go +++ b/virtcontainers/api_test.go @@ -8,11 +8,9 @@ package virtcontainers import ( "context" "fmt" - "io/ioutil" "os" "path/filepath" "reflect" - "runtime" "strings" "syscall" "testing" @@ -133,18 +131,6 @@ func TestCreateSandboxNoopAgentSuccessful(t *testing.T) { } } -var testCCProxySockPathTempl = "%s/cc-proxy-test.sock" -var testCCProxyURLUnixScheme = "unix://" - -func testGenerateCCProxySockDir() (string, error) { - dir, err := ioutil.TempDir("", "cc-proxy-test") - if err != nil { - return "", err - } - - return dir, nil -} - func TestCreateSandboxKataAgentSuccessful(t *testing.T) { if os.Geteuid() != 0 { t.Skip(testDisabledAsNonRoot) @@ -1601,42 +1587,6 @@ func createNewSandboxConfig(hType HypervisorType, aType AgentType, aConfig inter } } -func createNewContainerConfigs(numOfContainers int) []ContainerConfig { - var contConfigs []ContainerConfig - - envs := []types.EnvVar{ - { - Var: "PATH", - Value: "/bin:/usr/bin:/sbin:/usr/sbin", - }, - } - - cmd := types.Cmd{ - Args: strings.Split("/bin/ps -A", " "), - Envs: envs, - WorkDir: "/", - } - - _, thisFile, _, ok := runtime.Caller(0) - if ok == false { - return nil - } - - rootFs := RootFs{Target: filepath.Dir(thisFile) + "/utils/supportfiles/bundles/busybox/", Mounted: true} - - for i := 0; i < numOfContainers; i++ { - contConfig := ContainerConfig{ - ID: fmt.Sprintf("%d", i), - RootFs: rootFs, - Cmd: cmd, - } - - contConfigs = append(contConfigs, contConfig) - } - - return contConfigs -} - // createAndStartSandbox handles the common test operation of creating and // starting a sandbox. func createAndStartSandbox(ctx context.Context, config SandboxConfig) (sandbox VCSandbox, sandboxDir string, @@ -1684,66 +1634,6 @@ func createStartStopDeleteSandbox(b *testing.B, sandboxConfig SandboxConfig) { } } -func createStartStopDeleteContainers(b *testing.B, sandboxConfig SandboxConfig, contConfigs []ContainerConfig) { - ctx := context.Background() - - // Create sandbox - p, err := CreateSandbox(ctx, sandboxConfig, nil) - if err != nil { - b.Fatalf("Could not create sandbox: %s", err) - } - - // Start sandbox - _, err = StartSandbox(ctx, p.ID()) - if err != nil { - b.Fatalf("Could not start sandbox: %s", err) - } - - // Create containers - for _, contConfig := range contConfigs { - _, _, err := CreateContainer(ctx, p.ID(), contConfig) - if err != nil { - b.Fatalf("Could not create container %s: %s", contConfig.ID, err) - } - } - - // Start containers - for _, contConfig := range contConfigs { - _, err := StartContainer(ctx, p.ID(), contConfig.ID) - if err != nil { - b.Fatalf("Could not start container %s: %s", contConfig.ID, err) - } - } - - // Stop containers - for _, contConfig := range contConfigs { - _, err := StopContainer(ctx, p.ID(), contConfig.ID) - if err != nil { - b.Fatalf("Could not stop container %s: %s", contConfig.ID, err) - } - } - - // Delete containers - for _, contConfig := range contConfigs { - _, err := DeleteContainer(ctx, p.ID(), contConfig.ID) - if err != nil { - b.Fatalf("Could not delete container %s: %s", contConfig.ID, err) - } - } - - // Stop sandbox - _, err = StopSandbox(ctx, p.ID()) - if err != nil { - b.Fatalf("Could not stop sandbox: %s", err) - } - - // Delete sandbox - _, err = DeleteSandbox(ctx, p.ID()) - if err != nil { - b.Fatalf("Could not delete sandbox: %s", err) - } -} - func BenchmarkCreateStartStopDeleteSandboxQemuHypervisorNoopAgentNetworkNoop(b *testing.B) { for i := 0; i < b.N; i++ { sandboxConfig := createNewSandboxConfig(QemuHypervisor, NoopAgentType, nil) diff --git a/virtcontainers/cc_proxy.go b/virtcontainers/cc_proxy.go deleted file mode 100644 index 0bfde4036..000000000 --- a/virtcontainers/cc_proxy.go +++ /dev/null @@ -1,47 +0,0 @@ -// Copyright (c) 2017 Intel Corporation -// -// SPDX-License-Identifier: Apache-2.0 -// - -package virtcontainers - -import "os/exec" - -type ccProxy struct { -} - -// start is the proxy start implementation for ccProxy. -func (p *ccProxy) start(params proxyParams) (int, string, error) { - if err := validateProxyParams(params); err != nil { - return -1, "", err - } - - params.logger.Debug("Starting cc proxy") - - // construct the socket path the proxy instance will use - proxyURL, err := defaultProxyURL(params.id, SocketTypeUNIX) - if err != nil { - return -1, "", err - } - - args := []string{params.path, "-uri", proxyURL} - if params.debug { - args = append(args, "-log", "debug") - } - - cmd := exec.Command(args[0], args[1:]...) - if err := cmd.Start(); err != nil { - return -1, "", err - } - - return cmd.Process.Pid, proxyURL, nil -} - -func (p *ccProxy) stop(pid int) error { - return nil -} - -// The ccproxy doesn't need to watch the vm console, thus return false always. -func (p *ccProxy) consoleWatched() bool { - return false -} diff --git a/virtcontainers/cc_proxy_test.go b/virtcontainers/cc_proxy_test.go deleted file mode 100644 index faa32e891..000000000 --- a/virtcontainers/cc_proxy_test.go +++ /dev/null @@ -1,28 +0,0 @@ -// Copyright (c) 2017 Intel Corporation -// -// SPDX-License-Identifier: Apache-2.0 -// - -package virtcontainers - -import ( - "testing" - - "github.com/stretchr/testify/assert" -) - -func TestCCProxyStart(t *testing.T) { - proxy := &ccProxy{} - - testProxyStart(t, nil, proxy) -} - -func TestCCProxy(t *testing.T) { - proxy := &ccProxy{} - assert := assert.New(t) - - err := proxy.stop(0) - assert.Nil(err) - - assert.False(proxy.consoleWatched()) -} diff --git a/virtcontainers/cc_shim.go b/virtcontainers/cc_shim.go deleted file mode 100644 index 6f16b4e81..000000000 --- a/virtcontainers/cc_shim.go +++ /dev/null @@ -1,49 +0,0 @@ -// Copyright (c) 2017 Intel Corporation -// -// SPDX-License-Identifier: Apache-2.0 -// - -package virtcontainers - -import ( - "fmt" -) - -type ccShim struct{} - -// start is the ccShim start implementation. -// It starts the cc-shim binary with URL and token flags provided by -// the proxy. -func (s *ccShim) start(sandbox *Sandbox, params ShimParams) (int, error) { - if sandbox.config == nil { - return -1, fmt.Errorf("Sandbox config cannot be nil") - } - - config, ok := newShimConfig(*(sandbox.config)).(ShimConfig) - if !ok { - return -1, fmt.Errorf("Wrong shim config type, should be CCShimConfig type") - } - - if config.Path == "" { - return -1, fmt.Errorf("Shim path cannot be empty") - } - - if params.Token == "" { - return -1, fmt.Errorf("Token cannot be empty") - } - - if params.URL == "" { - return -1, fmt.Errorf("URL cannot be empty") - } - - if params.Container == "" { - return -1, fmt.Errorf("Container cannot be empty") - } - - args := []string{config.Path, "-c", params.Container, "-t", params.Token, "-u", params.URL} - if config.Debug { - args = append(args, "-d") - } - - return startShim(args, params) -} diff --git a/virtcontainers/cc_shim_test.go b/virtcontainers/cc_shim_test.go deleted file mode 100644 index 3c6733998..000000000 --- a/virtcontainers/cc_shim_test.go +++ /dev/null @@ -1,357 +0,0 @@ -// Copyright (c) 2017 Intel Corporation -// -// SPDX-License-Identifier: Apache-2.0 -// - -package virtcontainers - -import ( - "fmt" - "io" - "io/ioutil" - "os" - "path/filepath" - "strings" - "syscall" - "testing" - "time" - "unsafe" - - . "github.com/kata-containers/runtime/virtcontainers/pkg/mock" -) - -// These tests don't care about the format of the container ID -const testContainer = "testContainer" - -var testCCShimPath = "/usr/bin/virtcontainers/bin/test/cc-shim" -var testProxyURL = "foo:///foo/clear-containers/proxy.sock" -var testWrongConsolePath = "/foo/wrong-console" - -func getMockCCShimBinPath() string { - if DefaultMockCCShimBinPath == "" { - return testCCShimPath - } - - return DefaultMockCCShimBinPath -} - -func testCCShimStart(t *testing.T, sandbox *Sandbox, params ShimParams, expectFail bool) { - s := &ccShim{} - - pid, err := s.start(sandbox, params) - if expectFail { - if err == nil || pid != -1 { - t.Fatalf("This test should fail (sandbox %+v, params %+v, expectFail %t)", - sandbox, params, expectFail) - } - } else { - if err != nil { - t.Fatalf("This test should pass (sandbox %+v, params %+v, expectFail %t): %s", - sandbox, params, expectFail, err) - } - - if pid == -1 { - t.Fatalf("This test should pass (sandbox %+v, params %+v, expectFail %t)", - sandbox, params, expectFail) - } - } -} - -func TestCCShimStartNilSandboxConfigFailure(t *testing.T) { - testCCShimStart(t, &Sandbox{}, ShimParams{}, true) -} - -func TestCCShimStartNilShimConfigFailure(t *testing.T) { - sandbox := &Sandbox{ - config: &SandboxConfig{}, - } - - testCCShimStart(t, sandbox, ShimParams{}, true) -} - -func TestCCShimStartShimPathEmptyFailure(t *testing.T) { - sandbox := &Sandbox{ - config: &SandboxConfig{ - ShimType: CCShimType, - ShimConfig: ShimConfig{}, - }, - } - - testCCShimStart(t, sandbox, ShimParams{}, true) -} - -func TestCCShimStartShimTypeInvalid(t *testing.T) { - sandbox := &Sandbox{ - config: &SandboxConfig{ - ShimType: "foo", - ShimConfig: ShimConfig{}, - }, - } - - testCCShimStart(t, sandbox, ShimParams{}, true) -} - -func TestCCShimStartParamsTokenEmptyFailure(t *testing.T) { - sandbox := &Sandbox{ - config: &SandboxConfig{ - ShimType: CCShimType, - ShimConfig: ShimConfig{ - Path: getMockCCShimBinPath(), - }, - }, - } - - testCCShimStart(t, sandbox, ShimParams{}, true) -} - -func TestCCShimStartParamsURLEmptyFailure(t *testing.T) { - sandbox := &Sandbox{ - config: &SandboxConfig{ - ShimType: CCShimType, - ShimConfig: ShimConfig{ - Path: getMockCCShimBinPath(), - }, - }, - } - - params := ShimParams{ - Token: "testToken", - } - - testCCShimStart(t, sandbox, params, true) -} - -func TestCCShimStartParamsContainerEmptyFailure(t *testing.T) { - sandbox := &Sandbox{ - config: &SandboxConfig{ - ShimType: CCShimType, - ShimConfig: ShimConfig{ - Path: getMockCCShimBinPath(), - }, - }, - } - - params := ShimParams{ - Token: "testToken", - URL: "unix://is/awesome", - } - - testCCShimStart(t, sandbox, params, true) -} - -func TestCCShimStartParamsInvalidCommand(t *testing.T) { - dir, err := ioutil.TempDir("", "") - if err != nil { - t.Fatal(err) - } - defer os.RemoveAll(dir) - - cmd := filepath.Join(dir, "does-not-exist") - - sandbox := &Sandbox{ - config: &SandboxConfig{ - ShimType: CCShimType, - ShimConfig: ShimConfig{ - Path: cmd, - }, - }, - } - - params := ShimParams{ - Token: "testToken", - URL: "http://foo", - } - - testCCShimStart(t, sandbox, params, true) -} - -func startCCShimStartWithoutConsoleSuccessful(t *testing.T, detach bool) (*os.File, *os.File, *os.File, *Sandbox, ShimParams, error) { - saveStdout := os.Stdout - rStdout, wStdout, err := os.Pipe() - if err != nil { - return nil, nil, nil, &Sandbox{}, ShimParams{}, err - } - - os.Stdout = wStdout - - sandbox := &Sandbox{ - config: &SandboxConfig{ - ShimType: CCShimType, - ShimConfig: ShimConfig{ - Path: getMockCCShimBinPath(), - }, - }, - } - - params := ShimParams{ - Container: testContainer, - Token: "testToken", - URL: testProxyURL, - Detach: detach, - } - - return rStdout, wStdout, saveStdout, sandbox, params, nil -} - -func TestCCShimStartSuccessful(t *testing.T) { - rStdout, wStdout, saveStdout, sandbox, params, err := startCCShimStartWithoutConsoleSuccessful(t, false) - if err != nil { - t.Fatal(err) - } - - defer func() { - os.Stdout = saveStdout - rStdout.Close() - wStdout.Close() - }() - - testCCShimStart(t, sandbox, params, false) - - bufStdout := make([]byte, 1024) - if _, err := rStdout.Read(bufStdout); err != nil { - t.Fatal(err) - } - - if !strings.Contains(string(bufStdout), ShimStdoutOutput) { - t.Fatalf("Substring %q not found in %q", ShimStdoutOutput, string(bufStdout)) - } -} - -func TestCCShimStartDetachSuccessful(t *testing.T) { - rStdout, wStdout, saveStdout, sandbox, params, err := startCCShimStartWithoutConsoleSuccessful(t, true) - if err != nil { - t.Fatal(err) - } - - defer func() { - os.Stdout = saveStdout - wStdout.Close() - rStdout.Close() - }() - - testCCShimStart(t, sandbox, params, false) - - readCh := make(chan error, 1) - go func() { - defer close(readCh) - bufStdout := make([]byte, 1024) - n, err := rStdout.Read(bufStdout) - if err != nil && err != io.EOF { - readCh <- err - return - } - - if n > 0 { - readCh <- fmt.Errorf("Not expecting to read anything, Got %q", string(bufStdout)) - return - } - - readCh <- nil - }() - - select { - case err := <-readCh: - if err != nil { - t.Fatal(err) - } - case <-time.After(time.Duration(20) * time.Millisecond): - return - } -} - -func TestCCShimStartWithConsoleNonExistingFailure(t *testing.T) { - sandbox := &Sandbox{ - config: &SandboxConfig{ - ShimType: CCShimType, - ShimConfig: ShimConfig{ - Path: getMockCCShimBinPath(), - }, - }, - } - - params := ShimParams{ - Token: "testToken", - URL: testProxyURL, - Console: testWrongConsolePath, - } - - testCCShimStart(t, sandbox, params, true) -} - -func ioctl(fd uintptr, flag, data uintptr) error { - if _, _, err := syscall.Syscall(syscall.SYS_IOCTL, fd, flag, data); err != 0 { - return err - } - - return nil -} - -// unlockpt unlocks the slave pseudoterminal device corresponding to the master pseudoterminal referred to by f. -func unlockpt(f *os.File) error { - var u int32 - - return ioctl(f.Fd(), syscall.TIOCSPTLCK, uintptr(unsafe.Pointer(&u))) -} - -// ptsname retrieves the name of the first available pts for the given master. -func ptsname(f *os.File) (string, error) { - var n int32 - - if err := ioctl(f.Fd(), syscall.TIOCGPTN, uintptr(unsafe.Pointer(&n))); err != nil { - return "", err - } - - return fmt.Sprintf("/dev/pts/%d", n), nil -} - -func newConsole() (*os.File, string, error) { - master, err := os.OpenFile("/dev/ptmx", syscall.O_RDWR|syscall.O_NOCTTY|syscall.O_CLOEXEC, 0) - if err != nil { - return nil, "", err - } - - console, err := ptsname(master) - if err != nil { - return nil, "", err - } - - if err := unlockpt(master); err != nil { - return nil, "", err - } - - if err := os.Chmod(console, 0600); err != nil { - return nil, "", err - } - - return master, console, nil -} - -func TestCCShimStartWithConsoleSuccessful(t *testing.T) { - defer cleanUp() - - master, console, err := newConsole() - t.Logf("Console created for tests:%s\n", console) - - if err != nil { - t.Fatal(err) - } - - sandbox := &Sandbox{ - config: &SandboxConfig{ - ShimType: CCShimType, - ShimConfig: ShimConfig{ - Path: getMockCCShimBinPath(), - }, - }, - } - - params := ShimParams{ - Container: testContainer, - Token: "testToken", - URL: testProxyURL, - Console: console, - } - - testCCShimStart(t, sandbox, params, false) - master.Close() -} diff --git a/virtcontainers/documentation/api/1.0/api.md b/virtcontainers/documentation/api/1.0/api.md index 46ce8f352..8785e6827 100644 --- a/virtcontainers/documentation/api/1.0/api.md +++ b/virtcontainers/documentation/api/1.0/api.md @@ -217,9 +217,6 @@ const ( // NoProxyType is the noProxy. NoProxyType ProxyType = "noProxy" - // CCProxyType is the ccProxy. - CCProxyType ProxyType = "ccProxy" - // KataProxyType is the kataProxy. KataProxyType ProxyType = "kataProxy" ) @@ -241,9 +238,6 @@ type ProxyConfig struct { type ShimType string const ( - // CCShimType is the ccShim. - CCShimType ShimType = "ccShim" - // NoopShimType is the noopShim. NoopShimType ShimType = "noopShim" diff --git a/virtcontainers/kata_shim_test.go b/virtcontainers/kata_shim_test.go index ec77383a2..f302cd83c 100644 --- a/virtcontainers/kata_shim_test.go +++ b/virtcontainers/kata_shim_test.go @@ -12,14 +12,23 @@ import ( "os" "path/filepath" "strings" + "syscall" "testing" "time" + "unsafe" . "github.com/kata-containers/runtime/virtcontainers/pkg/mock" ) -var testKataShimPath = "/usr/bin/virtcontainers/bin/test/kata-shim" -var testKataShimProxyURL = "foo:///foo/kata-containers/proxy.sock" +const ( + testContainer = "testContainer" +) + +var ( + testKataShimPath = "/usr/bin/virtcontainers/bin/test/kata-shim" + testKataShimProxyURL = "foo:///foo/kata-containers/proxy.sock" + testWrongConsolePath = "/foo/wrong-console" +) func getMockKataShimBinPath() string { if DefaultMockKataShimBinPath == "" { @@ -272,6 +281,54 @@ func TestKataShimStartWithConsoleNonExistingFailure(t *testing.T) { testKataShimStart(t, sandbox, params, true) } +func ioctl(fd uintptr, flag, data uintptr) error { + if _, _, err := syscall.Syscall(syscall.SYS_IOCTL, fd, flag, data); err != 0 { + return err + } + + return nil +} + +// unlockpt unlocks the slave pseudoterminal device corresponding to the master pseudoterminal referred to by f. +func unlockpt(f *os.File) error { + var u int32 + + return ioctl(f.Fd(), syscall.TIOCSPTLCK, uintptr(unsafe.Pointer(&u))) +} + +// ptsname retrieves the name of the first available pts for the given master. +func ptsname(f *os.File) (string, error) { + var n int32 + + if err := ioctl(f.Fd(), syscall.TIOCGPTN, uintptr(unsafe.Pointer(&n))); err != nil { + return "", err + } + + return fmt.Sprintf("/dev/pts/%d", n), nil +} + +func newConsole() (*os.File, string, error) { + master, err := os.OpenFile("/dev/ptmx", syscall.O_RDWR|syscall.O_NOCTTY|syscall.O_CLOEXEC, 0) + if err != nil { + return nil, "", err + } + + console, err := ptsname(master) + if err != nil { + return nil, "", err + } + + if err := unlockpt(master); err != nil { + return nil, "", err + } + + if err := os.Chmod(console, 0600); err != nil { + return nil, "", err + } + + return master, console, nil +} + func TestKataShimStartWithConsoleSuccessful(t *testing.T) { defer cleanUp() diff --git a/virtcontainers/network.go b/virtcontainers/network.go index 93b2f1195..eb766bf67 100644 --- a/virtcontainers/network.go +++ b/virtcontainers/network.go @@ -116,10 +116,8 @@ var DefaultNetInterworkingModel = NetXConnectMacVtapModel // Introduces constants related to networking const ( - defaultRouteDest = "0.0.0.0/0" - defaultRouteLabel = "default" - defaultFilePerms = 0600 - defaultQlen = 1500 + defaultFilePerms = 0600 + defaultQlen = 1500 ) // DNSInfo describes the DNS setup related to a network interface. diff --git a/virtcontainers/pkg/mock/cc_proxy_mock.go b/virtcontainers/pkg/mock/cc_proxy_mock.go deleted file mode 100644 index 3490bc0fd..000000000 --- a/virtcontainers/pkg/mock/cc_proxy_mock.go +++ /dev/null @@ -1,460 +0,0 @@ -// Copyright (c) 2018 Intel Corporation -// -// SPDX-License-Identifier: Apache-2.0 -// - -package mock - -import ( - "encoding/json" - "errors" - "fmt" - "io" - "net" - "os" - "sync" - "testing" - - "github.com/clearcontainers/proxy/api" - "github.com/stretchr/testify/assert" -) - -const testToken = "pF56IaDpuax6hihJ5PneB8JypqmOvjkqY-wKGVYqgIM=" - -// CCProxyMock is an object mocking clearcontainers Proxy -type CCProxyMock struct { - sync.Mutex - - t *testing.T - connectionPath string - - // proxy socket - listener net.Listener - - // single client to serve - cl net.Conn - - //token to be used for the connection - token string - - lastStdinStream []byte - - ShimConnected chan bool - Signal chan ShimSignal - ShimDisconnected chan bool - StdinReceived chan bool - - wg sync.WaitGroup - - stopped bool -} - -// NewCCProxyMock creates a hyperstart instance -func NewCCProxyMock(t *testing.T, path string) *CCProxyMock { - return &CCProxyMock{ - t: t, - connectionPath: path, - lastStdinStream: nil, - Signal: make(chan ShimSignal, 5), - ShimConnected: make(chan bool), - ShimDisconnected: make(chan bool), - StdinReceived: make(chan bool), - token: testToken, - } -} - -// GetProxyToken returns the token that mock proxy uses -// to verify its client connection -func (proxy *CCProxyMock) GetProxyToken() string { - return proxy.token -} - -// GetLastStdinStream returns the last received stdin stream -func (proxy *CCProxyMock) GetLastStdinStream() []byte { - return proxy.lastStdinStream -} - -func (proxy *CCProxyMock) log(s string) { - proxy.logF("%s\n", s) -} - -func (proxy *CCProxyMock) logF(format string, args ...interface{}) { - proxy.t.Logf("[CCProxyMock] "+format, args...) -} - -type client struct { - proxy *CCProxyMock - conn net.Conn -} - -// ConnectShim payload defined here, as it has not been defined -// in proxy api package yet -type ConnectShim struct { - Token string `json:"token"` -} - -// ShimSignal is the struct used to represent the signal received from the shim -type ShimSignal struct { - Signal int `json:"signalNumber"` - Row int `json:"rows,omitempty"` - Column int `json:"columns,omitempty"` -} - -func connectShimHandler(data []byte, userData interface{}, response *handlerResponse) { - client := userData.(*client) - proxy := client.proxy - - payload := ConnectShim{} - err := json.Unmarshal(data, &payload) - assert.Nil(proxy.t, err) - - if payload.Token != proxy.token { - response.SetErrorMsg("Invalid Token") - proxy.logF("Invalid Token (token=%s)", payload.Token) - } - - response.AddResult("version", api.Version) - proxy.ShimConnected <- true -} - -func signalShimHandler(data []byte, userData interface{}, response *handlerResponse) { - client := userData.(*client) - proxy := client.proxy - - signalPayload := ShimSignal{} - err := json.Unmarshal(data, &signalPayload) - assert.Nil(proxy.t, err) - - proxy.Signal <- signalPayload -} - -func disconnectShimHandler(data []byte, userData interface{}, response *handlerResponse) { - client := userData.(*client) - proxy := client.proxy - - proxy.ShimDisconnected <- true -} - -func stdinShimHandler(data []byte, userData interface{}, response *handlerResponse) { - client := userData.(*client) - proxy := client.proxy - - proxy.lastStdinStream = data - proxy.StdinReceived <- true -} - -func registerVMHandler(data []byte, userData interface{}, response *handlerResponse) { - client := userData.(*client) - proxy := client.proxy - - payload := api.RegisterVM{} - if err := json.Unmarshal(data, &payload); err != nil { - proxy.logF("Register VM failed (%s)", err) - response.SetError(err) - return - } - - // Generate fake tokens - var tokens []string - for i := 0; i < payload.NumIOStreams; i++ { - tokens = append(tokens, fmt.Sprintf("%d", i)) - } - - io := &api.IOResponse{ - Tokens: tokens, - } - - response.AddResult("io", io) -} - -func unregisterVMHandler(data []byte, userData interface{}, response *handlerResponse) { -} - -func attachVMHandler(data []byte, userData interface{}, response *handlerResponse) { - client := userData.(*client) - proxy := client.proxy - - payload := api.AttachVM{} - if err := json.Unmarshal(data, &payload); err != nil { - proxy.logF("Attach VM failed (%s)", err) - response.SetError(err) - return - } - - // Generate fake tokens - var tokens []string - for i := 0; i < payload.NumIOStreams; i++ { - tokens = append(tokens, fmt.Sprintf("%d", i)) - } - - io := &api.IOResponse{ - Tokens: tokens, - } - - response.AddResult("io", io) -} - -func hyperCmdHandler(data []byte, userData interface{}, response *handlerResponse) { - response.SetData([]byte{}) -} - -// SendStdoutStream sends a Stdout Stream Frame to connected client -func (proxy *CCProxyMock) SendStdoutStream(payload []byte) { - err := api.WriteStream(proxy.cl, api.StreamStdout, payload) - assert.Nil(proxy.t, err) -} - -// SendStderrStream sends a Stderr Stream Frame to connected client -func (proxy *CCProxyMock) SendStderrStream(payload []byte) { - err := api.WriteStream(proxy.cl, api.StreamStderr, payload) - assert.Nil(proxy.t, err) -} - -// SendExitNotification sends an Exit Notification Frame to connected client -func (proxy *CCProxyMock) SendExitNotification(payload []byte) { - err := api.WriteNotification(proxy.cl, api.NotificationProcessExited, payload) - assert.Nil(proxy.t, err) -} - -func (proxy *CCProxyMock) startListening() { - - l, err := net.ListenUnix("unix", &net.UnixAddr{Name: proxy.connectionPath, Net: "unix"}) - assert.Nil(proxy.t, err) - - proxy.listener = l -} - -func (proxy *CCProxyMock) serveClient(proto *ccProxyProtocol, newConn net.Conn) { - newClient := &client{ - proxy: proxy, - conn: newConn, - } - if err := proto.Serve(newConn, newClient); err != nil && err != io.EOF { - proxy.logF("Error serving client : %v\n", err) - } - - newConn.Close() - - proxy.wg.Done() -} - -func (proxy *CCProxyMock) serve() { - proto := newCCProxyProtocol() - - // shim handlers - proto.Handle(FrameKey{api.TypeCommand, int(api.CmdConnectShim)}, connectShimHandler) - proto.Handle(FrameKey{api.TypeCommand, int(api.CmdDisconnectShim)}, disconnectShimHandler) - proto.Handle(FrameKey{api.TypeStream, int(api.StreamStdin)}, stdinShimHandler) - - // runtime handlers - proto.Handle(FrameKey{api.TypeCommand, int(api.CmdRegisterVM)}, registerVMHandler) - proto.Handle(FrameKey{api.TypeCommand, int(api.CmdUnregisterVM)}, unregisterVMHandler) - proto.Handle(FrameKey{api.TypeCommand, int(api.CmdAttachVM)}, attachVMHandler) - proto.Handle(FrameKey{api.TypeCommand, int(api.CmdHyper)}, hyperCmdHandler) - - // Shared handler between shim and runtime - proto.Handle(FrameKey{api.TypeCommand, int(api.CmdSignal)}, signalShimHandler) - - //Wait for a single client connection - conn, err := proxy.listener.Accept() - if err != nil { - // Ending up into this case when the listener is closed, which - // is still a valid case. We don't want to throw an error in - // this case. - return - } - - assert.NotNil(proxy.t, conn) - - proxy.wg.Add(1) - - proxy.cl = conn - - proxy.serveClient(proto, conn) -} - -// Start invokes mock proxy instance to start listening. -func (proxy *CCProxyMock) Start() { - proxy.stopped = false - proxy.startListening() - go func() { - for { - proxy.serve() - - proxy.Lock() - stopped := proxy.stopped - proxy.Unlock() - - if stopped { - break - } - } - }() -} - -// Stop causes mock proxy instance to stop listening, -// close connection to client and close all channels -func (proxy *CCProxyMock) Stop() { - proxy.Lock() - proxy.stopped = true - proxy.Unlock() - - proxy.listener.Close() - - if proxy.cl != nil { - proxy.cl.Close() - proxy.cl = nil - } else { - proxy.log("Client connection already closed") - } - - proxy.wg.Wait() - close(proxy.ShimConnected) - close(proxy.Signal) - close(proxy.ShimDisconnected) - close(proxy.StdinReceived) - os.Remove(proxy.connectionPath) -} - -// XXX: could do with its own package to remove that ugly namespacing -type ccProxyProtocolHandler func([]byte, interface{}, *handlerResponse) - -// Encapsulates the different parts of what a handler can return. -type handlerResponse struct { - err error - results map[string]interface{} - data []byte -} - -// SetError indicates sets error for the response. -func (r *handlerResponse) SetError(err error) { - r.err = err -} - -// SetErrorMsg sets an error with the passed string for the response. -func (r *handlerResponse) SetErrorMsg(msg string) { - r.err = errors.New(msg) -} - -// SetErrorf sets an error with the formatted string for the response. -func (r *handlerResponse) SetErrorf(format string, a ...interface{}) { - r.SetError(fmt.Errorf(format, a...)) -} - -// AddResult adds the given key/val to the response. -func (r *handlerResponse) AddResult(key string, value interface{}) { - if r.results == nil { - r.results = make(map[string]interface{}) - } - r.results[key] = value -} - -func (r *handlerResponse) SetData(data []byte) { - r.data = data -} - -// FrameKey is a struct composed of the the frame type and opcode, -// used as a key for retrieving the handler for handling the frame. -type FrameKey struct { - ftype api.FrameType - opcode int -} - -type ccProxyProtocol struct { - cmdHandlers map[FrameKey]ccProxyProtocolHandler -} - -func newCCProxyProtocol() *ccProxyProtocol { - return &ccProxyProtocol{ - cmdHandlers: make(map[FrameKey]ccProxyProtocolHandler), - } -} - -// Handle retreives the handler for handling the frame -func (proto *ccProxyProtocol) Handle(key FrameKey, handler ccProxyProtocolHandler) bool { - if _, ok := proto.cmdHandlers[key]; ok { - return false - } - proto.cmdHandlers[key] = handler - return true -} - -type clientCtx struct { - conn net.Conn - userData interface{} -} - -func newErrorResponse(opcode int, errMsg string) *api.Frame { - frame, err := api.NewFrameJSON(api.TypeResponse, opcode, &api.ErrorResponse{ - Message: errMsg, - }) - - if err != nil { - frame, err = api.NewFrameJSON(api.TypeResponse, opcode, &api.ErrorResponse{ - Message: fmt.Sprintf("couldn't marshal response: %v", err), - }) - if err != nil { - frame = api.NewFrame(api.TypeResponse, opcode, nil) - } - } - - frame.Header.InError = true - return frame -} - -func (proto *ccProxyProtocol) handleCommand(ctx *clientCtx, cmd *api.Frame) *api.Frame { - hr := handlerResponse{} - - // cmd.Header.Opcode is guaranteed to be within the right bounds by - // ReadFrame(). - handler := proto.cmdHandlers[FrameKey{cmd.Header.Type, cmd.Header.Opcode}] - - handler(cmd.Payload, ctx.userData, &hr) - if hr.err != nil { - return newErrorResponse(cmd.Header.Opcode, hr.err.Error()) - } - - var payload interface{} - if len(hr.results) > 0 { - payload = hr.results - } - - frame, err := api.NewFrameJSON(api.TypeResponse, cmd.Header.Opcode, payload) - if err != nil { - return newErrorResponse(cmd.Header.Opcode, err.Error()) - } - return frame -} - -// Serve serves the client connection in a continuous loop. -func (proto *ccProxyProtocol) Serve(conn net.Conn, userData interface{}) error { - ctx := &clientCtx{ - conn: conn, - userData: userData, - } - - for { - frame, err := api.ReadFrame(conn) - if err != nil { - // EOF or the client isn't even sending proper JSON, - // just kill the connection - return err - } - - if frame.Header.Type != api.TypeCommand && frame.Header.Type != api.TypeStream { - // EOF or the client isn't even sending proper JSON, - // just kill the connection - return fmt.Errorf("serve: expected a command got a %v", frame.Header.Type) - } - - // Execute the corresponding handler - resp := proto.handleCommand(ctx, frame) - - // Send the response back to the client. - if err = api.WriteFrame(conn, resp); err != nil { - // Something made us unable to write the response back - // to the client (could be a disconnection, ...). - return err - } - } -} diff --git a/virtcontainers/pkg/mock/mock.go b/virtcontainers/pkg/mock/mock.go index d8b03ea08..2085b414d 100644 --- a/virtcontainers/pkg/mock/mock.go +++ b/virtcontainers/pkg/mock/mock.go @@ -17,9 +17,6 @@ import ( "google.golang.org/grpc" ) -// DefaultMockCCShimBinPath is populated at link time. -var DefaultMockCCShimBinPath string - // DefaultMockKataShimBinPath is populated at link time. var DefaultMockKataShimBinPath string diff --git a/virtcontainers/pkg/oci/utils_test.go b/virtcontainers/pkg/oci/utils_test.go index ea6de017a..700d4863b 100644 --- a/virtcontainers/pkg/oci/utils_test.go +++ b/virtcontainers/pkg/oci/utils_test.go @@ -107,9 +107,9 @@ func TestMinimalSandboxConfig(t *testing.T) { runtimeConfig := RuntimeConfig{ HypervisorType: vc.QemuHypervisor, - AgentType: vc.HyperstartAgent, - ProxyType: vc.CCProxyType, - ShimType: vc.CCShimType, + AgentType: vc.KataContainersAgent, + ProxyType: vc.KataProxyType, + ShimType: vc.KataShimType, Console: consolePath, } @@ -222,9 +222,9 @@ func TestMinimalSandboxConfig(t *testing.T) { Hostname: "testHostname", HypervisorType: vc.QemuHypervisor, - AgentType: vc.HyperstartAgent, - ProxyType: vc.CCProxyType, - ShimType: vc.CCShimType, + AgentType: vc.KataContainersAgent, + ProxyType: vc.KataProxyType, + ShimType: vc.KataShimType, NetworkConfig: expectedNetworkConfig, diff --git a/virtcontainers/proxy.go b/virtcontainers/proxy.go index 051c8c1ff..46c266d30 100644 --- a/virtcontainers/proxy.go +++ b/virtcontainers/proxy.go @@ -41,9 +41,6 @@ const ( // NoProxyType is the noProxy. NoProxyType ProxyType = "noProxy" - // CCProxyType is the ccProxy. - CCProxyType ProxyType = "ccProxy" - // KataProxyType is the kataProxy. KataProxyType ProxyType = "kataProxy" @@ -51,12 +48,6 @@ const ( KataBuiltInProxyType ProxyType = "kataBuiltInProxy" ) -const ( - // Number of seconds to wait for the proxy to respond to a connection - // request. - waitForProxyTimeoutSecs = 5.0 -) - const ( // unix socket type of console consoleProtoUnix = "unix" @@ -74,9 +65,6 @@ func (pType *ProxyType) Set(value string) error { case "noProxy": *pType = NoProxyType return nil - case "ccProxy": - *pType = CCProxyType - return nil case "kataProxy": *pType = KataProxyType return nil @@ -95,8 +83,6 @@ func (pType *ProxyType) String() string { return string(NoopProxyType) case NoProxyType: return string(NoProxyType) - case CCProxyType: - return string(CCProxyType) case KataProxyType: return string(KataProxyType) case KataBuiltInProxyType: @@ -115,8 +101,6 @@ func newProxy(pType ProxyType) (proxy, error) { return &noopProxy{}, nil case NoProxyType: return &noProxy{}, nil - case CCProxyType: - return &ccProxy{}, nil case KataProxyType: return &kataProxy{}, nil case KataBuiltInProxyType: diff --git a/virtcontainers/proxy_test.go b/virtcontainers/proxy_test.go index 21cbf7d0d..3f4a04a5d 100644 --- a/virtcontainers/proxy_test.go +++ b/virtcontainers/proxy_test.go @@ -33,10 +33,6 @@ func testSetProxyType(t *testing.T, value string, expected ProxyType) { } } -func TestSetCCProxyType(t *testing.T) { - testSetProxyType(t, "ccProxy", CCProxyType) -} - func TestSetKataProxyType(t *testing.T) { testSetProxyType(t, "kataProxy", KataProxyType) } @@ -63,8 +59,7 @@ func TestSetUnknownProxyType(t *testing.T) { t.Fatalf("Should fail because %s type used", unknownType) } - if proxyType == CCProxyType || - proxyType == NoopProxyType || + if proxyType == NoopProxyType || proxyType == NoProxyType || proxyType == KataProxyType { t.Fatalf("%s proxy type was not expected", proxyType) @@ -78,11 +73,6 @@ func testStringFromProxyType(t *testing.T, proxyType ProxyType, expected string) } } -func TestStringFromCCProxyType(t *testing.T) { - proxyType := CCProxyType - testStringFromProxyType(t, proxyType, "ccProxy") -} - func TestStringFromKataProxyType(t *testing.T) { proxyType := KataProxyType testStringFromProxyType(t, proxyType, "kataProxy") @@ -119,12 +109,6 @@ func testNewProxyFromProxyType(t *testing.T, proxyType ProxyType, expected proxy } } -func TestNewProxyFromCCProxyType(t *testing.T) { - proxyType := CCProxyType - expectedProxy := &ccProxy{} - testNewProxyFromProxyType(t, proxyType, expectedProxy) -} - func TestNewProxyFromKataProxyType(t *testing.T) { proxyType := KataProxyType expectedProxy := &kataProxy{} @@ -171,19 +155,6 @@ func testNewProxyFromSandboxConfig(t *testing.T, sandboxConfig SandboxConfig) { var testProxyPath = "proxy-path" -func TestNewProxyConfigFromCCProxySandboxConfig(t *testing.T) { - proxyConfig := ProxyConfig{ - Path: testProxyPath, - } - - sandboxConfig := SandboxConfig{ - ProxyType: CCProxyType, - ProxyConfig: proxyConfig, - } - - testNewProxyFromSandboxConfig(t, sandboxConfig) -} - func TestNewProxyConfigFromKataProxySandboxConfig(t *testing.T) { proxyConfig := ProxyConfig{ Path: testProxyPath, diff --git a/virtcontainers/shim.go b/virtcontainers/shim.go index 77ef44b17..5f5b73ff1 100644 --- a/virtcontainers/shim.go +++ b/virtcontainers/shim.go @@ -22,9 +22,6 @@ import ( type ShimType string const ( - // CCShimType is the ccShim. - CCShimType ShimType = "ccShim" - // NoopShimType is the noopShim. NoopShimType ShimType = "noopShim" @@ -65,8 +62,6 @@ func (pType *ShimType) Set(value string) error { switch value { case "noopShim": *pType = NoopShimType - case "ccShim": - *pType = CCShimType case "kataShim": *pType = KataShimType case "kataBuiltInShim": @@ -82,8 +77,6 @@ func (pType *ShimType) String() string { switch *pType { case NoopShimType: return string(NoopShimType) - case CCShimType: - return string(CCShimType) case KataShimType: return string(KataShimType) case KataBuiltInShimType: @@ -98,8 +91,6 @@ func newShim(pType ShimType) (shim, error) { switch pType { case NoopShimType: return &noopShim{}, nil - case CCShimType: - return &ccShim{}, nil case KataShimType: return &kataShim{}, nil case KataBuiltInShimType: @@ -114,7 +105,7 @@ func newShimConfig(config SandboxConfig) interface{} { switch config.ShimType { case NoopShimType, KataBuiltInShimType: return nil - case CCShimType, KataShimType: + case KataShimType: var shimConfig ShimConfig err := mapstructure.Decode(config.ShimConfig, &shimConfig) if err != nil { diff --git a/virtcontainers/shim/mock/cc-shim/shim.go b/virtcontainers/shim/mock/cc-shim/shim.go deleted file mode 100644 index 8504c84ec..000000000 --- a/virtcontainers/shim/mock/cc-shim/shim.go +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright (c) 2017 Intel Corporation -// -// SPDX-License-Identifier: Apache-2.0 -// - -package main - -import ( - "github.com/kata-containers/runtime/virtcontainers/pkg/mock" -) - -func main() { - config := mock.ShimMockConfig{ - Name: "cc-shim", - URLParamName: "u", - ContainerParamName: "c", - TokenParamName: "t", - } - - mock.StartShim(config) -} diff --git a/virtcontainers/shim_test.go b/virtcontainers/shim_test.go index 22d5cc49b..7ab46dbe3 100644 --- a/virtcontainers/shim_test.go +++ b/virtcontainers/shim_test.go @@ -29,10 +29,6 @@ func testSetShimType(t *testing.T, value string, expected ShimType) { } } -func TestSetCCShimType(t *testing.T) { - testSetShimType(t, "ccShim", CCShimType) -} - func TestSetKataShimType(t *testing.T) { testSetShimType(t, "kataShim", KataShimType) } @@ -51,7 +47,7 @@ func TestSetUnknownShimType(t *testing.T) { t.Fatalf("Should fail because %s type used", unknownType) } - if shimType == CCShimType || shimType == NoopShimType { + if shimType == NoopShimType { t.Fatalf("%s shim type was not expected", shimType) } } @@ -63,11 +59,6 @@ func testStringFromShimType(t *testing.T, shimType ShimType, expected string) { } } -func TestStringFromCCShimType(t *testing.T) { - shimType := CCShimType - testStringFromShimType(t, shimType, "ccShim") -} - func TestStringFromKataShimType(t *testing.T) { shimType := KataShimType testStringFromShimType(t, shimType, "kataShim") @@ -99,12 +90,6 @@ func testNewShimFromShimType(t *testing.T, shimType ShimType, expected shim) { } } -func TestNewShimFromCCShimType(t *testing.T) { - shimType := CCShimType - expectedShim := &ccShim{} - testNewShimFromShimType(t, shimType, expectedShim) -} - func TestNewShimFromKataShimType(t *testing.T) { shimType := KataShimType expectedShim := &kataShim{} @@ -140,17 +125,6 @@ func testNewShimConfigFromSandboxConfig(t *testing.T, sandboxConfig SandboxConfi } } -func TestNewShimConfigFromCCShimSandboxConfig(t *testing.T) { - shimConfig := ShimConfig{} - - sandboxConfig := SandboxConfig{ - ShimType: CCShimType, - ShimConfig: shimConfig, - } - - testNewShimConfigFromSandboxConfig(t, sandboxConfig, shimConfig) -} - func TestNewShimConfigFromKataShimSandboxConfig(t *testing.T) { shimConfig := ShimConfig{}