From 42389742c22e0bc9eb3426e9309697de85827fe8 Mon Sep 17 00:00:00 2001 From: John Spray Date: Tue, 15 Dec 2015 17:19:30 +0000 Subject: [PATCH] mon: add `osd blacklist clear` This is just like 'blacklist rm' except it removes everything. Useful if you've got a whole bunch of things in your blacklist and you don't want to wait for N "blacklist rm" commands to run. Signed-off-by: John Spray --- qa/workunits/cephtool/test.sh | 6 ++++++ src/mon/MonCommands.h | 2 ++ src/mon/OSDMonitor.cc | 12 ++++++++++++ 3 files changed, 20 insertions(+) diff --git a/qa/workunits/cephtool/test.sh b/qa/workunits/cephtool/test.sh index 5b6fbf25c7f88..8152c6477252b 100755 --- a/qa/workunits/cephtool/test.sh +++ b/qa/workunits/cephtool/test.sh @@ -1008,6 +1008,12 @@ function test_mon_osd() expect_false "ceph osd blacklist $bl/-1" expect_false "ceph osd blacklist $bl/foo" + # Test `clear` + ceph osd blacklist add $bl + ceph osd blacklist ls | grep $bl + ceph osd blacklist clear + expect_false "ceph osd blacklist ls | grep $bl" + # # osd crush # diff --git a/src/mon/MonCommands.h b/src/mon/MonCommands.h index 8d09f91fba040..0a1122d98a589 100644 --- a/src/mon/MonCommands.h +++ b/src/mon/MonCommands.h @@ -456,6 +456,8 @@ COMMAND("osd lspools " \ "name=auid,type=CephInt,req=false", \ "list pools", "osd", "r", "cli,rest") COMMAND("osd blacklist ls", "show blacklisted clients", "osd", "r", "cli,rest") +COMMAND("osd blacklist clear", "clear all blacklisted clients", "osd", "rw", + "cli,rest") COMMAND("osd crush rule list", "list crush rules", "osd", "r", "cli,rest") COMMAND("osd crush rule ls", "list crush rules", "osd", "r", "cli,rest") COMMAND("osd crush rule dump " \ diff --git a/src/mon/OSDMonitor.cc b/src/mon/OSDMonitor.cc index 3e7cd35a164bb..a5bee6a6402ff 100644 --- a/src/mon/OSDMonitor.cc +++ b/src/mon/OSDMonitor.cc @@ -6551,6 +6551,18 @@ done: get_last_committed() + 1)); return true; + } else if (prefix == "osd blacklist clear") { + pending_inc.new_blacklist.clear(); + std::list > blacklist; + osdmap.get_blacklist(&blacklist); + for (const auto &entry : blacklist) { + pending_inc.old_blacklist.push_back(entry.first); + } + ss << " removed all blacklist entries"; + getline(ss, rs); + wait_for_finished_proposal(op, new Monitor::C_Command(mon, op, 0, rs, + get_last_committed() + 1)); + return true; } else if (prefix == "osd blacklist") { string addrstr; cmd_getval(g_ceph_context, cmdmap, "addr", addrstr); -- 2.39.5