Skip to content

Commit db8ba7c

Browse files
committed
Use containerd's ErrUnavailable instead of our own error type
Signed-off-by: Kazuyoshi Kato <[email protected]>
1 parent 7b5edc7 commit db8ba7c

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

runtime/service.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -715,9 +715,11 @@ func (s *service) Create(requestCtx context.Context, request *taskAPI.CreateTask
715715
for _, mnt := range request.Rootfs {
716716
driveID, err = s.stubDriveHandler.PatchStubDrive(requestCtx, s.machine, mnt.Source)
717717
if err != nil {
718+
if err == ErrDrivesExhausted {
719+
return nil, errors.Wrapf(errdefs.ErrUnavailable, "no remaining stub drives to be used")
720+
}
718721
return nil, errors.Wrapf(err, "failed to patch stub drive")
719722
}
720-
721723
}
722724

723725
ociConfigBytes, err := bundleDir.OCIConfig().Bytes()

runtime/service_integ_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -725,6 +725,6 @@ func TestCreateTooManyContainers_Isolated(t *testing.T) {
725725

726726
// When we reuse a VM explicitly, we cannot start multiple containers unless we pre-allocate stub drives.
727727
_, err = c2.NewTask(ctx, cio.NewCreator(cio.WithStreams(nil, &stdout, &stderr)))
728-
assert.Equal("failed to patch stub drive: There are no remaining drives to be used: unknown", err.Error())
728+
assert.Equal("no remaining stub drives to be used: unavailable: unknown", err.Error())
729729
require.Error(t, err)
730730
}

0 commit comments

Comments
 (0)