From f8101014367bb3c1580cc35e659fdbbbefc922ad Mon Sep 17 00:00:00 2001 From: Antonio Murdaca Date: Thu, 15 Nov 2018 10:59:30 +0100 Subject: [PATCH] layers: do not try to unmount if not mounted at all on delete This check has been wrongly removed with #198 The check must stay as it's now part of the Stop/Delete API so reintroduce it back This fixes #233 and the associated CRI-O issues This PR + kubernetes-sigs/cri-o#1910 fully fix the issue I'm going to revendor c/storage in CRI-O to full fix crio after this is merged Signed-off-by: Antonio Murdaca --- layers.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/layers.go b/layers.go index c28db350aa..6c8f59b8b2 100644 --- a/layers.go +++ b/layers.go @@ -841,8 +841,12 @@ func (r *layerStore) Delete(id string) error { return ErrLayerUnknown } id = layer.ID - if _, err := r.Unmount(id, true); err != nil { - return err + // This check is needed for idempotency of delete where the layer could have been + // already unmounted (since c/storage gives you that API directly) + for layer.MountCount > 0 { + if _, err := r.Unmount(id, false); err != nil { + return err + } } err := r.driver.Remove(id) if err == nil {