Merge pull request #5954 from claudiubelu/fix-sandbox-remove
sandbox: Allows the sandbox to be deleted in NotReady state
This commit is contained in:
		| @@ -26,7 +26,6 @@ import ( | |||||||
| 	runtime "k8s.io/cri-api/pkg/apis/runtime/v1" | 	runtime "k8s.io/cri-api/pkg/apis/runtime/v1" | ||||||
|  |  | ||||||
| 	"github.com/containerd/containerd/pkg/cri/store" | 	"github.com/containerd/containerd/pkg/cri/store" | ||||||
| 	sandboxstore "github.com/containerd/containerd/pkg/cri/store/sandbox" |  | ||||||
| ) | ) | ||||||
|  |  | ||||||
| // RemovePodSandbox removes the sandbox. If there are running containers in the | // RemovePodSandbox removes the sandbox. If there are running containers in the | ||||||
| @@ -46,14 +45,13 @@ func (c *criService) RemovePodSandbox(ctx context.Context, r *runtime.RemovePodS | |||||||
| 	// Use the full sandbox id. | 	// Use the full sandbox id. | ||||||
| 	id := sandbox.ID | 	id := sandbox.ID | ||||||
|  |  | ||||||
| 	// If the sandbox is still running or in an unknown state, forcibly stop it. | 	// If the sandbox is still running, not ready, or in an unknown state, forcibly stop it. | ||||||
| 	state := sandbox.Status.Get().State | 	// Even if it's in a NotReady state, this will close its network namespace, if open. | ||||||
| 	if state == sandboxstore.StateReady || state == sandboxstore.StateUnknown { | 	// This can happen if the task process associated with the Pod died or it was killed. | ||||||
| 	logrus.Infof("Forcibly stopping sandbox %q", id) | 	logrus.Infof("Forcibly stopping sandbox %q", id) | ||||||
| 	if err := c.stopPodSandbox(ctx, sandbox); err != nil { | 	if err := c.stopPodSandbox(ctx, sandbox); err != nil { | ||||||
| 		return nil, errors.Wrapf(err, "failed to forcibly stop sandbox %q", id) | 		return nil, errors.Wrapf(err, "failed to forcibly stop sandbox %q", id) | ||||||
| 	} | 	} | ||||||
| 	} |  | ||||||
|  |  | ||||||
| 	// Return error if sandbox network namespace is not closed yet. | 	// Return error if sandbox network namespace is not closed yet. | ||||||
| 	if sandbox.NetNS != nil { | 	if sandbox.NetNS != nil { | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 Michael Crosby
					Michael Crosby