Skip to content

Commit

Permalink
control/server.py: log monitor client version on start up
Browse files Browse the repository at this point in the history
Signed-off-by: Alexander Indenbaum <[email protected]>
  • Loading branch information
Alexander Indenbaum committed May 1, 2024
1 parent 0537f83 commit 6b3774b
Showing 1 changed file with 20 additions and 3 deletions.
23 changes: 20 additions & 3 deletions control/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ def __init__(self, config: GatewayConfig):
self.ceph_utils = None
self.rpc_lock = threading.Lock()
self.group_id = 0
self.monitor_client = '/usr/bin/ceph-nvmeof-monitor-client'

self.name = self.config.get("gateway", "name")
if not self.name:
Expand Down Expand Up @@ -152,7 +153,7 @@ def _wait_for_group_id(self):

def serve(self):
"""Starts gateway server."""
self.logger.debug("Starting serve")
self.logger.info(f"Starting serve, monitor client version: {self._monitor_client_version()}")

omap_state = OmapGatewayState(self.config)
local_state = LocalGatewayState()
Expand Down Expand Up @@ -195,18 +196,34 @@ def serve(self):
else:
self.logger.info(f"Prometheus endpoint is disabled. To enable, set the config option 'enable_prometheus_exporter = True'")

def _monitor_client_version(self) -> str:
"""Return monitor client version string."""
# Get the current SIGCHLD handler
original_sigchld_handler = signal.getsignal(signal.SIGCHLD)

try:
# Execute the command and capture its output
signal.signal(signal.SIGCHLD, signal.SIG_IGN)
completed_process = subprocess.run([self.monitor_client, "--version"], capture_output=True, text=True)
finally:
# Restore the original SIGCHLD handler
signal.signal(signal.SIGCHLD, original_sigchld_handler)

# Get the output
output = completed_process.stdout.strip()
return output

def _start_monitor_client(self):
"""Runs CEPH NVMEOF Monitor Client."""
enable_monitor_client = self.config.getboolean_with_default("gateway", "enable_monitor_client", True)
if not enable_monitor_client:
self.logger.info("CEPH monitor client is disabled")
return
monitor_client = '/usr/bin/ceph-nvmeof-monitor-client'
client_prefix = "client."
rados_id = self.config.get_with_default("ceph", "id", "client.admin")
if not rados_id.startswith(client_prefix):
rados_id = client_prefix + rados_id
cmd = [ monitor_client,
cmd = [ self.monitor_client,
"--gateway-name", self.name,
"--gateway-address", self._gateway_address(),
"--gateway-pool", self.config.get("ceph", "pool"),
Expand Down

0 comments on commit 6b3774b

Please sign in to comment.