Merge pull request #1833 from dmcgowan/snapshot-gc-3rd-phase

snapshots/overlay: add overlay cleanup
This commit is contained in:
Stephen Day
2018-03-12 17:49:56 -07:00
committed by GitHub
3 changed files with 180 additions and 52 deletions

View File

@@ -613,14 +613,23 @@ func validateSnapshot(info *snapshots.Info) error {
return nil
}
type cleaner interface {
Cleanup(ctx context.Context) error
}
func (s *snapshotter) garbageCollect(ctx context.Context) (d time.Duration, err error) {
s.l.Lock()
t1 := time.Now()
defer func() {
s.l.Unlock()
if err == nil {
if c, ok := s.Snapshotter.(cleaner); ok {
err = c.Cleanup(ctx)
}
}
if err == nil {
d = time.Now().Sub(t1)
}
s.l.Unlock()
}()
seen := map[string]struct{}{}