From ad96fded4cafe550e1291d89f3a869397b14ae83 Mon Sep 17 00:00:00 2001 From: Amit Barve Date: Mon, 4 Dec 2023 09:57:50 -0800 Subject: [PATCH] Don't block snapshot garbage collection on Remove failures If a snapshot removal fails (during garbage collection), the entire garbage collection operation is cancelled. This is problematic because once cleanup of any snapshot fails no other snapshots will be cleaned and the disk usage will just keep increasing. Solution is to return snapshot removal errors wrapped as "ErrFailedPrecondition" errors. The garbage collectors continues cleanup if the error is of this type. Signed-off-by: Amit Barve --- snapshots/windows/windows.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/snapshots/windows/windows.go b/snapshots/windows/windows.go index 35a7aacda..bc7a35a6b 100644 --- a/snapshots/windows/windows.go +++ b/snapshots/windows/windows.go @@ -282,7 +282,9 @@ func (s *snapshotter) Remove(ctx context.Context, key string) error { log.G(ctx).WithError(err1).WithField("path", renamed).Error("Failed to rename after failed commit") } } - return err + // Return the error wrapped in ErrFailedPrecondition so that cleanup of other snapshots will + // still continue. + return errors.Join(errdefs.ErrFailedPrecondition, err) } if err = hcsshim.DestroyLayer(s.info, renamedID); err != nil {