File tree 1 file changed +22
-0
lines changed
daemon/graphdriver/windows
1 file changed +22
-0
lines changed Original file line number Diff line number Diff line change @@ -412,7 +412,29 @@ func (d *Driver) Put(id string) error {
412
412
}
413
413
414
414
// 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.
415
417
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
+
416
438
return nil
417
439
}
418
440
You can’t perform that action at this time.
0 commit comments