Skip to content

Commit

Permalink
feat(volume): add remount read only volume grpc
Browse files Browse the repository at this point in the history
ref: longhorn/longhorn 7843

Signed-off-by: Jack Lin <jack.lin@suse.com>
  • Loading branch information
ChanYiLin committed Feb 7, 2024
1 parent 1f07374 commit 38621fd
Show file tree
Hide file tree
Showing 7 changed files with 452 additions and 264 deletions.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,11 @@ def __init__(self, channel):
request_serializer=github_dot_com_dot_longhorn_dot_longhorn__instance__manager_dot_pkg_dot_imrpc_dot_proxy__pb2.ProxyEngineRequest.SerializeToString,
response_deserializer=github_dot_com_dot_longhorn_dot_longhorn__instance__manager_dot_pkg_dot_imrpc_dot_proxy__pb2.EngineMetricsGetProxyResponse.FromString,
)
self.RemountReadOnlyVolume = channel.unary_unary(
'/imrpc.ProxyEngineService/RemountReadOnlyVolume',
request_serializer=github_dot_com_dot_longhorn_dot_longhorn__instance__manager_dot_pkg_dot_imrpc_dot_proxy__pb2.RemountVolumeRequest.SerializeToString,
response_deserializer=google_dot_protobuf_dot_empty__pb2.Empty.FromString,
)


class ProxyEngineServiceServicer(object):
Expand Down Expand Up @@ -361,6 +366,12 @@ def MetricsGet(self, request, context):
context.set_details('Method not implemented!')
raise NotImplementedError('Method not implemented!')

def RemountReadOnlyVolume(self, request, context):
"""Missing associated documentation comment in .proto file."""
context.set_code(grpc.StatusCode.UNIMPLEMENTED)
context.set_details('Method not implemented!')
raise NotImplementedError('Method not implemented!')


def add_ProxyEngineServiceServicer_to_server(servicer, server):
rpc_method_handlers = {
Expand Down Expand Up @@ -519,6 +530,11 @@ def add_ProxyEngineServiceServicer_to_server(servicer, server):
request_deserializer=github_dot_com_dot_longhorn_dot_longhorn__instance__manager_dot_pkg_dot_imrpc_dot_proxy__pb2.ProxyEngineRequest.FromString,
response_serializer=github_dot_com_dot_longhorn_dot_longhorn__instance__manager_dot_pkg_dot_imrpc_dot_proxy__pb2.EngineMetricsGetProxyResponse.SerializeToString,
),
'RemountReadOnlyVolume': grpc.unary_unary_rpc_method_handler(
servicer.RemountReadOnlyVolume,
request_deserializer=github_dot_com_dot_longhorn_dot_longhorn__instance__manager_dot_pkg_dot_imrpc_dot_proxy__pb2.RemountVolumeRequest.FromString,
response_serializer=google_dot_protobuf_dot_empty__pb2.Empty.SerializeToString,
),
}
generic_handler = grpc.method_handlers_generic_handler(
'imrpc.ProxyEngineService', rpc_method_handlers)
Expand Down Expand Up @@ -1055,3 +1071,20 @@ def MetricsGet(request,
github_dot_com_dot_longhorn_dot_longhorn__instance__manager_dot_pkg_dot_imrpc_dot_proxy__pb2.EngineMetricsGetProxyResponse.FromString,
options, channel_credentials,
insecure, call_credentials, compression, wait_for_ready, timeout, metadata)

@staticmethod
def RemountReadOnlyVolume(request,
target,
options=(),
channel_credentials=None,
call_credentials=None,
insecure=False,
compression=None,
wait_for_ready=None,
timeout=None,
metadata=None):
return grpc.experimental.unary_unary(request, target, '/imrpc.ProxyEngineService/RemountReadOnlyVolume',
github_dot_com_dot_longhorn_dot_longhorn__instance__manager_dot_pkg_dot_imrpc_dot_proxy__pb2.RemountVolumeRequest.SerializeToString,
google_dot_protobuf_dot_empty__pb2.Empty.FromString,
options, channel_credentials,
insecure, call_credentials, compression, wait_for_ready, timeout, metadata)
16 changes: 16 additions & 0 deletions pkg/client/proxy_volume.go
Original file line number Diff line number Diff line change
Expand Up @@ -296,3 +296,19 @@ func (c *ProxyClient) VolumeSnapshotMaxSizeSet(dataEngine, engineName, volumeNam

return nil
}

func (c *ProxyClient) RemountReadOnlyVolume(volumeName string) (err error) {
if volumeName == "" {
return fmt.Errorf("failed to remount volume, volume name is empty")
}

req := &rpc.RemountVolumeRequest{
VolumeName: volumeName,
}

_, err = c.service.RemountReadOnlyVolume(getContextWithGRPCTimeout(c.ctx), req)
if err != nil {
return err
}
return nil
}
Loading

0 comments on commit 38621fd

Please sign in to comment.