Compare commits

..

1 Commits

Author SHA1 Message Date
b5e5b6af01 Limit pg_size to 64 in vitastor-cli create-pool and modify-pool
The CLI accepted pg_size up to 256, but clients and OSDs skip a pool
with pg_size > 64 and the monitor refuses it, so such a pool was
created or switched to a size nobody could serve, without an error.
Refuse pg_size > 64 with EINVAL, also with --force.
2026-10-25 16:10:29 +03:00
8 changed files with 39 additions and 26 deletions

View File

@@ -410,8 +410,8 @@ Create a pool. Required parameters:
| <!-- --> | <!-- --> |
|--------------------------|-----------------------------------------------------------------------------------------|
| `-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 |
| `-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 |
| `-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:

View File

@@ -429,8 +429,8 @@ OSD PARENT UP SIZE USED% TAGS WEIGHT BLOCK BITMAP
| <!-- --> | <!-- --> |
|---------------------------|-----------------------------------------------------------------------------------------------|
| `-s R` или `--pg_size R` | Число копий данных для реплицированных пулов |
| `--ec N+K` | Число частей данных (N) и чётности (K) для пулов с кодами коррекции ошибок |
| `-s R` или `--pg_size R` | Число копий данных для реплицированных пулов, от 1 до 64 |
| `--ec N+K` | Число частей данных (N) и чётности (K) для пулов с кодами коррекции ошибок, N+K от 3 до 64 |
| `-n N` или `--pg_count N` | Число PG для нового пула (начните с 10*\<число OSD\>/pg_size, округлённого до степени двойки) |
Необязательные параметры:

View File

@@ -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\n"
" --ec N+K Number of data (N) and parity (K) chunks for erasure-coded pools\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"
" -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"

View File

@@ -233,9 +233,10 @@ 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";
}
if (pg_size > 256)
// same limit as in etcd_state_client.cpp and mon/pool_config.js
if (pg_size > 64)
{
return "PG size can't be greater than 256";
return "PG size can't be greater than 64";
}
// PG rules

View File

@@ -170,8 +170,7 @@ struct rm_osd_t
}
if (still_up.size() && !allow_up)
error += (still_up.size() == 1 ? "OSD " : "OSDs ") + implode(", ", still_up) +
(still_up.size() == 1 ? " is" : " are") + " still up. Use `vitastor-disk purge` to delete " +
(still_up.size() == 1 ? "it" : "them") + ".\n";
(still_up.size() == 1 ? "is" : "are") + " still up. Use `vitastor-disk purge` to delete them.\n";
if (is_dataloss && !force_dataloss && !dry_run)
error += "OSDs not deleted. Please move data to other OSDs or bypass this check with --allow-data-loss if you know what you are doing.\n";
else if (is_warning && !force_warning && !dry_run)

View File

@@ -48,6 +48,8 @@ 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
@@ -66,8 +68,6 @@ OLD=1 ./test_move_reappear.sh
./test_rm_degraded.sh
./test_rm_osd_msg.sh
./test_snapshot_chain.sh
SCHEME=ec ./test_snapshot_chain.sh
ENCRYPTED=1 ./test_snapshot_chain.sh

View File

@@ -0,0 +1,27 @@
#!/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

View File

@@ -1,14 +0,0 @@
#!/bin/bash -ex
# Test the rm-osd message for OSDs that are still up
. `dirname $0`/run_3osds.sh
$VITASTOR_CLI rm-osd --dry-run 1 > ./testdata/one.txt 2>&1 && format_error "rm-osd of an up OSD was not refused"
cat ./testdata/one.txt
grep -q '^OSD 1 is still up\. Use `vitastor-disk purge` to delete it\.$' ./testdata/one.txt || format_error "bad message for one OSD"
$VITASTOR_CLI rm-osd --dry-run 1 2 > ./testdata/two.txt 2>&1 && format_error "rm-osd of up OSDs was not refused"
cat ./testdata/two.txt
grep -q '^OSDs 1, 2 are still up\. Use `vitastor-disk purge` to delete them\.$' ./testdata/two.txt || format_error "bad message for two OSDs"
format_green OK