Skip to content

Commit ed7c689

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]> (cherry picked from commit ad96fde) Signed-off-by: Amit Barve <[email protected]>
1 parent 467de56 commit ed7c689

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
@@ -280,7 +280,9 @@ func (s *snapshotter) Remove(ctx context.Context, key string) error {
280280
log.G(ctx).WithError(err1).WithField("path", renamed).Error("Failed to rename after failed commit")
281281
}
282282
}
283-
return err
283+
// Return the error wrapped in ErrFailedPrecondition so that cleanup of other snapshots will
284+
// still continue.
285+
return errors.Join(errdefs.ErrFailedPrecondition, err)
284286
}
285287

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

0 commit comments

Comments
 (0)