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 19, 2024
1 parent 1f07374 commit bc60f2a
Show file tree
Hide file tree
Showing 14 changed files with 471 additions and 280 deletions.
2 changes: 1 addition & 1 deletion integration/rpc/disk/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import sys


# include current directory to fix relative import in genrated grpc files
# include current directory to fix relative import in generated grpc files
sys.path.append(
os.path.abspath(
os.path.join(os.path.split(__file__)[0], ".")
Expand Down
2 changes: 1 addition & 1 deletion integration/rpc/imrpc/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import sys


# include current directory to fix relative import in genrated grpc files
# include current directory to fix relative import in generated grpc files
sys.path.append(
os.path.abspath(
os.path.join(os.path.split(__file__)[0], ".")
Expand Down
2 changes: 1 addition & 1 deletion integration/rpc/instance/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import sys


# include current directory to fix relative import in genrated grpc files
# include current directory to fix relative import in generated grpc files
sys.path.append(
os.path.abspath(
os.path.join(os.path.split(__file__)[0], ".")
Expand Down

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)
2 changes: 1 addition & 1 deletion package/instance-manager
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ function generate_nvme_hostid_and_hostnqn() {
mkdir -p /etc/nvme

local hostnqn=$(nvme gen-hostnqn)
# hostnqn is generated from /sys/class/dmi/id/product_uuid according to the implemetation of libnvme
# hostnqn is generated from /sys/class/dmi/id/product_uuid according to the implementation of libnvme
echo "$hostnqn" > /etc/nvme/hostnqn
# Always generate the same hostid for the same hostnqn
cat /sys/class/dmi/id/product_uuid > /etc/nvme/hostid
Expand Down
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 bc60f2a

Please sign in to comment.