mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-23 19:56:01 +00:00
Repalce rawContainerID with containerID
This commit is contained in:
parent
2537f66f0e
commit
93f0c5a8e5
@ -43,17 +43,17 @@ type RuntimeService interface {
|
||||
// CreateContainer creates a new container in specified PodSandbox.
|
||||
CreateContainer(podSandboxID string, config *runtimeApi.ContainerConfig, sandboxConfig *runtimeApi.PodSandboxConfig) (string, error)
|
||||
// StartContainer starts the container.
|
||||
StartContainer(rawContainerID string) error
|
||||
StartContainer(containerID string) error
|
||||
// StopContainer stops a running container with a grace period (i.e., timeout).
|
||||
StopContainer(rawContainerID string, timeout int64) error
|
||||
StopContainer(containerID string, timeout int64) error
|
||||
// RemoveContainer removes the container.
|
||||
RemoveContainer(rawContainerID string) error
|
||||
RemoveContainer(containerID string) error
|
||||
// ListContainers lists all containers by filters.
|
||||
ListContainers(filter *runtimeApi.ContainerFilter) ([]*runtimeApi.Container, error)
|
||||
// ContainerStatus returns the status of the container.
|
||||
ContainerStatus(rawContainerID string) (*runtimeApi.ContainerStatus, error)
|
||||
ContainerStatus(containerID string) (*runtimeApi.ContainerStatus, error)
|
||||
// Exec executes a command in the container.
|
||||
Exec(rawContainerID string, cmd []string, tty bool, stdin io.Reader, stdout, stderr io.WriteCloser) error
|
||||
Exec(containerID string, cmd []string, tty bool, stdin io.Reader, stdout, stderr io.WriteCloser) error
|
||||
}
|
||||
|
||||
// ImageManagerService interface should be implemented by a container image
|
||||
|
@ -244,15 +244,15 @@ func (r *FakeRuntimeService) CreateContainer(podSandboxID string, config *runtim
|
||||
return containerID, nil
|
||||
}
|
||||
|
||||
func (r *FakeRuntimeService) StartContainer(rawContainerID string) error {
|
||||
func (r *FakeRuntimeService) StartContainer(containerID string) error {
|
||||
r.Lock()
|
||||
defer r.Unlock()
|
||||
|
||||
r.Called = append(r.Called, "StartContainer")
|
||||
|
||||
c, ok := r.Containers[rawContainerID]
|
||||
c, ok := r.Containers[containerID]
|
||||
if !ok {
|
||||
return fmt.Errorf("container %s not found", rawContainerID)
|
||||
return fmt.Errorf("container %s not found", containerID)
|
||||
}
|
||||
|
||||
// Set container to running.
|
||||
@ -264,15 +264,15 @@ func (r *FakeRuntimeService) StartContainer(rawContainerID string) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (r *FakeRuntimeService) StopContainer(rawContainerID string, timeout int64) error {
|
||||
func (r *FakeRuntimeService) StopContainer(containerID string, timeout int64) error {
|
||||
r.Lock()
|
||||
defer r.Unlock()
|
||||
|
||||
r.Called = append(r.Called, "StopContainer")
|
||||
|
||||
c, ok := r.Containers[rawContainerID]
|
||||
c, ok := r.Containers[containerID]
|
||||
if !ok {
|
||||
return fmt.Errorf("container %q not found", rawContainerID)
|
||||
return fmt.Errorf("container %q not found", containerID)
|
||||
}
|
||||
|
||||
// Set container to exited state.
|
||||
@ -284,14 +284,14 @@ func (r *FakeRuntimeService) StopContainer(rawContainerID string, timeout int64)
|
||||
return nil
|
||||
}
|
||||
|
||||
func (r *FakeRuntimeService) RemoveContainer(rawContainerID string) error {
|
||||
func (r *FakeRuntimeService) RemoveContainer(containerID string) error {
|
||||
r.Lock()
|
||||
defer r.Unlock()
|
||||
|
||||
r.Called = append(r.Called, "RemoveContainer")
|
||||
|
||||
// Remove the container
|
||||
delete(r.Containers, rawContainerID)
|
||||
delete(r.Containers, containerID)
|
||||
|
||||
return nil
|
||||
}
|
||||
@ -335,15 +335,15 @@ func (r *FakeRuntimeService) ListContainers(filter *runtimeApi.ContainerFilter)
|
||||
return result, nil
|
||||
}
|
||||
|
||||
func (r *FakeRuntimeService) ContainerStatus(rawContainerID string) (*runtimeApi.ContainerStatus, error) {
|
||||
func (r *FakeRuntimeService) ContainerStatus(containerID string) (*runtimeApi.ContainerStatus, error) {
|
||||
r.Lock()
|
||||
defer r.Unlock()
|
||||
|
||||
r.Called = append(r.Called, "ContainerStatus")
|
||||
|
||||
c, ok := r.Containers[rawContainerID]
|
||||
c, ok := r.Containers[containerID]
|
||||
if !ok {
|
||||
return nil, fmt.Errorf("container %q not found", rawContainerID)
|
||||
return nil, fmt.Errorf("container %q not found", containerID)
|
||||
}
|
||||
|
||||
return &runtimeApi.ContainerStatus{
|
||||
@ -363,7 +363,7 @@ func (r *FakeRuntimeService) ContainerStatus(rawContainerID string) (*runtimeApi
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (r *FakeRuntimeService) Exec(rawContainerID string, cmd []string, tty bool, stdin io.Reader, stdout, stderr io.WriteCloser) error {
|
||||
func (r *FakeRuntimeService) Exec(containerID string, cmd []string, tty bool, stdin io.Reader, stdout, stderr io.WriteCloser) error {
|
||||
r.Lock()
|
||||
defer r.Unlock()
|
||||
|
||||
|
@ -174,19 +174,19 @@ func (ds *dockerService) CreateContainer(podSandboxID string, config *runtimeApi
|
||||
}
|
||||
|
||||
// StartContainer starts the container.
|
||||
func (ds *dockerService) StartContainer(rawContainerID string) error {
|
||||
return ds.client.StartContainer(rawContainerID)
|
||||
func (ds *dockerService) StartContainer(containerID string) error {
|
||||
return ds.client.StartContainer(containerID)
|
||||
}
|
||||
|
||||
// StopContainer stops a running container with a grace period (i.e., timeout).
|
||||
func (ds *dockerService) StopContainer(rawContainerID string, timeout int64) error {
|
||||
return ds.client.StopContainer(rawContainerID, int(timeout))
|
||||
func (ds *dockerService) StopContainer(containerID string, timeout int64) error {
|
||||
return ds.client.StopContainer(containerID, int(timeout))
|
||||
}
|
||||
|
||||
// RemoveContainer removes the container.
|
||||
// TODO: If a container is still running, should we forcibly remove it?
|
||||
func (ds *dockerService) RemoveContainer(rawContainerID string) error {
|
||||
return ds.client.RemoveContainer(rawContainerID, dockertypes.ContainerRemoveOptions{RemoveVolumes: true})
|
||||
func (ds *dockerService) RemoveContainer(containerID string) error {
|
||||
return ds.client.RemoveContainer(containerID, dockertypes.ContainerRemoveOptions{RemoveVolumes: true})
|
||||
}
|
||||
|
||||
func getContainerTimestamps(r *dockertypes.ContainerJSON) (time.Time, time.Time, time.Time, error) {
|
||||
@ -209,8 +209,8 @@ func getContainerTimestamps(r *dockertypes.ContainerJSON) (time.Time, time.Time,
|
||||
}
|
||||
|
||||
// ContainerStatus returns the container status.
|
||||
func (ds *dockerService) ContainerStatus(rawContainerID string) (*runtimeApi.ContainerStatus, error) {
|
||||
r, err := ds.client.InspectContainer(rawContainerID)
|
||||
func (ds *dockerService) ContainerStatus(containerID string) (*runtimeApi.ContainerStatus, error) {
|
||||
r, err := ds.client.InspectContainer(containerID)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@ -218,7 +218,7 @@ func (ds *dockerService) ContainerStatus(rawContainerID string) (*runtimeApi.Con
|
||||
// Parse the timstamps.
|
||||
createdAt, startedAt, finishedAt, err := getContainerTimestamps(r)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to parse timestamp for container %q: %v", rawContainerID, err)
|
||||
return nil, fmt.Errorf("failed to parse timestamp for container %q: %v", containerID, err)
|
||||
}
|
||||
|
||||
// Convert the mounts.
|
||||
@ -295,6 +295,6 @@ func (ds *dockerService) ContainerStatus(rawContainerID string) (*runtimeApi.Con
|
||||
// Exec execute a command in the container.
|
||||
// TODO: Need to handle terminal resizing before implementing this function.
|
||||
// https://github.com/kubernetes/kubernetes/issues/29579.
|
||||
func (ds *dockerService) Exec(rawContainerID string, cmd []string, tty bool, stdin io.Reader, stdout, stderr io.WriteCloser) error {
|
||||
func (ds *dockerService) Exec(containerID string, cmd []string, tty bool, stdin io.Reader, stdout, stderr io.WriteCloser) error {
|
||||
return fmt.Errorf("not implemented")
|
||||
}
|
||||
|
@ -165,15 +165,15 @@ func (r *RemoteRuntimeService) CreateContainer(podSandBoxID string, config *runt
|
||||
}
|
||||
|
||||
// StartContainer starts the container.
|
||||
func (r *RemoteRuntimeService) StartContainer(rawContainerID string) error {
|
||||
func (r *RemoteRuntimeService) StartContainer(containerID string) error {
|
||||
ctx, cancel := getContextWithTimeout(r.timeout)
|
||||
defer cancel()
|
||||
|
||||
_, err := r.runtimeClient.StartContainer(ctx, &runtimeApi.StartContainerRequest{
|
||||
ContainerId: &rawContainerID,
|
||||
ContainerId: &containerID,
|
||||
})
|
||||
if err != nil {
|
||||
glog.Errorf("StartContainer %q from runtime service failed: %v", rawContainerID, err)
|
||||
glog.Errorf("StartContainer %q from runtime service failed: %v", containerID, err)
|
||||
return err
|
||||
}
|
||||
|
||||
@ -181,16 +181,16 @@ func (r *RemoteRuntimeService) StartContainer(rawContainerID string) error {
|
||||
}
|
||||
|
||||
// StopContainer stops a running container with a grace period (i.e., timeout).
|
||||
func (r *RemoteRuntimeService) StopContainer(rawContainerID string, timeout int64) error {
|
||||
func (r *RemoteRuntimeService) StopContainer(containerID string, timeout int64) error {
|
||||
ctx, cancel := getContextWithTimeout(r.timeout)
|
||||
defer cancel()
|
||||
|
||||
_, err := r.runtimeClient.StopContainer(ctx, &runtimeApi.StopContainerRequest{
|
||||
ContainerId: &rawContainerID,
|
||||
ContainerId: &containerID,
|
||||
Timeout: &timeout,
|
||||
})
|
||||
if err != nil {
|
||||
glog.Errorf("StopContainer %q from runtime service failed: %v", rawContainerID, err)
|
||||
glog.Errorf("StopContainer %q from runtime service failed: %v", containerID, err)
|
||||
return err
|
||||
}
|
||||
|
||||
@ -199,15 +199,15 @@ func (r *RemoteRuntimeService) StopContainer(rawContainerID string, timeout int6
|
||||
|
||||
// RemoveContainer removes the container. If the container is running, the container
|
||||
// should be forced to removal.
|
||||
func (r *RemoteRuntimeService) RemoveContainer(rawContainerID string) error {
|
||||
func (r *RemoteRuntimeService) RemoveContainer(containerID string) error {
|
||||
ctx, cancel := getContextWithTimeout(r.timeout)
|
||||
defer cancel()
|
||||
|
||||
_, err := r.runtimeClient.RemoveContainer(ctx, &runtimeApi.RemoveContainerRequest{
|
||||
ContainerId: &rawContainerID,
|
||||
ContainerId: &containerID,
|
||||
})
|
||||
if err != nil {
|
||||
glog.Errorf("RemoveContainer %q from runtime service failed: %v", rawContainerID, err)
|
||||
glog.Errorf("RemoveContainer %q from runtime service failed: %v", containerID, err)
|
||||
return err
|
||||
}
|
||||
|
||||
@ -231,15 +231,15 @@ func (r *RemoteRuntimeService) ListContainers(filter *runtimeApi.ContainerFilter
|
||||
}
|
||||
|
||||
// ContainerStatus returns the container status.
|
||||
func (r *RemoteRuntimeService) ContainerStatus(rawContainerID string) (*runtimeApi.ContainerStatus, error) {
|
||||
func (r *RemoteRuntimeService) ContainerStatus(containerID string) (*runtimeApi.ContainerStatus, error) {
|
||||
ctx, cancel := getContextWithTimeout(r.timeout)
|
||||
defer cancel()
|
||||
|
||||
resp, err := r.runtimeClient.ContainerStatus(ctx, &runtimeApi.ContainerStatusRequest{
|
||||
ContainerId: &rawContainerID,
|
||||
ContainerId: &containerID,
|
||||
})
|
||||
if err != nil {
|
||||
glog.Errorf("ContainerStatus %q from runtime service failed: %v", rawContainerID, err)
|
||||
glog.Errorf("ContainerStatus %q from runtime service failed: %v", containerID, err)
|
||||
return nil, err
|
||||
}
|
||||
|
||||
@ -248,6 +248,6 @@ func (r *RemoteRuntimeService) ContainerStatus(rawContainerID string) (*runtimeA
|
||||
|
||||
// Exec executes a command in the container.
|
||||
// TODO: support terminal resizing for exec, refer https://github.com/kubernetes/kubernetes/issues/29579.
|
||||
func (r *RemoteRuntimeService) Exec(rawContainerID string, cmd []string, tty bool, stdin io.Reader, stdout, stderr io.WriteCloser) error {
|
||||
func (r *RemoteRuntimeService) Exec(containerID string, cmd []string, tty bool, stdin io.Reader, stdout, stderr io.WriteCloser) error {
|
||||
return fmt.Errorf("Not implemented")
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user