mirror of
				https://github.com/moby/moby.git
				synced 2022-11-09 12:21:53 -05:00 
			
		
		
		
	Merge pull request #31928 from Microsoft/jjh/cleanupremoving
Windows: graph cleanup '-removing'
This commit is contained in:
		
						commit
						58ccdfe00c
					
				
					 1 changed files with 22 additions and 0 deletions
				
			
		| 
						 | 
					@ -412,7 +412,29 @@ func (d *Driver) Put(id string) error {
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// Cleanup ensures the information the driver stores is properly removed.
 | 
					// Cleanup ensures the information the driver stores is properly removed.
 | 
				
			||||||
 | 
					// We use this opportunity to cleanup any -removing folders which may be
 | 
				
			||||||
 | 
					// still left if the daemon was killed while it was removing a layer.
 | 
				
			||||||
func (d *Driver) Cleanup() error {
 | 
					func (d *Driver) Cleanup() error {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						items, err := ioutil.ReadDir(d.info.HomeDir)
 | 
				
			||||||
 | 
						if err != nil {
 | 
				
			||||||
 | 
							return err
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						// Note we don't return an error below - it's possible the files
 | 
				
			||||||
 | 
						// are locked. However, next time around after the daemon exits,
 | 
				
			||||||
 | 
						// we likely will be able to to cleanup successfully. Instead we log
 | 
				
			||||||
 | 
						// warnings if there are errors.
 | 
				
			||||||
 | 
						for _, item := range items {
 | 
				
			||||||
 | 
							if item.IsDir() && strings.HasSuffix(item.Name(), "-removing") {
 | 
				
			||||||
 | 
								if err := hcsshim.DestroyLayer(d.info, item.Name()); err != nil {
 | 
				
			||||||
 | 
									logrus.Warnf("Failed to cleanup %s: %s", item.Name(), err)
 | 
				
			||||||
 | 
								} else {
 | 
				
			||||||
 | 
									logrus.Infof("Cleaned up %s", item.Name())
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	return nil
 | 
						return nil
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue