From f715aa475c6070ecdf876471f627b0bf4f32566f Mon Sep 17 00:00:00 2001 From: Tamer Tas Date: Tue, 16 Aug 2016 00:36:45 +0300 Subject: [PATCH] kubelet/api: extract ContainerManager interface --- pkg/kubelet/api/services.go | 42 +++++++++++++++++++++---------------- 1 file changed, 24 insertions(+), 18 deletions(-) diff --git a/pkg/kubelet/api/services.go b/pkg/kubelet/api/services.go index 94a37f999ca..06b8f16bf00 100644 --- a/pkg/kubelet/api/services.go +++ b/pkg/kubelet/api/services.go @@ -28,24 +28,9 @@ type RuntimeVersioner interface { Version(apiVersion string) (*runtimeApi.VersionResponse, error) } -// RuntimeService interface should be implemented by a container runtime. -// The methods should be thread-safe. -type RuntimeService interface { - RuntimeVersioner - - // CreatePodSandbox creates a pod-level sandbox. - // The definition of PodSandbox is at https://github.com/kubernetes/kubernetes/pull/25899 - CreatePodSandbox(config *runtimeApi.PodSandboxConfig) (string, error) - // StopPodSandbox stops the sandbox. If there are any running containers in the - // sandbox, they should be force terminated. - StopPodSandbox(podSandboxID string) error - // RemovePodSandbox removes the sandbox. If there are running containers in the - // sandbox, they should be forcibly removed. - RemovePodSandbox(podSandboxID string) error - // PodSandboxStatus returns the Status of the PodSandbox. - PodSandboxStatus(podSandboxID string) (*runtimeApi.PodSandboxStatus, error) - // ListPodSandbox returns a list of Sandbox. - ListPodSandbox(filter *runtimeApi.PodSandboxFilter) ([]*runtimeApi.PodSandbox, error) +// ContainerManager contains methods to manipulate containers managed by a +// container runtime. The methods are thread-safe. +type ContainerManager interface { // CreateContainer creates a new container in specified PodSandbox. CreateContainer(podSandboxID string, config *runtimeApi.ContainerConfig, sandboxConfig *runtimeApi.PodSandboxConfig) (string, error) // StartContainer starts the container. @@ -62,6 +47,27 @@ type RuntimeService interface { Exec(containerID string, cmd []string, tty bool, stdin io.Reader, stdout, stderr io.WriteCloser) error } +// RuntimeService interface should be implemented by a container runtime. +// The methods should be thread-safe. +type RuntimeService interface { + RuntimeVersioner + ContainerManager + + // CreatePodSandbox creates a pod-level sandbox. + // The definition of PodSandbox is at https://github.com/kubernetes/kubernetes/pull/25899 + CreatePodSandbox(config *runtimeApi.PodSandboxConfig) (string, error) + // StopPodSandbox stops the sandbox. If there are any running containers in the + // sandbox, they should be force terminated. + StopPodSandbox(podSandboxID string) error + // RemovePodSandbox removes the sandbox. If there are running containers in the + // sandbox, they should be forcibly removed. + RemovePodSandbox(podSandboxID string) error + // PodSandboxStatus returns the Status of the PodSandbox. + PodSandboxStatus(podSandboxID string) (*runtimeApi.PodSandboxStatus, error) + // ListPodSandbox returns a list of Sandbox. + ListPodSandbox(filter *runtimeApi.PodSandboxFilter) ([]*runtimeApi.PodSandbox, error) +} + // ImageManagerService interface should be implemented by a container image // manager. // The methods should be thread-safe.