mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
Windows: Don't attempt detach VHD for R/O layers
Signed-off-by: John Howard <jhoward@microsoft.com>
This commit is contained in:
parent
a6e1502575
commit
293c74ba79
1 changed files with 8 additions and 5 deletions
|
@ -338,11 +338,14 @@ func (d *Driver) Remove(id string) error {
|
||||||
// If permission denied, it's possible that the scratch is still mounted, an
|
// If permission denied, it's possible that the scratch is still mounted, an
|
||||||
// artifact after a hard daemon crash for example. Worth a shot to try detaching it
|
// artifact after a hard daemon crash for example. Worth a shot to try detaching it
|
||||||
// before retrying the rename.
|
// before retrying the rename.
|
||||||
if detachErr := vhd.DetachVhd(filepath.Join(layerPath, "sandbox.vhdx")); detachErr != nil {
|
sandbox := filepath.Join(layerPath, "sandbox.vhdx")
|
||||||
return errors.Wrapf(err, "failed to detach VHD: %s", detachErr)
|
if _, statErr := os.Stat(sandbox); statErr == nil {
|
||||||
}
|
if detachErr := vhd.DetachVhd(sandbox); detachErr != nil {
|
||||||
if renameErr := os.Rename(layerPath, tmpLayerPath); renameErr != nil && !os.IsNotExist(renameErr) {
|
return errors.Wrapf(err, "failed to detach VHD: %s", detachErr)
|
||||||
return errors.Wrapf(err, "second rename attempt following detach failed: %s", renameErr)
|
}
|
||||||
|
if renameErr := os.Rename(layerPath, tmpLayerPath); renameErr != nil && !os.IsNotExist(renameErr) {
|
||||||
|
return errors.Wrapf(err, "second rename attempt following detach failed: %s", renameErr)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if err := hcsshim.DestroyLayer(d.info, tmpID); err != nil {
|
if err := hcsshim.DestroyLayer(d.info, tmpID); err != nil {
|
||||||
|
|
Loading…
Add table
Reference in a new issue