Commit 58a9da33 authored by Pengfei Ni's avatar Pengfei Ni

Kubelet: rename CreatePodSandbox to RunPodSandbox in CRI

parent dc529a03
...@@ -50,9 +50,9 @@ type ContainerManager interface { ...@@ -50,9 +50,9 @@ type ContainerManager interface {
// PodSandboxManager contains methods for operating on PodSandboxes. The methods // PodSandboxManager contains methods for operating on PodSandboxes. The methods
// are thread-safe. // are thread-safe.
type PodSandboxManager interface { type PodSandboxManager interface {
// CreatePodSandbox creates a pod-level sandbox. // RunPodSandbox creates and starts a pod-level sandbox. Runtimes should ensure
// The definition of PodSandbox is at https://github.com/kubernetes/kubernetes/pull/25899 // the sandbox is in ready state.
CreatePodSandbox(config *runtimeApi.PodSandboxConfig) (string, error) RunPodSandbox(config *runtimeApi.PodSandboxConfig) (string, error)
// StopPodSandbox stops the sandbox. If there are any running containers in the // StopPodSandbox stops the sandbox. If there are any running containers in the
// sandbox, they should be force terminated. // sandbox, they should be force terminated.
StopPodSandbox(podSandboxID string) error StopPodSandbox(podSandboxID string) error
......
...@@ -99,11 +99,11 @@ func (r *FakeRuntimeService) Version(apiVersion string) (*runtimeApi.VersionResp ...@@ -99,11 +99,11 @@ func (r *FakeRuntimeService) Version(apiVersion string) (*runtimeApi.VersionResp
}, nil }, nil
} }
func (r *FakeRuntimeService) CreatePodSandbox(config *runtimeApi.PodSandboxConfig) (string, error) { func (r *FakeRuntimeService) RunPodSandbox(config *runtimeApi.PodSandboxConfig) (string, error) {
r.Lock() r.Lock()
defer r.Unlock() defer r.Unlock()
r.Called = append(r.Called, "CreatePodSandbox") r.Called = append(r.Called, "RunPodSandbox")
// PodSandboxID should be randomized for real container runtime, but here just use // PodSandboxID should be randomized for real container runtime, but here just use
// fixed name from BuildSandboxName() for easily making fake sandboxes. // fixed name from BuildSandboxName() for easily making fake sandboxes.
......
...@@ -8,9 +8,9 @@ service RuntimeService { ...@@ -8,9 +8,9 @@ service RuntimeService {
// Version returns the runtime name, runtime version and runtime API version // Version returns the runtime name, runtime version and runtime API version
rpc Version(VersionRequest) returns (VersionResponse) {} rpc Version(VersionRequest) returns (VersionResponse) {}
// CreatePodSandbox creates a pod-level sandbox. // RunPodSandbox creates and starts a pod-level sandbox. Runtimes should ensure
// The definition of PodSandbox is at https://github.com/kubernetes/kubernetes/pull/25899 // the sandbox is in ready state.
rpc CreatePodSandbox(CreatePodSandboxRequest) returns (CreatePodSandboxResponse) {} rpc RunPodSandbox(RunPodSandboxRequest) returns (RunPodSandboxResponse) {}
// StopPodSandbox stops the running sandbox. If there are any running // StopPodSandbox stops the running sandbox. If there are any running
// containers in the sandbox, they should be forcibly terminated. // containers in the sandbox, they should be forcibly terminated.
rpc StopPodSandbox(StopPodSandboxRequest) returns (StopPodSandboxResponse) {} rpc StopPodSandbox(StopPodSandboxRequest) returns (StopPodSandboxResponse) {}
...@@ -188,12 +188,12 @@ message PodSandboxConfig { ...@@ -188,12 +188,12 @@ message PodSandboxConfig {
optional LinuxPodSandboxConfig linux = 8; optional LinuxPodSandboxConfig linux = 8;
} }
message CreatePodSandboxRequest { message RunPodSandboxRequest {
// The configuration for creating a PodSandBox. // The configuration for creating a PodSandBox.
optional PodSandboxConfig config = 1; optional PodSandboxConfig config = 1;
} }
message CreatePodSandboxResponse { message RunPodSandboxResponse {
// The id of the PodSandBox // The id of the PodSandBox
optional string pod_sandbox_id = 1; optional string pod_sandbox_id = 1;
} }
......
...@@ -37,12 +37,12 @@ const ( ...@@ -37,12 +37,12 @@ const (
defaultSandboxGracePeriod int = 10 defaultSandboxGracePeriod int = 10
) )
// CreatePodSandbox creates a pod-level sandbox. // RunPodSandbox creates and starts a pod-level sandbox. Runtimes should ensure
// The definition of PodSandbox is at https://github.com/kubernetes/kubernetes/pull/25899 // the sandbox is in ready state.
// For docker, PodSandbox is implemented by a container holding the network // For docker, PodSandbox is implemented by a container holding the network
// namespace for the pod. // namespace for the pod.
// Note: docker doesn't use LogDirectory (yet). // Note: docker doesn't use LogDirectory (yet).
func (ds *dockerService) CreatePodSandbox(config *runtimeApi.PodSandboxConfig) (string, error) { func (ds *dockerService) RunPodSandbox(config *runtimeApi.PodSandboxConfig) (string, error) {
// Step 1: Pull the image for the sandbox. // Step 1: Pull the image for the sandbox.
// TODO: How should we handle pulling custom pod infra container image // TODO: How should we handle pulling custom pod infra container image
// (with credentials)? // (with credentials)?
......
...@@ -36,7 +36,7 @@ func TestCreateSandbox(t *testing.T) { ...@@ -36,7 +36,7 @@ func TestCreateSandbox(t *testing.T) {
Uid: &uid, Uid: &uid,
}, },
} }
id, err := ds.CreatePodSandbox(config) id, err := ds.RunPodSandbox(config)
if err != nil { if err != nil {
t.Errorf("Unexpected error: %v", err) t.Errorf("Unexpected error: %v", err)
} }
......
...@@ -64,16 +64,17 @@ func (r *RemoteRuntimeService) Version(apiVersion string) (*runtimeApi.VersionRe ...@@ -64,16 +64,17 @@ func (r *RemoteRuntimeService) Version(apiVersion string) (*runtimeApi.VersionRe
return typedVersion, err return typedVersion, err
} }
// CreatePodSandbox creates a pod-level sandbox. // RunPodSandbox creates and starts a pod-level sandbox. Runtimes should ensure
func (r *RemoteRuntimeService) CreatePodSandbox(config *runtimeApi.PodSandboxConfig) (string, error) { // the sandbox is in ready state.
func (r *RemoteRuntimeService) RunPodSandbox(config *runtimeApi.PodSandboxConfig) (string, error) {
ctx, cancel := getContextWithTimeout(r.timeout) ctx, cancel := getContextWithTimeout(r.timeout)
defer cancel() defer cancel()
resp, err := r.runtimeClient.CreatePodSandbox(ctx, &runtimeApi.CreatePodSandboxRequest{ resp, err := r.runtimeClient.RunPodSandbox(ctx, &runtimeApi.RunPodSandboxRequest{
Config: config, Config: config,
}) })
if err != nil { if err != nil {
glog.Errorf("CreatePodSandbox from runtime service failed: %v", err) glog.Errorf("RunPodSandbox from runtime service failed: %v", err)
return "", err return "", err
} }
......
...@@ -33,8 +33,8 @@ func NewPodSandboxManager(PodSandboxManagerConfig) (kubeletApi.PodSandboxManager ...@@ -33,8 +33,8 @@ func NewPodSandboxManager(PodSandboxManagerConfig) (kubeletApi.PodSandboxManager
return &PodSandboxManager{}, nil return &PodSandboxManager{}, nil
} }
// CreatePodSandbox creates a pod sandbox given a pod sandbox configuration. // RunPodSandbox creates and starts a pod sandbox given a pod sandbox configuration.
func (*PodSandboxManager) CreatePodSandbox(*runtimeApi.PodSandboxConfig) (string, error) { func (*PodSandboxManager) RunPodSandbox(*runtimeApi.PodSandboxConfig) (string, error) {
panic("not implemented") panic("not implemented")
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment