From 6b9d171e1ef0a61139b520a74077a8d6cb4456b4 Mon Sep 17 00:00:00 2001 From: Gil Bregman Date: Mon, 23 Oct 2023 17:49:07 +0300 Subject: [PATCH] Write SPDK and discovery service PIDs to the log. Display conf file earlier. Fixes #281 Signed-off-by: Gil Bregman --- control/__main__.py | 1 + control/config.py | 19 +++++++++++++++++++ control/grpc.py | 12 +----------- control/server.py | 3 +++ 4 files changed, 24 insertions(+), 11 deletions(-) diff --git a/control/__main__.py b/control/__main__.py index 78b49536..2544fd71 100644 --- a/control/__main__.py +++ b/control/__main__.py @@ -31,6 +31,7 @@ args = parser.parse_args() config = GatewayConfig(args.config) + config.dump_config_file(logger) with GatewayServer(config) as gateway: gateway.serve() gateway.keep_alive() diff --git a/control/config.py b/control/config.py index 7bc35445..cfa98836 100644 --- a/control/config.py +++ b/control/config.py @@ -18,6 +18,7 @@ class GatewayConfig: """ def __init__(self, conffile): self.filepath = conffile + self.conffile_logged = False with open(conffile) as f: self.config = configparser.ConfigParser() self.config.read_file(f) @@ -45,3 +46,21 @@ def getint_with_default(self, section, param, value): def getfloat_with_default(self, section, param, value): return self.config.getfloat(section, param, fallback=value) + + def dump_config_file(self, logger): + if self.conffile_logged: + return + + try: + logger.info(f"Using configuration file {self.filepath}") + with open(self.filepath) as f: + logger.info( + f"====================================== Configuration file content ======================================") + for line in f: + line = line.rstrip() + logger.info(f"{line}") + logger.info( + f"========================================================================================================") + self.conffile_logged = True + except Exception: + pass diff --git a/control/grpc.py b/control/grpc.py index 2ed666eb..eb7c9619 100644 --- a/control/grpc.py +++ b/control/grpc.py @@ -67,17 +67,7 @@ def __init__(self, config, gateway_state, spdk_rpc_client) -> None: if git_modified: self.logger.info(f"NVMeoF gateway uncommitted modified files: {git_modified}") self.config = config - self.logger.info(f"Using configuration file {config.filepath}") - try: - with open(config.filepath) as f: - self.logger.info(f"Configuration file content:") - self.logger.info(f"============================================================================") - for line in f: - line = line.rstrip() - self.logger.info(f"{line}") - self.logger.info(f"============================================================================") - except Exception: - pass + config.dump_config_file(self.logger) self.rpc_lock = threading.Lock() self.gateway_state = gateway_state self.spdk_rpc_client = spdk_rpc_client diff --git a/control/server.py b/control/server.py index 7057c28e..748f26d3 100644 --- a/control/server.py +++ b/control/server.py @@ -147,6 +147,8 @@ def _start_discovery_service(self): self.logger.info("Starting ceph nvmeof discovery service") DiscoveryService(self.config).start_service() os._exit(0) + else: + self.logger.info(f"Discovery service process id: {self.discovery_pid}") def _add_server_listener(self): """Adds listener port to server.""" @@ -208,6 +210,7 @@ def _start_spdk(self): log_level = self.config.get("spdk", "log_level") # connect timeout: spdk client retries 5 times per sec conn_retries = int(timeout * 5) + self.logger.info(f"SPDK process id: {self.spdk_process.pid}") self.logger.info( f"Attempting to initialize SPDK: rpc_socket: {spdk_rpc_socket}," f" conn_retries: {conn_retries}, timeout: {timeout}"