forked from vitalif/vitastor
Compare commits
1 Commits
cli-pg-siz
...
cli-pool-r
| Author | SHA1 | Date | |
|---|---|---|---|
| a763d2d467 |
@@ -410,8 +410,8 @@ Create a pool. Required parameters:
|
||||
|
||||
| <!-- --> | <!-- --> |
|
||||
|--------------------------|-----------------------------------------------------------------------------------------|
|
||||
| `-s R` or `--pg_size R` | Number of replicas for replicated pools, from 1 to 64 |
|
||||
| `--ec N+K` | Number of data (N) and parity (K) chunks for erasure-coded pools, N+K from 3 to 64 |
|
||||
| `-s R` or `--pg_size R` | Number of replicas for replicated pools |
|
||||
| `--ec N+K` | Number of data (N) and parity (K) chunks for erasure-coded pools |
|
||||
| `-n N` or `--pg_count N` | PG count for the new pool (start with 10*\<OSD count\>/pg_size rounded to a power of 2) |
|
||||
|
||||
Optional parameters:
|
||||
@@ -470,6 +470,8 @@ 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`
|
||||
|
||||
@@ -429,8 +429,8 @@ OSD PARENT UP SIZE USED% TAGS WEIGHT BLOCK BITMAP
|
||||
|
||||
| <!-- --> | <!-- --> |
|
||||
|---------------------------|-----------------------------------------------------------------------------------------------|
|
||||
| `-s R` или `--pg_size R` | Число копий данных для реплицированных пулов, от 1 до 64 |
|
||||
| `--ec N+K` | Число частей данных (N) и чётности (K) для пулов с кодами коррекции ошибок, N+K от 3 до 64 |
|
||||
| `-s R` или `--pg_size R` | Число копий данных для реплицированных пулов |
|
||||
| `--ec N+K` | Число частей данных (N) и чётности (K) для пулов с кодами коррекции ошибок |
|
||||
| `-n N` или `--pg_count N` | Число PG для нового пула (начните с 10*\<число OSD\>/pg_size, округлённого до степени двойки) |
|
||||
|
||||
Необязательные параметры:
|
||||
@@ -487,6 +487,8 @@ OSD PARENT UP SIZE USED% TAGS WEIGHT BLOCK BITMAP
|
||||
|
||||
Описания параметров смотрите в [create-pool](#create-pool).
|
||||
|
||||
Переименование с --name завершается ошибкой, если у другого пула уже есть такое имя.
|
||||
|
||||
Примеры:
|
||||
|
||||
`vitastor-cli modify-pool pool_A --name pool_B`
|
||||
|
||||
@@ -197,8 +197,8 @@ static const char* help_text =
|
||||
"\n"
|
||||
"vitastor-cli create-pool|pool-create <name> (-s <pg_size>|--ec <N>+<K>) -n <pg_count> [OPTIONS]\n"
|
||||
" Create a pool. Required parameters:\n"
|
||||
" -s|--pg_size R Number of replicas for replicated pools, from 1 to 64\n"
|
||||
" --ec N+K Number of data (N) and parity (K) chunks for erasure-coded pools, N+K from 3 to 64\n"
|
||||
" -s|--pg_size R Number of replicas for replicated pools\n"
|
||||
" --ec N+K Number of data (N) and parity (K) chunks for erasure-coded pools\n"
|
||||
" -n|--pg_count N PG count for the new pool (start with 10*<OSD count>/pg_size rounded to a power of 2)\n"
|
||||
" Optional parameters:\n"
|
||||
" --pg_minsize <number> R or N+K minus number of failures to tolerate without downtime\n"
|
||||
@@ -235,6 +235,7 @@ 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"
|
||||
|
||||
@@ -233,10 +233,9 @@ std::string validate_pool_config(json11::Json::object & new_cfg, json11::Json ol
|
||||
{
|
||||
return "PG size can't be smaller than 3 for EC/XOR pools";
|
||||
}
|
||||
// same limit as in etcd_state_client.cpp and mon/pool_config.js
|
||||
if (pg_size > 64)
|
||||
if (pg_size > 256)
|
||||
{
|
||||
return "PG size can't be greater than 64";
|
||||
return "PG size can't be greater than 256";
|
||||
}
|
||||
|
||||
// PG rules
|
||||
|
||||
@@ -117,6 +117,22 @@ 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,6 +18,8 @@ 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
|
||||
|
||||
@@ -48,8 +50,6 @@ OLD=1 SCHEME=ec IMMEDIATE_COMMIT=1 ./test_interrupted_rebalance.sh
|
||||
|
||||
./test_failure_domain.sh
|
||||
|
||||
./test_pool_pg_size_limit.sh
|
||||
|
||||
./test_level_placement.sh
|
||||
|
||||
./test_snapshot.sh
|
||||
|
||||
34
tests/test_modify_pool_name.sh
Executable file
34
tests/test_modify_pool_name.sh
Executable file
@@ -0,0 +1,34 @@
|
||||
#!/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
|
||||
@@ -1,27 +0,0 @@
|
||||
#!/bin/bash -ex
|
||||
|
||||
# Test that create-pool and modify-pool refuse pg_size > 64, which OSDs and clients don't support
|
||||
|
||||
. `dirname $0`/common.sh
|
||||
|
||||
wait_etcd
|
||||
|
||||
$ETCDCTL put /vitastor/config/pools '{"1":{"name":"testpool","scheme":"replicated","pg_size":2,"pg_minsize":1,"pg_count":1,"failure_domain":"osd"}}'
|
||||
|
||||
for args in "create-pool bigpool -s 65 -n 1 --force" "create-pool bigpool --ec 62+3 -n 1 --force" "modify-pool testpool -s 65"; do
|
||||
r=0
|
||||
$VITASTOR_CLI $args || r=$?
|
||||
if [[ $r != 22 ]]; then
|
||||
format_error "$args should fail with EINVAL (22), but exited with $r"
|
||||
fi
|
||||
done
|
||||
|
||||
$ETCDCTL get --print-value-only /vitastor/config/pools | jq -e 'keys == ["1"] and .["1"].pg_size == 2' || \
|
||||
format_error "Pool configuration should not change after refused commands"
|
||||
|
||||
# 64 is still accepted
|
||||
$VITASTOR_CLI modify-pool testpool -s 64
|
||||
$ETCDCTL get --print-value-only /vitastor/config/pools | jq -e '.["1"].pg_size == 64' || \
|
||||
format_error "modify-pool -s 64 should set pg_size to 64"
|
||||
|
||||
format_green OK
|
||||
Reference in New Issue
Block a user