Fix node folding in case of empty rules (pool with size 1), add a test
This commit is contained in:
@@ -34,7 +34,7 @@ function fold_failure_domains(node_list, rules)
|
|||||||
folded = false;
|
folded = false;
|
||||||
for (const node_id in per_parent)
|
for (const node_id in per_parent)
|
||||||
{
|
{
|
||||||
const fold_node = per_parent[node_id].filter(child => per_parent[child.id||''] || interest[child.level]).length == 0;
|
const fold_node = node_id !== '' && per_parent[node_id].length > 0 && per_parent[node_id].filter(child => per_parent[child.id||''] || interest[child.level]).length == 0;
|
||||||
if (fold_node)
|
if (fold_node)
|
||||||
{
|
{
|
||||||
const old_node = node_map[node_id];
|
const old_node = node_map[node_id];
|
||||||
|
|||||||
@@ -36,6 +36,18 @@ async function run()
|
|||||||
[ [ [ 'dc' ], [ 'host' ] ] ]
|
[ [ [ 'dc' ], [ 'host' ] ] ]
|
||||||
), 0, 2));
|
), 0, 2));
|
||||||
|
|
||||||
|
console.log('\nfold_failure_domains empty rules');
|
||||||
|
console.log(JSON.stringify(fold_failure_domains(
|
||||||
|
[
|
||||||
|
{ id: 1, level: 'osd', size: 1, parent: 'disk1' },
|
||||||
|
{ id: 2, level: 'osd', size: 2, parent: 'disk1' },
|
||||||
|
{ id: 'disk1', level: 'disk', parent: 'host1' },
|
||||||
|
{ id: 'host1', level: 'host', parent: 'dc1' },
|
||||||
|
{ id: 'dc1', level: 'dc' },
|
||||||
|
],
|
||||||
|
[]
|
||||||
|
), 0, 2));
|
||||||
|
|
||||||
console.log('\noptimize_folded');
|
console.log('\noptimize_folded');
|
||||||
// 5 DCs, 2 hosts per DC, 10 OSD per host
|
// 5 DCs, 2 hosts per DC, 10 OSD per host
|
||||||
const nodes = [];
|
const nodes = [];
|
||||||
|
|||||||
@@ -87,6 +87,22 @@ wait_etcd()
|
|||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
|
wait_condition()
|
||||||
|
{
|
||||||
|
sec=$1
|
||||||
|
check=$2
|
||||||
|
proc=$3
|
||||||
|
i=0
|
||||||
|
while [[ $i -lt $sec ]]; do
|
||||||
|
eval "$check" && break
|
||||||
|
if [ $i -eq $sec ]; then
|
||||||
|
format_error "$proc couldn't finish in $sec seconds"
|
||||||
|
fi
|
||||||
|
sleep 1
|
||||||
|
i=$((i+1))
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
if [[ -n "$ANTIETCD" ]]; then
|
if [[ -n "$ANTIETCD" ]]; then
|
||||||
ETCDCTL="node mon/node_modules/.bin/anticli -e $ETCD_URL"
|
ETCDCTL="node mon/node_modules/.bin/anticli -e $ETCD_URL"
|
||||||
MON_PARAMS="--use_antietcd 1 --antietcd_data_dir ./testdata --antietcd_persist_interval 500 $MON_PARAMS"
|
MON_PARAMS="--use_antietcd 1 --antietcd_data_dir ./testdata --antietcd_persist_interval 500 $MON_PARAMS"
|
||||||
|
|||||||
@@ -127,22 +127,6 @@ try_reweight()
|
|||||||
sleep 3
|
sleep 3
|
||||||
}
|
}
|
||||||
|
|
||||||
wait_condition()
|
|
||||||
{
|
|
||||||
sec=$1
|
|
||||||
check=$2
|
|
||||||
proc=$3
|
|
||||||
i=0
|
|
||||||
while [[ $i -lt $sec ]]; do
|
|
||||||
eval "$check" && break
|
|
||||||
if [ $i -eq $sec ]; then
|
|
||||||
format_error "$proc couldn't finish in $sec seconds"
|
|
||||||
fi
|
|
||||||
sleep 1
|
|
||||||
i=$((i+1))
|
|
||||||
done
|
|
||||||
}
|
|
||||||
|
|
||||||
wait_finish_rebalance()
|
wait_finish_rebalance()
|
||||||
{
|
{
|
||||||
sec=$1
|
sec=$1
|
||||||
|
|||||||
@@ -31,4 +31,8 @@ sleep 2
|
|||||||
$ETCDCTL get --prefix /vitastor/pg/config --print-value-only | \
|
$ETCDCTL get --prefix /vitastor/pg/config --print-value-only | \
|
||||||
jq -s -e '([ .[0].items["1"] | .[].osd_set | map_values(. | tonumber) | select((.[0] <= 4) != (.[1] <= 4)) ] | length) == 4'
|
jq -s -e '([ .[0].items["1"] | .[].osd_set | map_values(. | tonumber) | select((.[0] <= 4) != (.[1] <= 4)) ] | length) == 4'
|
||||||
|
|
||||||
|
# test pool with size 1
|
||||||
|
build/src/cmd/vitastor-cli --etcd_address $ETCD_URL create-pool size1pool -s 1 -n 1 --force
|
||||||
|
wait_condition 10 "$ETCDCTL get --prefix /vitastor/pg/config --print-value-only | jq -s -e '.[0].items["'"'"2"'"'"]'"
|
||||||
|
|
||||||
format_green OK
|
format_green OK
|
||||||
|
|||||||
Reference in New Issue
Block a user