Skip to content

Commit

Permalink
nvme_gw_server: allow to change rpc socket address
Browse files Browse the repository at this point in the history
Previously it was supposed that you could change the address by using
spdk_server_addr and spdk_port configuration parameters. But the
parameters were used only by rcp client, while the spdk target was
always started with the default socket address. This commit fixes it.

Additionally, there is no sense to provide the port configuration
option because the target is always listening on a unix socket
only. So the two parameters spdk_server_addr and spdk_port are
replaced with one rpc_socket. There is not much sense to add "spdk_"
prefix to the option name, because it is in [spdk] section.

And while here remove unused "all" argument in nvme_tgt command, which
seemed to be unintentionally committed after testing with "-L all".

Signed-off-by: Mykola Golub <mykola.golub@clyso.com>
  • Loading branch information
trociny committed Nov 8, 2021
1 parent a3f8d5a commit aaaa51d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 8 deletions.
3 changes: 1 addition & 2 deletions nvme_gw.config
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,7 @@ client_cert = ./client.crt

[spdk]

spdk_server_addr = /var/tmp/spdk.sock
spdk_port = 5260
rpc_socket = /var/tmp/spdk.sock
timeout = 60.0
log_level = ERROR
conn_retries = 3
11 changes: 5 additions & 6 deletions nvme_gw_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,9 @@ def start_spdk(self):
self.spdk_rpc = spdk_rpc
spdk_tgt = self.nvme_config.get("config", "spdk_tgt")
spdk_cmd = os.path.join(spdk_path, spdk_tgt)
spdk_rpc_socket = self.nvme_config.get("spdk", "rpc_socket")

cmd = [spdk_cmd, "all", "-u"]
cmd = [spdk_cmd, "-u", "-r", spdk_rpc_socket]
self.logger.info(f"Starting {' '.join(cmd)}")

try:
Expand All @@ -48,20 +49,18 @@ def start_spdk(self):
self.logger.error(f"Unable to start SPDK: \n {ex}")
raise

spdk_server_addr = self.nvme_config.get("spdk", "spdk_server_addr")
spdk_port = self.nvme_config.get("spdk", "spdk_port")
timeout = self.nvme_config.getfloat("spdk", "timeout")
log_level = self.nvme_config.get("spdk", "log_level")
conn_retries = self.nvme_config.getint("spdk", "conn_retries")

self.logger.info(
f"Attempting to initialize SPDK: server_addr: {spdk_server_addr}, port: {spdk_port}, conn_retries: {conn_retries}, timeout: {timeout}"
f"Attempting to initialize SPDK: rpc_socket: {spdk_rpc_socket}, conn_retries: {conn_retries}, timeout: {timeout}"
)

try:
self.client = self.spdk_rpc.client.JSONRPCClient(
spdk_server_addr,
spdk_port,
spdk_rpc_socket,
None,
timeout,
log_level=log_level,
conn_retries=conn_retries,
Expand Down

0 comments on commit aaaa51d

Please sign in to comment.