kata-monitor: drop unused functions

Drop the functions we are not using anymore.
Update the tests too.

Signed-off-by: Francesco Giudici <fgiudici@redhat.com>
This commit is contained in:
Francesco Giudici 2022-01-25 11:13:44 +01:00
parent 7516a8c51b
commit 834e199eee
3 changed files with 5 additions and 31 deletions

View File

@ -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
}

View File

@ -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()))
}

View File

@ -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)