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:
Derek McGowan
2020-01-02 16:38:21 -08:00
parent b95fa01b95
commit 123af61c0b
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