Skip to content

Commit

Permalink
Write SPDK and discovery service PIDs to the log. Display conf file e…
Browse files Browse the repository at this point in the history
…arlier.

Fixes #281

Signed-off-by: Gil Bregman <[email protected]>
  • Loading branch information
gbregman committed Oct 23, 2023
1 parent e1bed1c commit 6b9d171
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 11 deletions.
1 change: 1 addition & 0 deletions control/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
19 changes: 19 additions & 0 deletions control/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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
12 changes: 1 addition & 11 deletions control/grpc.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions control/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -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."""
Expand Down Expand Up @@ -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}"
Expand Down

0 comments on commit 6b9d171

Please sign in to comment.