From 62f33d5978bc7a99b22f8a2a90c546899e60f386 Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Mon, 30 Sep 2019 10:58:40 -0500 Subject: [PATCH] mon/MonClient: interpret numeric mon target name as rank This allows us to behave when a rank is passed to mon_command(..., target=), which will call rados_mon_command_target() -> MonClient::start_mon_command with a (string) target name. We could make an integer variant of rados_mon_command_target, and do the int vs string differentiation in python, but this is much easier. Signed-off-by: Sage Weil --- src/mon/MonClient.cc | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/mon/MonClient.cc b/src/mon/MonClient.cc index 70b97c5496385..a1a0c7b9b4468 100644 --- a/src/mon/MonClient.cc +++ b/src/mon/MonClient.cc @@ -1340,7 +1340,17 @@ void MonClient::start_mon_command(const string &mon_name, return; } MonCommand *r = new MonCommand(++last_mon_command_tid); - r->target_name = mon_name; + + // detect/tolerate mon *rank* passed as a string + string err; + int rank = strict_strtoll(mon_name.c_str(), 10, &err); + if (err.size() == 0 && rank >= 0) { + ldout(cct,10) << __func__ << " interpreting name '" << mon_name + << "' as rank " << rank << dendl; + r->target_rank = rank; + } else { + r->target_name = mon_name; + } r->cmd = cmd; r->inbl = inbl; r->poutbl = outbl; -- 2.39.5