mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-23 19:56:01 +00:00
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:
commit
f82bdca459
@ -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)
|
||||
}
|
||||
|
@ -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)
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user