Merge pull request #3925 from dmcgowan/snapshot-cleanup-api

Add Cleanup to snapshot API
This commit is contained in:
Phil Estes
2020-01-08 10:03:18 -05:00
committed by GitHub
8 changed files with 354 additions and 70 deletions

View File

@@ -184,6 +184,13 @@ func (p *proxySnapshotter) Close() error {
return nil
}
func (p *proxySnapshotter) Cleanup(ctx context.Context) error {
_, err := p.client.Cleanup(ctx, &snapshotsapi.CleanupRequest{
Snapshotter: p.snapshotterName,
})
return errdefs.FromGRPC(err)
}
func toKind(kind snapshotsapi.Kind) snapshots.Kind {
if kind == snapshotsapi.KindActive {
return snapshots.KindActive

View File

@@ -341,6 +341,17 @@ type Snapshotter interface {
Close() error
}
// Cleaner defines a type capable of performing asynchronous resource cleanup.
// The Cleaner interface should be used by snapshotters which implement fast
// removal and deferred resource cleanup. This prevents snapshots from needing
// to perform lengthy resource cleanup before acknowledging a snapshot key
// has been removed and available for re-use. This is also useful when
// performing multi-key removal with the intent of cleaning up all the
// resources after each snapshot key has been removed.
type Cleaner interface {
Cleanup(ctx context.Context) error
}
// Opt allows setting mutable snapshot properties on creation
type Opt func(info *Info) error