]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
[3AZ Stretch pool]: Allow user to specify values when unsetting pools
authorKamoltat Sirivadhna <ksirivad@redhat.com>
Tue, 5 Nov 2024 20:53:41 +0000 (20:53 +0000)
committerKamoltat Sirivadhna <ksirivad@redhat.com>
Mon, 17 Mar 2025 12:31:03 +0000 (12:31 +0000)
Problem:

When we enable stretched mode on the pools,
we modify 6 configs on the pool,
namely peering_crush_bucket_count,
peering_crush_bucket_target,
peering_crush_bucket_barrier,
crush_rule, size, min_size.

Out of these, only 3 configs,
namely peering_crush_bucket_count,
peering_crush_bucket_target,
peering_crush_bucket_barrier is reset to 0.

The remaining 3 configs,
namely crush_rule, size,
min_size are not reverted back,
and are still the values that were set with stretch set command.

Solution:

The unset command now is required
to specify `crush_rule`, `size`, `min_size`.

Fixes: https://tracker.ceph.com/issues/68842
Signed-off-by: Kamoltat Sirivadhna <ksirivad@redhat.com>
src/mon/MonCommands.h
src/mon/OSDMonitor.cc

index a53d1adce9e2adc49263585d9cbb189670251961..7aa9fb58d74989a8c3ac47c3bd4357caa25e8b64 100644 (file)
@@ -1234,7 +1234,10 @@ COMMAND("osd pool stretch set "
         "make the pool stretched across the specified number of CRUSH buckets",
         "osd", "rw")
 COMMAND("osd pool stretch unset "
-               "name=pool,type=CephPoolname",
+               "name=pool,type=CephPoolname "
+               "name=crush_rule,type=CephString "
+               "name=size,type=CephInt,range=0 "
+               "name=min_size,type=CephInt,range=0 ",
                "unset the stretch mode for the pool",
                "osd", "rw")
 COMMAND("osd utilization",
index 4807f9dd166d314396a372a117d214f43ac6fe83..4bff8b3bb4b1f18839b86c16e0833afaf47080ac 100644 (file)
@@ -9237,11 +9237,44 @@ int OSDMonitor::prepare_command_pool_stretch_unset(const cmdmap_t& cmdmap,
     ss << "pool " << pool_name << " is not a stretch pool";
     return -ENOENT;
   }
+  CrushWrapper& crush = _get_stable_crush();
+  string crush_rule_str;
+  cmd_getval(cmdmap, "crush_rule", crush_rule_str);
+  if (crush_rule_str.empty()) {
+    ss << "crush_rule must be provided";
+    return -EINVAL;
+  }
+
+  int crush_rule = crush.get_rule_id(crush_rule_str);
+  if (crush_rule < 0) {
+    ss << "crush rule " << crush_rule_str << " does not exist";
+    return -ENOENT;
+  }
+
+  if (!crush.rule_valid_for_pool_type(crush_rule, p.get_type())) {
+    ss << "crush rule " << crush_rule << " type does not match pool";
+    return -EINVAL;
+  }
+
+  int64_t pool_size = cmd_getval_or<int64_t>(cmdmap, "size", 0);
+  if (pool_size < 0) {
+    ss << "pool size must be non-negative";
+    return -EINVAL;
+  }
+
+  int64_t pool_min_size = cmd_getval_or<int64_t>(cmdmap, "min_size", 0);
+  if (pool_min_size < 0) {
+    ss << "pool min_size must be non-negative";
+    return -EINVAL;
+  }
 
   // unset stretch values
   p.peering_crush_bucket_count = 0;
   p.peering_crush_bucket_target = 0;
   p.peering_crush_bucket_barrier = 0;
+  p.crush_rule = static_cast<__u8>(crush_rule);
+  p.size = static_cast<__u8>(pool_size);
+  p.min_size = static_cast<__u8>(pool_min_size);
   p.last_change = pending_inc.epoch;
   pending_inc.new_pools[pool] = p;
   ss << "pool " << pool_name