forked from vitalif/vitastor
Compare commits
1 Commits
cli-pool-r
...
cli-level-
| Author | SHA1 | Date | |
|---|---|---|---|
| b7efe16836 |
@@ -425,7 +425,7 @@ Optional parameters:
|
||||
| `--block_size 128k` | Put pool only on OSDs with this data block size |
|
||||
| `--bitmap_granularity 4k` | Put pool only on OSDs with this logical sector size |
|
||||
| `--immediate_commit none` | Put pool only on OSDs with this or larger immediate_commit (none < small < all) |
|
||||
| `--level_placement <rules>` | Use additional failure domain rules (example: "dc=112233") |
|
||||
| `--level_placement <rules>` | Use additional failure domain rules (example: "dc=112233", "" to remove) |
|
||||
| `--raw_placement <rules>` | Specify raw PG generation rules ([details](../config/pool.en.md#raw_placement)) |
|
||||
| `--local_reads primary` | Local read policy for replicated pools: primary, nearest or random |
|
||||
| `--primary_affinity_tags tags` | Prefer to put primary copies on OSDs with all specified tags |
|
||||
@@ -470,8 +470,6 @@ These, however, can still be modified with -f|--force.
|
||||
|
||||
See [create-pool](#create-pool) for parameter descriptions.
|
||||
|
||||
Renaming with --name fails if another pool already has the new name.
|
||||
|
||||
Examples:
|
||||
|
||||
`vitastor-cli modify-pool pool_A --name pool_B`
|
||||
|
||||
@@ -444,7 +444,7 @@ OSD PARENT UP SIZE USED% TAGS WEIGHT BLOCK BITMAP
|
||||
| `--block_size 128k` | ...только OSD с данным размером блока |
|
||||
| `--bitmap_granularity 4k` | ...только OSD с данным размером логического сектора |
|
||||
| `--immediate_commit none` | ...только OSD с этим или большим immediate_commit (none < small < all) |
|
||||
| `--level_placement <rules>` | Задать правила дополнительных доменов отказа (пример: "dc=112233") |
|
||||
| `--level_placement <rules>` | Задать правила дополнительных доменов отказа (пример: "dc=112233", "" — удалить) |
|
||||
| `--raw_placement <rules>` | Задать низкоуровневые правила генерации PG ([детали](../config/pool.ru.md#raw_placement)) |
|
||||
| `--local_reads primary` | Политика локальных чтений для реплик: primary, nearest или random |
|
||||
| `--primary_affinity_tags tags` | Предпочитать OSD со всеми данными тегами для роли первичных |
|
||||
@@ -487,8 +487,6 @@ OSD PARENT UP SIZE USED% TAGS WEIGHT BLOCK BITMAP
|
||||
|
||||
Описания параметров смотрите в [create-pool](#create-pool).
|
||||
|
||||
Переименование с --name завершается ошибкой, если у другого пула уже есть такое имя.
|
||||
|
||||
Примеры:
|
||||
|
||||
`vitastor-cli modify-pool pool_A --name pool_B`
|
||||
|
||||
@@ -208,7 +208,7 @@ static const char* help_text =
|
||||
" --block_size 128k Put pool only on OSDs with this data block size\n"
|
||||
" --bitmap_granularity 4k Put pool only on OSDs with this logical sector size\n"
|
||||
" --immediate_commit all Put pool only on OSDs with this or larger immediate_commit (none < small < all)\n"
|
||||
" --level_placement <rules> Use additional failure domain rules (example: \"dc=112233\")\n"
|
||||
" --level_placement <rules> Use additional failure domain rules (example: \"dc=112233\", \"\" to remove)\n"
|
||||
" --raw_placement <rules> Specify raw PG generation rules (see documentation for details)\n"
|
||||
" --local_reads primary Local read policy for replicated pools: primary, nearest or random\n"
|
||||
" --primary_affinity_tags tags Prefer to put primary copies on OSDs with all specified tags\n"
|
||||
@@ -235,7 +235,6 @@ static const char* help_text =
|
||||
" [--immediate_commit <all|small|none>] [--pg_stripe_size <size>]\n"
|
||||
" These, however, can still be modified with -f|--force.\n"
|
||||
" See create-pool for parameter descriptions.\n"
|
||||
" Renaming with --name fails if another pool already has the new name.\n"
|
||||
" Examples:\n"
|
||||
" vitastor-cli modify-pool pool_A --name pool_B\n"
|
||||
" vitastor-cli modify-pool 2 --pg_size 4 -n 128\n"
|
||||
|
||||
@@ -103,24 +103,22 @@ std::string validate_pool_config(json11::Json::object & new_cfg, json11::Json ol
|
||||
// level=rule, level=rule, ...
|
||||
if (!value.is_object())
|
||||
{
|
||||
if (!value.is_null() && !value.is_string())
|
||||
{
|
||||
return key+" must be a string";
|
||||
}
|
||||
json11::Json::object obj;
|
||||
for (auto & item: explode(",", value.string_value(), true))
|
||||
{
|
||||
auto pair = explode("=", item, true);
|
||||
if (pair.size() >= 2)
|
||||
if (pair.size() != 2)
|
||||
{
|
||||
obj[pair[0]] = pair[1];
|
||||
return "--level_placement must be <level>=<rule>[,<level>=<rule>...], but it is "+value.string_value();
|
||||
}
|
||||
obj[pair[0]] = pair[1];
|
||||
}
|
||||
if (obj.size())
|
||||
{
|
||||
value = obj;
|
||||
}
|
||||
else
|
||||
{
|
||||
new_cfg.erase(kv_it++);
|
||||
continue;
|
||||
}
|
||||
// empty value = remove the rules; null keeps the old ones from being merged back
|
||||
value = obj.size() ? json11::Json(obj) : json11::Json();
|
||||
}
|
||||
}
|
||||
else if (key == "osd_tags" || key == "primary_affinity_tags")
|
||||
@@ -169,6 +167,10 @@ std::string validate_pool_config(json11::Json::object & new_cfg, json11::Json ol
|
||||
{
|
||||
new_cfg.erase("local_reads");
|
||||
}
|
||||
if (new_cfg.find("level_placement") != new_cfg.end() && new_cfg["level_placement"].is_null())
|
||||
{
|
||||
new_cfg.erase("level_placement");
|
||||
}
|
||||
|
||||
// Prevent autovivification of object keys. Now we don't modify the config, we just check it
|
||||
json11::Json cfg = new_cfg;
|
||||
|
||||
@@ -117,22 +117,6 @@ resume_1:
|
||||
return;
|
||||
}
|
||||
|
||||
if (new_cfg["name"] != old_cfg["name"])
|
||||
{
|
||||
for (auto & pce: kv.value.object_items())
|
||||
{
|
||||
if (pce.second["name"] == new_cfg["name"])
|
||||
{
|
||||
result = (cli_result_t){
|
||||
.err = EEXIST,
|
||||
.text = "Pool with name \""+new_cfg["name"].string_value()+"\" already exists (ID "+pce.first+")",
|
||||
};
|
||||
state = 100;
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (new_cfg.find("used_for_app") != new_cfg.end() && !force)
|
||||
{
|
||||
// Check that pool doesn't have images
|
||||
|
||||
@@ -18,8 +18,6 @@ SCHEME=ec ./test_change_pg_count.sh
|
||||
|
||||
./test_create_nomaxid.sh
|
||||
|
||||
./test_modify_pool_name.sh
|
||||
|
||||
./test_etcd_fail.sh
|
||||
ANTIETCD=1 ./test_etcd_fail.sh
|
||||
|
||||
|
||||
@@ -36,4 +36,23 @@ $ETCDCTL get --prefix /vitastor/pg/config --print-value-only | \
|
||||
(. | map_values((. - 1) / 2 | floor) | unique | length) == 6 and
|
||||
(. | map_values((. - 1) / 4 | floor) | unique | length) == 3) ] | length) == 32'
|
||||
|
||||
# A malformed --level_placement is refused, an empty one removes the rules
|
||||
r=0
|
||||
$VITASTOR_CLI modify-pool testpool --level_placement rack || r=$?
|
||||
if [[ $r != 22 ]]; then
|
||||
format_error "modify-pool --level_placement rack should fail with EINVAL (22), but exited with $r"
|
||||
fi
|
||||
$ETCDCTL get --print-value-only /vitastor/config/pools | jq -e '.["1"].level_placement == {"rack":"112233"}' || \
|
||||
format_error "level_placement should stay rack=112233 after a refused change"
|
||||
$VITASTOR_CLI modify-pool testpool --level_placement ''
|
||||
$ETCDCTL get --print-value-only /vitastor/config/pools | jq -e '.["1"] | has("level_placement") | not' || \
|
||||
format_error "modify-pool --level_placement '' should remove level_placement"
|
||||
sleep 2
|
||||
if grep -q 'configuration is invalid' ./testdata/mon.log; then
|
||||
format_error "Monitor refused the pool configuration without level_placement"
|
||||
fi
|
||||
$ETCDCTL get --prefix /vitastor/pg/config --print-value-only | \
|
||||
jq -s -e '([ .[0].items["1"] | .[].osd_set | map_values(. | tonumber) | select(
|
||||
(. | map_values((. - 1) / 2 | floor) | unique | length) == 6) ] | length) == 32'
|
||||
|
||||
format_green OK
|
||||
|
||||
@@ -1,34 +0,0 @@
|
||||
#!/bin/bash -ex
|
||||
|
||||
# Test that modify-pool --name refuses to take the name of another pool
|
||||
|
||||
. `dirname $0`/common.sh
|
||||
|
||||
wait_etcd
|
||||
|
||||
POOL='"scheme":"replicated","pg_size":2,"pg_minsize":1,"pg_count":1,"failure_domain":"osd"'
|
||||
$ETCDCTL put /vitastor/config/pools '{"1":{"name":"pool1",'$POOL'},"2":{"name":"pool2",'$POOL'}}'
|
||||
|
||||
for p in pool2 2; do
|
||||
r=0
|
||||
$VITASTOR_CLI modify-pool $p --name pool1 || r=$?
|
||||
if [[ $r != 17 ]]; then
|
||||
format_error "modify-pool $p --name pool1 should fail with EEXIST (17), but exited with $r"
|
||||
fi
|
||||
done
|
||||
|
||||
names=$($ETCDCTL get --print-value-only /vitastor/config/pools | jq -c '[ .[].name ]')
|
||||
if [[ "$names" != '["pool1","pool2"]' ]]; then
|
||||
format_error "Pool names should stay pool1, pool2, but they are $names"
|
||||
fi
|
||||
|
||||
# A free name and the pool's own name are still accepted
|
||||
$VITASTOR_CLI modify-pool pool2 --name pool3
|
||||
$VITASTOR_CLI modify-pool pool3 --name pool3 --pg_count 2
|
||||
|
||||
cfg=$($ETCDCTL get --print-value-only /vitastor/config/pools | jq -c '[ .[] | [ .name, .pg_count ] ]')
|
||||
if [[ "$cfg" != '[["pool1",1],["pool3",2]]' ]]; then
|
||||
format_error "Pools should be pool1 (1 PG) and pool3 (2 PGs), but they are $cfg"
|
||||
fi
|
||||
|
||||
format_green OK
|
||||
Reference in New Issue
Block a user