Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

control/server.py: log monitor client version on start up #618

Merged
merged 1 commit into from
May 2, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading