Skip to content

Commit 4bb446e

Browse files
authored
Merge pull request #197 from dmcgowan/fix-unmount-hang
Fix unmount hanging on non-transient errors
2 parents 026a903 + c209413 commit 4bb446e

1 file changed

Lines changed: 11 additions & 2 deletions

File tree

internal/shim/task/service.go

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -175,14 +175,23 @@ func (s *service) shutdown(ctx context.Context) error {
175175
}
176176

177177
// unmountAllWithRetry asks the guest to unmount all tracked mounts, retrying
178-
// briefly on transient failures. Returns the last UnmountAll error if ctx is
179-
// cancelled before a successful call.
178+
// briefly on transient failures (e.g. EBUSY). Permanent errors — including
179+
// Unimplemented, connection errors, and context cancellation — stop the
180+
// retry immediately.
180181
func unmountAllWithRetry(ctx context.Context, mc mountAPI.TTRPCMountService) error {
181182
for {
182183
_, err := mc.UnmountAll(ctx, &mountAPI.UnmountAllRequest{})
183184
if err == nil {
184185
return nil
185186
}
187+
// Convert gRPC/TTRPC status errors to errdefs so IsNotImplemented works.
188+
native := errgrpc.ToNative(err)
189+
// Stop immediately on permanent errors: connection gone or method not
190+
// implemented. Only retry transient errors (e.g. EBUSY from the guest).
191+
if errors.Is(err, ttrpc.ErrClosed) || errors.Is(err, io.EOF) ||
192+
errdefs.IsNotImplemented(native) {
193+
return err
194+
}
186195
select {
187196
case <-ctx.Done():
188197
return err

0 commit comments

Comments
 (0)