Skip to content

Commit 58ccdfe

Browse files
authoredMar 21, 2017
Merge pull request moby#31928 from Microsoft/jjh/cleanupremoving
Windows: graph cleanup '-removing'
2 parents 9a5bf4b + 9910b9a commit 58ccdfe

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed
 

‎daemon/graphdriver/windows/windows.go

+22
Original file line numberDiff line numberDiff line change
@@ -412,7 +412,29 @@ func (d *Driver) Put(id string) error {
412412
}
413413

414414
// Cleanup ensures the information the driver stores is properly removed.
415+
// We use this opportunity to cleanup any -removing folders which may be
416+
// still left if the daemon was killed while it was removing a layer.
415417
func (d *Driver) Cleanup() error {
418+
419+
items, err := ioutil.ReadDir(d.info.HomeDir)
420+
if err != nil {
421+
return err
422+
}
423+
424+
// Note we don't return an error below - it's possible the files
425+
// are locked. However, next time around after the daemon exits,
426+
// we likely will be able to to cleanup successfully. Instead we log
427+
// warnings if there are errors.
428+
for _, item := range items {
429+
if item.IsDir() && strings.HasSuffix(item.Name(), "-removing") {
430+
if err := hcsshim.DestroyLayer(d.info, item.Name()); err != nil {
431+
logrus.Warnf("Failed to cleanup %s: %s", item.Name(), err)
432+
} else {
433+
logrus.Infof("Cleaned up %s", item.Name())
434+
}
435+
}
436+
}
437+
416438
return nil
417439
}
418440

0 commit comments

Comments
 (0)
Please sign in to comment.