diff --git a/control/cephutils.py b/control/cephutils.py index 16dd52f0..976ee7f8 100644 --- a/control/cephutils.py +++ b/control/cephutils.py @@ -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): diff --git a/control/server.py b/control/server.py index 98c9384f..2033fe57 100644 --- a/control/server.py +++ b/control/server.py @@ -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, + "pool_name": self.config.get("ceph", "pool"), + "daemon_type": "gateway", # "nvmeof: 3 active (3 hosts)" + } + self.ceph_utils.service_daemon_register(conn, metadata) def _monitor_client_version(self) -> str: """Return monitor client version string.""" diff --git a/control/state.py b/control/state.py index db93e49c..9185bfe2 100644 --- a/control/state.py +++ b/control/state.py @@ -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.