From f40269ed40f0519f4be359a6d9fee2e41ad761c6 Mon Sep 17 00:00:00 2001 From: Kamoltat Date: Thu, 22 Sep 2022 03:41:16 +0000 Subject: [PATCH] osd/OSDMap: Check for uneven weights & != 2 buckets stretch mode Added additional health warnings in ``OSDMap::check_health()``. 1. Check for uneven weights of the two dividing buckets if stretch mode is enabled and spit out warnings if true. 2. Check for != 2 buckets if stretch mode is enabled and spit out warnings if true. Fixes: https://tracker.ceph.com/issues/57570 Signed-off-by: Kamoltat (cherry picked from commit 78baf23ea214dce3c1a7cf3f3515706d03f950ed) --- src/osd/OSDMap.cc | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/osd/OSDMap.cc b/src/osd/OSDMap.cc index 2858934f023c1..a263d4c10c6c0 100644 --- a/src/osd/OSDMap.cc +++ b/src/osd/OSDMap.cc @@ -6279,6 +6279,24 @@ void OSDMap::check_health(CephContext *cct, ss.str(), 0); } } + // UNEQUAL_WEIGHT + if (stretch_mode_enabled) { + vector subtrees; + crush->get_subtree_of_type(stretch_mode_bucket, &subtrees); + if (subtrees.size() != 2) { + stringstream ss; + ss << "Stretch mode buckets != 2"; + checks->add("INCORRECT_NUM_BUCKETS_STRETCH_MODE", HEALTH_WARN, ss.str(), 0); + return; + } + int weight1 = crush->get_item_weight(subtrees[0]); + int weight2 = crush->get_item_weight(subtrees[1]); + stringstream ss; + if (weight1 != weight2) { + ss << "Stretch mode buckets have different weights!"; + checks->add("UNEVEN_WEIGHTS_STRETCH_MODE", HEALTH_WARN, ss.str(), 0); + } + } } int OSDMap::parse_osd_id_list(const vector& ls, set *out, -- 2.39.5