Skip to content

Commit cacc5f5

Browse files
committed
[3AZ Stretch pool]: Allow user to specify values when unsetting pools
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 <[email protected]>
1 parent 844e80b commit cacc5f5

File tree

2 files changed

+37
-1
lines changed

2 files changed

+37
-1
lines changed

src/mon/MonCommands.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1234,7 +1234,10 @@ COMMAND("osd pool stretch set "
12341234
"make the pool stretched across the specified number of CRUSH buckets",
12351235
"osd", "rw")
12361236
COMMAND("osd pool stretch unset "
1237-
"name=pool,type=CephPoolname",
1237+
"name=pool,type=CephPoolname "
1238+
"name=crush_rule,type=CephString "
1239+
"name=size,type=CephInt,range=0 "
1240+
"name=min_size,type=CephInt,range=0 ",
12381241
"unset the stretch mode for the pool",
12391242
"osd", "rw")
12401243
COMMAND("osd utilization",

src/mon/OSDMonitor.cc

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9237,11 +9237,44 @@ int OSDMonitor::prepare_command_pool_stretch_unset(const cmdmap_t& cmdmap,
92379237
ss << "pool " << pool_name << " is not a stretch pool";
92389238
return -ENOENT;
92399239
}
9240+
CrushWrapper& crush = _get_stable_crush();
9241+
string crush_rule_str;
9242+
cmd_getval(cmdmap, "crush_rule", crush_rule_str);
9243+
if (crush_rule_str.empty()) {
9244+
ss << "crush_rule must be provided";
9245+
return -EINVAL;
9246+
}
9247+
9248+
int crush_rule = crush.get_rule_id(crush_rule_str);
9249+
if (crush_rule < 0) {
9250+
ss << "crush rule " << crush_rule_str << " does not exist";
9251+
return -ENOENT;
9252+
}
9253+
9254+
if (!crush.rule_valid_for_pool_type(crush_rule, p.get_type())) {
9255+
ss << "crush rule " << crush_rule << " type does not match pool";
9256+
return -EINVAL;
9257+
}
9258+
9259+
int64_t pool_size = cmd_getval_or<int64_t>(cmdmap, "size", 0);
9260+
if (pool_size < 0) {
9261+
ss << "pool size must be non-negative";
9262+
return -EINVAL;
9263+
}
9264+
9265+
int64_t pool_min_size = cmd_getval_or<int64_t>(cmdmap, "min_size", 0);
9266+
if (pool_min_size < 0) {
9267+
ss << "pool min_size must be non-negative";
9268+
return -EINVAL;
9269+
}
92409270

92419271
// unset stretch values
92429272
p.peering_crush_bucket_count = 0;
92439273
p.peering_crush_bucket_target = 0;
92449274
p.peering_crush_bucket_barrier = 0;
9275+
p.crush_rule = static_cast<__u8>(crush_rule);
9276+
p.size = static_cast<__u8>(pool_size);
9277+
p.min_size = static_cast<__u8>(pool_min_size);
92459278
p.last_change = pending_inc.epoch;
92469279
pending_inc.new_pools[pool] = p;
92479280
ss << "pool " << pool_name

0 commit comments

Comments
 (0)