diff --git a/src/runtime/pkg/kata-monitor/sandbox_cache.go b/src/runtime/pkg/kata-monitor/sandbox_cache.go index f4f542b41a..4e3e778455 100644 --- a/src/runtime/pkg/kata-monitor/sandbox_cache.go +++ b/src/runtime/pkg/kata-monitor/sandbox_cache.go @@ -20,12 +20,6 @@ type sandboxCache struct { sandboxes map[string]sandboxKubeData } -func (sc *sandboxCache) getSandboxes() map[string]sandboxKubeData { - sc.Lock() - defer sc.Unlock() - return sc.sandboxes -} - func (sc *sandboxCache) getSandboxList() []string { sc.Lock() defer sc.Unlock() @@ -68,9 +62,3 @@ func (sc *sandboxCache) setMetadata(id string, value sandboxKubeData) { sc.sandboxes[id] = value } - -func (sc *sandboxCache) set(sandboxes map[string]sandboxKubeData) { - sc.Lock() - defer sc.Unlock() - sc.sandboxes = sandboxes -} diff --git a/src/runtime/pkg/kata-monitor/sandbox_cache_test.go b/src/runtime/pkg/kata-monitor/sandbox_cache_test.go index 6dd2e78943..4eedf778ad 100644 --- a/src/runtime/pkg/kata-monitor/sandbox_cache_test.go +++ b/src/runtime/pkg/kata-monitor/sandbox_cache_test.go @@ -16,21 +16,16 @@ func TestSandboxCache(t *testing.T) { assert := assert.New(t) sc := &sandboxCache{ Mutex: &sync.Mutex{}, - sandboxes: make(map[string]sandboxKubeData), + sandboxes: map[string]sandboxKubeData{"111": {"1-2-3", "test-name", "test-namespace"}}, } - scMap := map[string]sandboxKubeData{"111": {"1-2-3", "test-name", "test-namespace"}} - - sc.set(scMap) - - scMap = sc.getSandboxes() - assert.Equal(1, len(scMap)) + assert.Equal(1, len(sc.getSandboxList())) // put new item id := "new-id" b := sc.putIfNotExists(id, sandboxKubeData{}) assert.Equal(true, b) - assert.Equal(2, len(scMap)) + assert.Equal(2, len(sc.getSandboxList())) // put key that alreay exists b = sc.putIfNotExists(id, sandboxKubeData{}) @@ -38,9 +33,9 @@ func TestSandboxCache(t *testing.T) { b = sc.deleteIfExists(id) assert.Equal(true, b) - assert.Equal(1, len(scMap)) + assert.Equal(1, len(sc.getSandboxList())) b = sc.deleteIfExists(id) assert.Equal(false, b) - assert.Equal(1, len(scMap)) + assert.Equal(1, len(sc.getSandboxList())) } diff --git a/src/runtime/pkg/kata-monitor/shim_client.go b/src/runtime/pkg/kata-monitor/shim_client.go index 31043c847b..bdb62d401b 100644 --- a/src/runtime/pkg/kata-monitor/shim_client.go +++ b/src/runtime/pkg/kata-monitor/shim_client.go @@ -10,8 +10,6 @@ import ( "io" "net" "net/http" - "os" - "path/filepath" "time" cdshim "github.com/containerd/containerd/runtime/v2/shim" @@ -43,13 +41,6 @@ func getSandboxFS() string { return shim.GetSandboxesStoragePath() } -func checkSandboxFSExists(sandboxID string) bool { - sbsPath := filepath.Join(string(filepath.Separator), getSandboxFS(), sandboxID) - _, err := os.Stat(sbsPath) - - return !os.IsNotExist(err) -} - // BuildShimClient builds and returns an http client for communicating with the provided sandbox func BuildShimClient(sandboxID string, timeout time.Duration) (*http.Client, error) { return buildUnixSocketClient(shim.SocketAddress(sandboxID), timeout)