Add Cleanup to snapshot API
Cleanup is an optional method a snapshotter may implement. Cleanup can be used to cleanup resources after a snapshot has been removed. This function allows a snapshotter to defer longer resource cleanup until after snapshot removals are completed. Adding this to the API allows proxy snapshotters to leverage this enhancement. Signed-off-by: Derek McGowan <derek@mcgstyle.net>
This commit is contained in:
@@ -791,18 +791,17 @@ 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 {
|
||||
if c, ok := s.Snapshotter.(snapshots.Cleaner); ok {
|
||||
err = c.Cleanup(ctx)
|
||||
if errdefs.IsNotImplemented(err) {
|
||||
err = nil
|
||||
}
|
||||
}
|
||||
}
|
||||
if err == nil {
|
||||
|
||||
Reference in New Issue
Block a user