mirror of
https://github.com/kata-containers/kata-containers.git
synced 2025-04-30 20:54:26 +00:00
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:
parent
7516a8c51b
commit
834e199eee
@ -20,12 +20,6 @@ type sandboxCache struct {
|
|||||||
sandboxes map[string]sandboxKubeData
|
sandboxes map[string]sandboxKubeData
|
||||||
}
|
}
|
||||||
|
|
||||||
func (sc *sandboxCache) getSandboxes() map[string]sandboxKubeData {
|
|
||||||
sc.Lock()
|
|
||||||
defer sc.Unlock()
|
|
||||||
return sc.sandboxes
|
|
||||||
}
|
|
||||||
|
|
||||||
func (sc *sandboxCache) getSandboxList() []string {
|
func (sc *sandboxCache) getSandboxList() []string {
|
||||||
sc.Lock()
|
sc.Lock()
|
||||||
defer sc.Unlock()
|
defer sc.Unlock()
|
||||||
@ -68,9 +62,3 @@ func (sc *sandboxCache) setMetadata(id string, value sandboxKubeData) {
|
|||||||
|
|
||||||
sc.sandboxes[id] = value
|
sc.sandboxes[id] = value
|
||||||
}
|
}
|
||||||
|
|
||||||
func (sc *sandboxCache) set(sandboxes map[string]sandboxKubeData) {
|
|
||||||
sc.Lock()
|
|
||||||
defer sc.Unlock()
|
|
||||||
sc.sandboxes = sandboxes
|
|
||||||
}
|
|
||||||
|
@ -16,21 +16,16 @@ func TestSandboxCache(t *testing.T) {
|
|||||||
assert := assert.New(t)
|
assert := assert.New(t)
|
||||||
sc := &sandboxCache{
|
sc := &sandboxCache{
|
||||||
Mutex: &sync.Mutex{},
|
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"}}
|
assert.Equal(1, len(sc.getSandboxList()))
|
||||||
|
|
||||||
sc.set(scMap)
|
|
||||||
|
|
||||||
scMap = sc.getSandboxes()
|
|
||||||
assert.Equal(1, len(scMap))
|
|
||||||
|
|
||||||
// put new item
|
// put new item
|
||||||
id := "new-id"
|
id := "new-id"
|
||||||
b := sc.putIfNotExists(id, sandboxKubeData{})
|
b := sc.putIfNotExists(id, sandboxKubeData{})
|
||||||
assert.Equal(true, b)
|
assert.Equal(true, b)
|
||||||
assert.Equal(2, len(scMap))
|
assert.Equal(2, len(sc.getSandboxList()))
|
||||||
|
|
||||||
// put key that alreay exists
|
// put key that alreay exists
|
||||||
b = sc.putIfNotExists(id, sandboxKubeData{})
|
b = sc.putIfNotExists(id, sandboxKubeData{})
|
||||||
@ -38,9 +33,9 @@ func TestSandboxCache(t *testing.T) {
|
|||||||
|
|
||||||
b = sc.deleteIfExists(id)
|
b = sc.deleteIfExists(id)
|
||||||
assert.Equal(true, b)
|
assert.Equal(true, b)
|
||||||
assert.Equal(1, len(scMap))
|
assert.Equal(1, len(sc.getSandboxList()))
|
||||||
|
|
||||||
b = sc.deleteIfExists(id)
|
b = sc.deleteIfExists(id)
|
||||||
assert.Equal(false, b)
|
assert.Equal(false, b)
|
||||||
assert.Equal(1, len(scMap))
|
assert.Equal(1, len(sc.getSandboxList()))
|
||||||
}
|
}
|
||||||
|
@ -10,8 +10,6 @@ import (
|
|||||||
"io"
|
"io"
|
||||||
"net"
|
"net"
|
||||||
"net/http"
|
"net/http"
|
||||||
"os"
|
|
||||||
"path/filepath"
|
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
cdshim "github.com/containerd/containerd/runtime/v2/shim"
|
cdshim "github.com/containerd/containerd/runtime/v2/shim"
|
||||||
@ -43,13 +41,6 @@ func getSandboxFS() string {
|
|||||||
return shim.GetSandboxesStoragePath()
|
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
|
// BuildShimClient builds and returns an http client for communicating with the provided sandbox
|
||||||
func BuildShimClient(sandboxID string, timeout time.Duration) (*http.Client, error) {
|
func BuildShimClient(sandboxID string, timeout time.Duration) (*http.Client, error) {
|
||||||
return buildUnixSocketClient(shim.SocketAddress(sandboxID), timeout)
|
return buildUnixSocketClient(shim.SocketAddress(sandboxID), timeout)
|
||||||
|
Loading…
Reference in New Issue
Block a user