Browse Source

daemon: Handle NotFound when deleting container lease

If the lease doesn't exit (for example when creating the container
failed), just ignore the not found error.

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
Paweł Gronowski 1 year ago
parent
commit
bedcc94de4
1 changed files with 5 additions and 2 deletions
  1. 5 2
      daemon/delete.go

+ 5 - 2
daemon/delete.go

@@ -8,6 +8,7 @@ import (
 	"strings"
 	"strings"
 	"time"
 	"time"
 
 
+	cerrdefs "github.com/containerd/containerd/errdefs"
 	"github.com/containerd/containerd/leases"
 	"github.com/containerd/containerd/leases"
 	"github.com/containerd/containerd/log"
 	"github.com/containerd/containerd/log"
 	"github.com/docker/docker/api/types"
 	"github.com/docker/docker/api/types"
@@ -149,8 +150,10 @@ func (daemon *Daemon) cleanupContainer(container *container.Container, config ty
 				ID: container.ID,
 				ID: container.ID,
 			}
 			}
 			if err := ls.Delete(context.Background(), lease, leases.SynchronousDelete); err != nil {
 			if err := ls.Delete(context.Background(), lease, leases.SynchronousDelete); err != nil {
-				container.SetRemovalError(err)
-				return err
+				if !cerrdefs.IsNotFound(err) {
+					container.SetRemovalError(err)
+					return err
+				}
 			}
 			}
 		}
 		}
 	}
 	}