From a2d38659b30d58f6537e109ad532b8f664d985f2 Mon Sep 17 00:00:00 2001 From: Patrick Donnelly Date: Wed, 14 May 2025 19:33:43 -0400 Subject: [PATCH] mon/MonClient: improve error message when failing to auth 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 --- src/mon/MonClient.cc | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/mon/MonClient.cc b/src/mon/MonClient.cc index 235472c7973..e5ff0723ba5 100644 --- a/src/mon/MonClient.cc +++ b/src/mon/MonClient.cc @@ -1924,8 +1924,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(allowed_methods.begin(), allowed_methods.end()); + auto s_auth_supported = std::set(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; -- 2.47.3