]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
librados: fall back to legacy blacklist command if blocklist gets EINVAL
authorSage Weil <sage@newdream.net>
Fri, 26 Jun 2020 22:04:51 +0000 (17:04 -0500)
committerNeha Ojha <nojha@redhat.com>
Mon, 24 Aug 2020 19:53:08 +0000 (19:53 +0000)
I would have expected ENOSYS or EOPNOTSUPP or similar, but the mon returns
EINVAL on an unrecognized command

Signed-off-by: Sage Weil <sage@newdream.net>
src/librados/RadosClient.cc

index c87e08f22c3860f8b4f2ed04bb4d99339d4e4838..79f83e36873e7a53ef846bdf043da1d13a7156de 100644 (file)
@@ -800,8 +800,22 @@ int librados::RadosClient::blocklist_add(const string& client_address,
   cmds.push_back(cmd.str());
   bufferlist inbl;
   int r = mon_command(cmds, inbl, NULL, NULL);
+  if (r == -EINVAL) {
+    // try legacy blacklist command
+    std::stringstream cmd;
+    cmd << "{"
+       << "\"prefix\": \"osd blacklist\", "
+       << "\"blacklistop\": \"add\", "
+       << "\"addr\": \"" << client_address << "\"";
+    if (expire_seconds != 0) {
+      cmd << ", \"expire\": " << expire_seconds << ".0";
+    }
+    cmd << "}";
+    cmds.clear();
+    cmds.push_back(cmd.str());
+    r = mon_command(cmds, inbl, NULL, NULL);
+  }
   if (r < 0) {
-#warning blocklist fallback
     return r;
   }