Skip to content

Commit

Permalink
Register nvmeof gw service to service_map
Browse files Browse the repository at this point in the history
This brings up nvmeof in "ceph status" output.

Signed-off-by: Vallari Agrawal <[email protected]>
  • Loading branch information
VallariAg committed Aug 15, 2024
1 parent 9666b4a commit f701c3c
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 0 deletions.
16 changes: 16 additions & 0 deletions control/cephutils.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,22 @@ def pool_exists(self, pool) -> bool:

return False

def service_daemon_register(self, cluster, metadata):
try:
if cluster: # rados client
daemon_name = metadata['id']
cluster.service_daemon_register("nvmeof", daemon_name, metadata)
self.logger.exception(f"Registered {daemon_name} to service_map!")
except Exception:
self.logger.exception(f"Can't register daemon to service_map!")

def service_daemon_update(self, cluster, status_buffer):
try:
if cluster and status_buffer:
cluster.service_daemon_update(status_buffer)
except Exception:
self.logger.exception(f"Can't update daemon status to service_map!")

def create_image(self, pool_name, image_name, size) -> bool:
# Check for pool existence in advance as we don't create it if it's not there
if not self.pool_exists(pool_name):
Expand Down
12 changes: 12 additions & 0 deletions control/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,18 @@ def serve(self):
log_level = log_level.upper()
log_req = pb2.set_spdk_nvmf_logs_req(log_level=log_level, print_level=log_level)
self.gateway_rpc.set_spdk_nvmf_logs(log_req)

self._register_service_map()

def _register_service_map(self):
# show gateway in "ceph status" output
conn = self.omap_state.conn
metadata = {
"id": self.name.removeprefix("client.nvmeof."),
"pool_name": self.config.get("ceph", "pool"),
"daemon_type": "gateway", # "nvmeof: 3 <daemon_type> active (3 hosts)"
}
self.ceph_utils.service_daemon_register(conn, metadata)

def _monitor_client_version(self) -> str:
"""Return monitor client version string."""
Expand Down
3 changes: 3 additions & 0 deletions control/state.py
Original file line number Diff line number Diff line change
Expand Up @@ -557,6 +557,9 @@ def cleanup_omap(self):
self.ioctx = None
except Exception:
pass
if self.conn:
self.conn.shutdown()
self.conn = None

class GatewayStateHandler:
"""Maintains consistency in NVMeoF target state store instances.
Expand Down

0 comments on commit f701c3c

Please sign in to comment.