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:
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user