add sandbox deletor to delete sandboxes on pod delete event

This commit is contained in:
Keerthan Reddy,Mala
2020-07-05 15:54:02 -07:00
parent d4325f42fb
commit 90cc954eed
13 changed files with 338 additions and 18 deletions

View File

@@ -114,6 +114,8 @@ type Runtime interface {
GetContainerLogs(ctx context.Context, pod *v1.Pod, containerID ContainerID, logOptions *v1.PodLogOptions, stdout, stderr io.Writer) (err error)
// Delete a container. If the container is still running, an error is returned.
DeleteContainer(containerID ContainerID) error
// Delete a sandbox. If the container is still running, an error is returned.
DeleteSandbox(sandboxID string) error
// ImageService provides methods to image-related methods.
ImageService
// UpdatePodCIDR sends a new podCIDR to the runtime.
@@ -308,6 +310,8 @@ type Status struct {
ID ContainerID
// Name of the container.
Name string
// ID of the sandbox to which this container belongs.
PodSandboxId string
// Status of the container.
State State
// Creation time of the container.

View File

@@ -364,6 +364,14 @@ func (f *FakeRuntime) DeleteContainer(containerID kubecontainer.ContainerID) err
return f.Err
}
func (f *FakeRuntime) DeleteSandbox(sandboxID string) error {
f.Lock()
defer f.Unlock()
f.CalledFunctions = append(f.CalledFunctions, "DeleteSandbox")
return f.Err
}
func (f *FakeRuntime) ImageStats() (*kubecontainer.ImageStats, error) {
f.Lock()
defer f.Unlock()

View File

@@ -147,6 +147,11 @@ func (r *Mock) DeleteContainer(containerID kubecontainer.ContainerID) error {
return args.Error(0)
}
func (r *Mock) DeleteSandbox(sandboxID string) error {
args := r.Called(sandboxID)
return args.Error(0)
}
func (r *Mock) ImageStats() (*kubecontainer.ImageStats, error) {
args := r.Called()
return args.Get(0).(*kubecontainer.ImageStats), args.Error(1)