containerd/patch/0076-containerd-fix-start-container-failed-with-id-exists.patch

35 lines
1.5 KiB
Diff
Raw Normal View History

From 6936dda1f72b328cacfc29b52da780a29ef45385 Mon Sep 17 00:00:00 2001
From: xiadanni <xiadanni1@huawei.com>
Date: Thu, 8 Jul 2021 14:37:56 +0800
Subject: [PATCH] containerd: fix start container failed with id exists
reason: If container root path already exists when call runtime.Create,
we try to call runtime.Delete to cleanup it. But in case runtime.Delete
failed, root path will still exists which causes Create failed with error
"container with id exists". So remove path directly if Delete failed.
Signed-off-by: xiadanni <xiadanni1@huawei.com>
---
vendor/github.com/containerd/go-runc/runc.go | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/vendor/github.com/containerd/go-runc/runc.go b/vendor/github.com/containerd/go-runc/runc.go
index 1c96317..c089381 100644
--- a/vendor/github.com/containerd/go-runc/runc.go
+++ b/vendor/github.com/containerd/go-runc/runc.go
@@ -159,7 +159,10 @@ func (o *CreateOpts) args() (out []string, err error) {
func (r *Runc) Create(context context.Context, id, bundle string, opts *CreateOpts) error {
if _, err := os.Stat(filepath.Join(r.Root, id)); err == nil {
logrus.Warnf("cleanup residue runtime with bundle %s root=%s", bundle, r.Root)
- r.Delete(context, id, &DeleteOpts{Force: true})
+ if dErr := r.Delete(context, id, &DeleteOpts{Force: true}); dErr != nil {
+ logrus.Errorf("runtime force delete return err: %v, remove container root err: %v",
+ dErr, os.RemoveAll(filepath.Join(r.Root, id)))
+ }
}
args := []string{"create", "--bundle", bundle}
--
2.27.0