Skip to content

Commit 9d28de1

Browse files
committed
Fix multierror, switch to original stub path on release
Signed-off-by: bpopovschi <[email protected]>
1 parent c86d63d commit 9d28de1

File tree

2 files changed

+7
-6
lines changed

2 files changed

+7
-6
lines changed

runtime/drive_handler.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ func (h *StubDriveHandler) Reserve(
111111
return ErrDrivesExhausted
112112
}
113113
if _, ok := h.usedDrives[id]; ok {
114-
// This case means that driver wasn't released or removed properly
114+
// This case means that drive wasn't released or removed properly
115115
return fmt.Errorf("drive with ID %s already in use, a previous attempt to remove it may have failed", id)
116116
}
117117

@@ -127,6 +127,7 @@ func (h *StubDriveHandler) Reserve(
127127
filesystemType,
128128
options,
129129
)
130+
freeDrive = &stubDrive
130131

131132
err = stubDrive.PatchAndMount(requestCtx, machine, driveMounter)
132133
if err != nil {
@@ -161,7 +162,7 @@ func (h *StubDriveHandler) Release(
161162
return errors.Wrap(err, "failed to unmount drive")
162163
}
163164

164-
err = machine.UpdateGuestDrive(requestCtx, drive.driveID, drive.driveMount.HostPath)
165+
err = machine.UpdateGuestDrive(requestCtx, drive.driveID, drive.stubPath)
165166
if err != nil {
166167
return errors.Wrap(err, "failed to patch drive")
167168
}

runtime/service.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -926,22 +926,22 @@ func (s *service) Delete(requestCtx context.Context, req *taskAPI.DeleteRequest)
926926
// Trying to release stub drive for further reuse
927927
err = s.containerStubHandler.Release(requestCtx, req.ID, s.driveMountClient, s.machine)
928928
if err != nil {
929-
multierror.Append(result, errors.Wrapf(err, "failed to release stub drive for container: %s", req.ID))
929+
result = multierror.Append(result, errors.Wrapf(err, "failed to release stub drive for container: %s", req.ID))
930930
}
931931

932932
// Otherwise, delete the container
933933
dir, err := s.shimDir.BundleLink(req.ID)
934934
if err != nil {
935-
return nil, errors.Wrapf(err, "failed to find the bundle directory of the container: %s", req.ID)
935+
result = multierror.Append(result, errors.Wrapf(err, "failed to find the bundle directory of the container: %s", req.ID))
936936
}
937937

938938
_, err = os.Stat(dir.RootPath())
939939
if os.IsNotExist(err) {
940-
return nil, errors.Wrapf(err, "failed to find the bundle directory of the container: %s", dir.RootPath())
940+
result = multierror.Append(result, errors.Wrapf(err, "failed to find the bundle directory of the container: %s", dir.RootPath()))
941941
}
942942

943943
if err = os.Remove(dir.RootPath()); err != nil {
944-
return nil, multierror.Append(result, errors.Wrapf(err, "failed to remove the bundle directory of the container: %s", dir.RootPath()))
944+
result = multierror.Append(result, errors.Wrapf(err, "failed to remove the bundle directory of the container: %s", dir.RootPath()))
945945
}
946946

947947
return resp, result.ErrorOrNil()

0 commit comments

Comments
 (0)