]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
mon/MonClient: improve error message when failing to auth
authorPatrick Donnelly <pdonnell@ibm.com>
Wed, 14 May 2025 23:33:43 +0000 (19:33 -0400)
committerPatrick Donnelly <pdonnell@ibm.com>
Wed, 1 Oct 2025 18:47:09 +0000 (14:47 -0400)
Currently you just see:

    2025-05-14T23:07:37.244+0000 7f00dedd1640 -1 monclient(hunting): handle_auth_bad_method server allowed_methods [2] but i only support [2]

which is terrible at communicating the problem.

Signed-off-by: Patrick Donnelly <pdonnell@ibm.com>
src/mon/MonClient.cc

index bb33c4961883d029b5cf27cd5ba370eb705a360e..16839cfc78cf3aa288a9d8fb48213dcd2f19f3eb 100644 (file)
@@ -1918,8 +1918,16 @@ int MonConnection::handle_auth_bad_method(
   p = std::find_first_of(std::next(p), auth_supported.end(),
                         allowed_methods.begin(), allowed_methods.end());
   if (p == auth_supported.end()) {
-    lderr(cct) << __func__ << " server allowed_methods " << allowed_methods
-              << " but i only support " << auth_supported << dendl;
+    auto s_allowed_methods = std::set<uint32_t>(allowed_methods.begin(), allowed_methods.end());
+    auto s_auth_supported = std::set<uint32_t>(auth_supported.begin(), auth_supported.end());
+    bool is_subset = std::includes(s_allowed_methods.begin(), s_allowed_methods.end(),
+                                   s_auth_supported.begin(), s_auth_supported.end());
+    if (!is_subset) {
+      lderr(cct) << __func__ << " server allowed_methods " << allowed_methods
+                << " and I support " << auth_supported << dendl;
+    } else {
+      lderr(cct) << __func__ << " failed to auth with my available methods: " << cpp_strerror(result) << dendl;
+    }
     return handle_auth_failure(cct);
   }
   auth_method = *p;