]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mon/Monitor: Validate monitor ids during 'mon ok-to-stop' cmd 44839/head
authorNitzan Mordechai <nmordech@redhat.com>
Mon, 31 Jan 2022 07:50:46 +0000 (09:50 +0200)
committerNitzanMordhai <nmordech@redhat.com>
Sun, 6 Mar 2022 11:56:36 +0000 (11:56 +0000)
'mon ok-to-stop' should validate the user provided ids before proceeding further

Fixed:  https://tracker.ceph.com/issues/54122
Signed-off-by: Nitzan Mordechai <nmordech@redhat.com>
src/mon/Monitor.cc

index d1e54d36c7bfa2a59099160a2cb749252f706f16..df895a2016c9cdd9777a12e8bbde9c8c1af462c4 100644 (file)
@@ -3829,7 +3829,7 @@ void Monitor::handle_command(MonOpRequestRef op)
     rs = "";
     r = 0;
   } else if (prefix == "mon ok-to-stop") {
-    vector<string> ids;
+    vector<string> ids, invalid_ids;
     if (!cmd_getval(cmdmap, "ids", ids)) {
       r = -EINVAL;
       goto out;
@@ -3841,8 +3841,16 @@ void Monitor::handle_command(MonOpRequestRef op)
     for (auto& n : ids) {
       if (monmap->contains(n)) {
        wouldbe.erase(n);
+      } else {
+        invalid_ids.push_back(n);
       }
     }
+    if (!invalid_ids.empty()) {
+      r = 0;
+      rs = "invalid mon(s) specified: " + stringify(invalid_ids);
+      goto out;
+    }
+
     if (wouldbe.size() < monmap->min_quorum_size()) {
       r = -EBUSY;
       rs = "not enough monitors would be available (" + stringify(wouldbe) +