Merge pull request #44326 from xlgao-zju/forcibly-remove

Automatic merge from submit-queue (batch tested with PRs 44326, 45768)

[CRI] Forcibly remove container

Forcibly remove the running containers in `RemoveContainer`. Since we should forcibly remove the running containers in `RemovePodSandbox`. See [here](https://github.com/kubernetes/kubernetes/blob/master/pkg/kubelet/api/v1alpha1/runtime/api.proto#L35).

cc @feiskyer @Random-Liu 

Signed-off-by: Xianglin Gao <xlgao@zju.edu.cn>
This commit is contained in:
Kubernetes Submit Queue 2017-05-16 10:39:05 -07:00 committed by GitHub
commit f82bdca459
2 changed files with 2 additions and 3 deletions

View File

@ -287,7 +287,6 @@ func (ds *dockerService) StopContainer(containerID string, timeout int64) error
}
// RemoveContainer removes the container.
// TODO: If a container is still running, should we forcibly remove it?
func (ds *dockerService) RemoveContainer(containerID string) error {
// Ideally, log lifecycle should be independent of container lifecycle.
// However, docker will remove container log after container is removed,
@ -296,7 +295,7 @@ func (ds *dockerService) RemoveContainer(containerID string) error {
if err != nil {
return err
}
err = ds.client.RemoveContainer(containerID, dockertypes.ContainerRemoveOptions{RemoveVolumes: true})
err = ds.client.RemoveContainer(containerID, dockertypes.ContainerRemoveOptions{RemoveVolumes: true, Force: true})
if err != nil {
return fmt.Errorf("failed to remove container %q: %v", containerID, err)
}

View File

@ -237,7 +237,7 @@ func (ds *dockerService) RemovePodSandbox(podSandboxID string) error {
}
// Remove the sandbox container.
if err := ds.client.RemoveContainer(podSandboxID, dockertypes.ContainerRemoveOptions{RemoveVolumes: true}); err != nil && !libdocker.IsContainerNotFoundError(err) {
if err := ds.client.RemoveContainer(podSandboxID, dockertypes.ContainerRemoveOptions{RemoveVolumes: true, Force: true}); err != nil && !libdocker.IsContainerNotFoundError(err) {
errs = append(errs, err)
}