Skip to content

Commit

Permalink
proxy: update ProxyOps
Browse files Browse the repository at this point in the history
Add newly introduced methods VolumeSnapshotMaxCountSet and VolumeSnapshotMaxSizeSet

Longhorn 7555

Signed-off-by: Derek Su <derek.su@suse.com>
  • Loading branch information
derekbit authored and David Ko committed Jan 5, 2024
1 parent 8e3abaa commit 304418f
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 23 deletions.
2 changes: 2 additions & 0 deletions pkg/proxy/proxy.go
Expand Up @@ -41,6 +41,8 @@ type ProxyOps interface {
SnapshotRemove(context.Context, *rpc.EngineSnapshotRemoveRequest) (*emptypb.Empty, error)
SnapshotHash(context.Context, *rpc.EngineSnapshotHashRequest) (*emptypb.Empty, error)
SnapshotHashStatus(context.Context, *rpc.EngineSnapshotHashStatusRequest) (*rpc.EngineSnapshotHashStatusProxyResponse, error)
VolumeSnapshotMaxCountSet(context.Context, *rpc.EngineVolumeSnapshotMaxCountSetRequest) (*emptypb.Empty, error)
VolumeSnapshotMaxSizeSet(context.Context, *rpc.EngineVolumeSnapshotMaxSizeSetRequest) (*emptypb.Empty, error)

SnapshotBackup(context.Context, *rpc.EngineSnapshotBackupRequest, map[string]string, []string) (*rpc.EngineSnapshotBackupProxyResponse, error)
SnapshotBackupStatus(context.Context, *rpc.EngineSnapshotBackupStatusRequest) (*rpc.EngineSnapshotBackupStatusProxyResponse, error)
Expand Down
40 changes: 17 additions & 23 deletions pkg/proxy/volume.go
Expand Up @@ -158,7 +158,7 @@ func (ops V1DataEngineProxyOps) VolumeFrontendStart(ctx context.Context, req *rp
}

func (ops V2DataEngineProxyOps) VolumeFrontendStart(ctx context.Context, req *rpc.EngineVolumeFrontendStartRequest) (resp *emptypb.Empty, err error) {
/* Not implemented */
/* TODO: Implement this */
return &emptypb.Empty{}, nil
}

Expand Down Expand Up @@ -194,7 +194,7 @@ func (ops V1DataEngineProxyOps) VolumeFrontendShutdown(ctx context.Context, req
}

func (ops V2DataEngineProxyOps) VolumeFrontendShutdown(ctx context.Context, req *rpc.ProxyEngineRequest) (resp *emptypb.Empty, err error) {
/* Not implemented */
/* TODO: Implement this */
return &emptypb.Empty{}, nil
}

Expand Down Expand Up @@ -231,7 +231,7 @@ func (ops V1DataEngineProxyOps) VolumeUnmapMarkSnapChainRemovedSet(ctx context.C
}

func (ops V2DataEngineProxyOps) VolumeUnmapMarkSnapChainRemovedSet(ctx context.Context, req *rpc.EngineVolumeUnmapMarkSnapChainRemovedSetRequest) (resp *emptypb.Empty, err error) {
/* Not implemented */
/* TODO: Implement this */
return &emptypb.Empty{}, nil
}

Expand All @@ -244,17 +244,14 @@ func (p *Proxy) VolumeSnapshotMaxCountSet(ctx context.Context, req *rpc.EngineVo
})
log.Infof("Setting volume flag SnapshotMaxCount to %v", req.Count.Count)

switch req.ProxyEngineRequest.DataEngine {
case rpc.DataEngine_DATA_ENGINE_V1:
return p.volumeSnapshotMaxCountSet(ctx, req)
case rpc.DataEngine_DATA_ENGINE_V2:
return p.spdkVolumeSnapshotMaxCountSet(ctx, req)
default:
return nil, grpcstatus.Errorf(grpccodes.InvalidArgument, "unknown data engine %v", req.ProxyEngineRequest.DataEngine)
op, ok := p.ops[req.ProxyEngineRequest.DataEngine]
if !ok {
return nil, grpcstatus.Errorf(grpccodes.Unimplemented, "unsupported data engine %v", req.ProxyEngineRequest.DataEngine)
}
return op.VolumeSnapshotMaxCountSet(ctx, req)
}

