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 59 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

@@ -251,7 +251,7 @@ resume_1:
{ "title", "MISPLACED" },
});
cols.push_back(json11::Json::object{
{ "key", "fmt_degraded" },
{ "key", "fmt_misplaced" },
{ "title", "DEGRADED" },
});
cols.push_back(json11::Json::object{
@@ -273,8 +273,6 @@ resume_1:
load_pg_stats();
if (parent->waiting > 0)
return;
if (state == 100)
return;
format_pgs();
state = 100;
}

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

@@ -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
@@ -61,7 +63,6 @@ OLD=1 SCHEME=ec ./test_snapshot.sh
OLD=1 ./test_move_reappear.sh
./test_degraded.sh
./test_pg_ls.sh
./test_rm.sh

View File

@@ -1,47 +0,0 @@
#!/bin/bash -ex
# Test vitastor-cli ls-pgs on degraded PGs
PG_COUNT=4
PG_SIZE=3
PG_MINSIZE=2
# Keep degraded objects until the checks are done
GLOBAL_CONFIG=',"no_recovery":true'
. `dirname $0`/run_3osds.sh
$VITASTOR_CLI create -s 32M testimg
# Data written while OSD 3 is down is degraded when it comes back
kill -9 $OSD3_PID
$ETCDCTL del /vitastor/osd/state/3
wait_condition 60 "$ETCDCTL get --prefix /vitastor/pg/state/ --print-value-only | jq -s -e '[ .[] | select(.state | index(\"degraded\")) ] | length == $PG_COUNT'" "PG peering without OSD 3"
$VITASTOR_CLI dd if=/dev/urandom oimg=testimg bs=1M count=32
start_osd 3
wait_condition 60 "$ETCDCTL get --prefix /vitastor/pgstats/ --print-value-only | jq -s -e '[ .[] | select(.degraded_count > 0) ] | length == $PG_COUNT'" "PG degradation"
$VITASTOR_CLI ls-pgs
# NUM and DEGRADED of every PG from the table, and degraded_count from JSON
$VITASTOR_CLI ls-pgs | awk 'NR == 1 { n = index($0, "NUM"); d = index($0, "DEGRADED"); e = index($0, "INCOMPLETE") }
NR > 1 { num = substr($0, n); sub(/ .*/, "", num); deg = substr($0, d, e-d); sub(/ +$/, "", deg); print num " " deg }' > ./testdata/pg_ls.txt
$VITASTOR_CLI ls-pgs --json | jq -r '.[] | "\(.pg_num) \(.degraded_count // 0)"' > ./testdata/pg_ls_json.txt
if [[ $(wc -l < ./testdata/pg_ls.txt) != $PG_COUNT ]]; then
format_error "ls-pgs should list $PG_COUNT PGs"
fi
while read num count; do
shown=$(awk '$1 == '$num' { $1 = ""; sub(/^ /, ""); print }' ./testdata/pg_ls.txt)
if [[ -z "$shown" || $count -gt 0 && "$shown" = "0 B" || $count -eq 0 && "$shown" != "0 B" ]]; then
format_error "ls-pgs shows DEGRADED=$shown for PG $num with $count degraded objects"
fi
done < ./testdata/pg_ls_json.txt
# An unknown pool is an error, not an empty table
if out=$($VITASTOR_CLI ls-pgs --pool nosuchpool 2>&1); then
format_error "ls-pgs should fail for an unknown pool"
fi
if [[ "$out" != "Pool nosuchpool not found" ]]; then
format_error "ls-pgs prints '$out' instead of the unknown pool error"
fi
format_green OK

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