Skip to content

Commit ad96fde

Browse files
committed
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 <[email protected]>
1 parent b8e3259 commit ad96fde

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

snapshots/windows/windows.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,9 @@ func (s *snapshotter) Remove(ctx context.Context, key string) error {
282282
log.G(ctx).WithError(err1).WithField("path", renamed).Error("Failed to rename after failed commit")
283283
}
284284
}
285-
return err
285+
// Return the error wrapped in ErrFailedPrecondition so that cleanup of other snapshots will
286+
// still continue.
287+
return errors.Join(errdefs.ErrFailedPrecondition, err)
286288
}
287289

288290
if err = hcsshim.DestroyLayer(s.info, renamedID); err != nil {

0 commit comments

Comments
 (0)