Skip to content

Commit 8c3a539

Browse files
authored
Merge pull request #2078 from rudyfly/volume-bugfix
bugfix: do umount rootfs when failed to operate volumes
2 parents 77984b5 + 90a1c77 commit 8c3a539

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

daemon/mgr/container.go

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -337,16 +337,22 @@ func (mgr *ContainerManager) Create(ctx context.Context, name string, config *ty
337337
mgr.setBaseFS(ctx, container, id)
338338

339339
if err := mgr.Mount(ctx, container); err != nil {
340-
return nil, err
340+
return nil, errors.Wrapf(err, "failed to mount container: (%s) rootfs: (%s)", id, container.MountFS)
341341
}
342342

343343
// parse volume config
344344
if err := mgr.generateMountPoints(ctx, container); err != nil {
345+
if err = mgr.Unmount(ctx, container); err != nil {
346+
err = errors.Wrapf(err, "failed to umount container: (%s) rootfs: (%s)", id, container.MountFS)
347+
}
345348
return nil, errors.Wrap(err, "failed to parse volume argument")
346349
}
347350

348351
// set mount point disk quota
349352
if err := mgr.setMountPointDiskQuota(ctx, container); err != nil {
353+
if err = mgr.Unmount(ctx, container); err != nil {
354+
err = errors.Wrapf(err, "failed to umount container: (%s) rootfs: (%s)", id, container.MountFS)
355+
}
350356
return nil, errors.Wrap(err, "failed to set mount point disk quota")
351357
}
352358

@@ -356,7 +362,7 @@ func (mgr *ContainerManager) Create(ctx context.Context, name string, config *ty
356362
}
357363

358364
if err := mgr.Unmount(ctx, container); err != nil {
359-
return nil, err
365+
return nil, errors.Wrapf(err, "failed to umount container: (%s) rootfs: (%s)", id, container.MountFS)
360366
}
361367

362368
// set network settings

0 commit comments

Comments
 (0)