]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
mon: fix some erroneous safety asserts in OSDMonitor::try_enable_stretch_mode
authorGreg Farnum <gfarnum@redhat.com>
Tue, 8 Dec 2020 23:28:50 +0000 (23:28 +0000)
committerGreg Farnum <gfarnum@redhat.com>
Thu, 10 Dec 2020 14:35:15 +0000 (14:35 +0000)
This function asserts it is not committing in error cases, because it is supposed
to be run first in a trial mode, and then in a commit mode. But I wanted the
asserts to be more informative than that when they are printed, so I included
the failure condition as an OR clause in the assert.

Unfortunately, a few of them were either written wrong or became wrong due to
code movement. Fix these so they are valid and convey the desired information.

Reported-by: Ronen Friedman <rfriedma@redhat.com>
Signed-off-by: Greg Farnum <gfarnum@redhat.com>
src/mon/OSDMonitor.cc

index e6d09366d04d3da0b2452233d61ebb46e79d673b..8c8babfd47d7d5c590763700c64c778df7d21f47 100644 (file)
@@ -14369,7 +14369,7 @@ void OSDMonitor::try_enable_stretch_mode(stringstream& ss, bool *okay,
   if (retval == -1) {
     ss << dividing_bucket << " is not a valid crush bucket type";
     *errcode = -ENOENT;
-    ceph_assert(!commit || dividing_id != -1);
+    ceph_assert(!commit || retval != -1);
     return;
   }
   vector<int> subtrees;
@@ -14386,7 +14386,7 @@ void OSDMonitor::try_enable_stretch_mode(stringstream& ss, bool *okay,
   if (new_crush_rule_result < 0) {
     ss << "unrecognized crush rule " << new_crush_rule;
     *errcode = new_crush_rule_result;
-    ceph_assert(!commit || new_crush_rule_result);
+    ceph_assert(!commit || (new_crush_rule_result > 0));
     return;
   }
   __u8 new_rule = static_cast<__u8>(new_crush_rule_result);
@@ -14406,7 +14406,7 @@ void OSDMonitor::try_enable_stretch_mode(stringstream& ss, bool *okay,
   if (bucket_count != 2) {
     ss << "currently we only support 2-site stretch clusters!";
     *errcode = -EINVAL;
-    ceph_assert(!commit);
+    ceph_assert(!commit || bucket_count == 2);
     return;
   }
   // TODO: check CRUSH rules for pools so that we are appropriately divided