func (p *Proxy) volumeSnapshotMaxCountSet(ctx context.Context, req *rpc.EngineVolumeSnapshotMaxCountSetRequest) (resp *emptypb.Empty, err error) {
func (ops V1DataEngineProxyOps) VolumeSnapshotMaxCountSet(ctx context.Context, req *rpc.EngineVolumeSnapshotMaxCountSetRequest) (resp *emptypb.Empty, err error) {
c, err := eclient.NewControllerClient(req.ProxyEngineRequest.Address, req.ProxyEngineRequest.VolumeName,
req.ProxyEngineRequest.EngineName)
if err != nil {
Expand All @@ -270,8 +267,8 @@ func (p *Proxy) volumeSnapshotMaxCountSet(ctx context.Context, req *rpc.EngineVo
return &emptypb.Empty{}, nil
}

func (p *Proxy) spdkVolumeSnapshotMaxCountSet(ctx context.Context, req *rpc.EngineVolumeSnapshotMaxCountSetRequest) (resp *emptypb.Empty, err error) {
/* Not implemented */
func (ops V2DataEngineProxyOps) VolumeSnapshotMaxCountSet(ctx context.Context, req *rpc.EngineVolumeSnapshotMaxCountSetRequest) (resp *emptypb.Empty, err error) {
/* TODO: Implement this */
return &emptypb.Empty{}, nil
}

Expand All @@ -284,17 +281,14 @@ func (p *Proxy) VolumeSnapshotMaxSizeSet(ctx context.Context, req *rpc.EngineVol
})
log.Infof("Setting volume flag SnapshotMaxSize to %v", req.Size.Size)

switch req.ProxyEngineRequest.DataEngine {
case rpc.DataEngine_DATA_ENGINE_V1:
return p.volumeSnapshotMaxSizeSet(ctx, req)
case rpc.DataEngine_DATA_ENGINE_V2:
return p.spdkVolumeSnapshotMaxSizeSet(ctx, req)
default:
return nil, grpcstatus.Errorf(grpccodes.InvalidArgument, "unknown data engine %v", req.ProxyEngineRequest.DataEngine)
op, ok := p.ops[req.ProxyEngineRequest.DataEngine]
if !ok {
return nil, grpcstatus.Errorf(grpccodes.Unimplemented, "unsupported data engine %v", req.ProxyEngineRequest.DataEngine)
}
return op.VolumeSnapshotMaxSizeSet(ctx, req)
}

func (p *Proxy) volumeSnapshotMaxSizeSet(ctx context.Context, req *rpc.EngineVolumeSnapshotMaxSizeSetRequest) (resp *emptypb.Empty, err error) {
func (ops V1DataEngineProxyOps) VolumeSnapshotMaxSizeSet(ctx context.Context, req *rpc.EngineVolumeSnapshotMaxSizeSetRequest) (resp *emptypb.Empty, err error) {
c, err := eclient.NewControllerClient(req.ProxyEngineRequest.Address, req.ProxyEngineRequest.VolumeName,
req.ProxyEngineRequest.EngineName)
if err != nil {
Expand All @@ -310,7 +304,7 @@ func (p *Proxy) volumeSnapshotMaxSizeSet(ctx context.Context, req *rpc.EngineVol
return &emptypb.Empty{}, nil
}

func (p *Proxy) spdkVolumeSnapshotMaxSizeSet(ctx context.Context, req *rpc.EngineVolumeSnapshotMaxSizeSetRequest) (resp *emptypb.Empty, err error) {
/* Not implemented */
func (ops V2DataEngineProxyOps) VolumeSnapshotMaxSizeSet(ctx context.Context, req *rpc.EngineVolumeSnapshotMaxSizeSetRequest) (resp *emptypb.Empty, err error) {
/* TODO: Implement this */
return &emptypb.Empty{}, nil
}

0 comments on commit 304418f

Please sign in to comment.