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:
@@ -163,6 +163,19 @@ func (s service) Usage(ctx context.Context, ur *snapshotsapi.UsageRequest) (*sna
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (s service) Cleanup(ctx context.Context, cr *snapshotsapi.CleanupRequest) (*ptypes.Empty, error) {
|
||||
c, ok := s.sn.(snapshots.Cleaner)
|
||||
if !ok {
|
||||
return nil, errdefs.ToGRPCf(errdefs.ErrNotImplemented, "snapshotter does not implement Cleanup method")
|
||||
}
|
||||
|
||||
if err := c.Cleanup(ctx); err != nil {
|
||||
return nil, errdefs.ToGRPC(err)
|
||||
}
|
||||
|
||||
return empty, nil
|
||||
}
|
||||
|
||||
func fromKind(kind snapshots.Kind) snapshotsapi.Kind {
|
||||
if kind == snapshots.KindActive {
|
||||
return snapshotsapi.KindActive
|
||||
|
||||
Reference in New Issue
Block a user