forked from vitalif/vitastor
Compare commits
1 Commits
cli-modify
...
cli-rm-osd
| Author | SHA1 | Date | |
|---|---|---|---|
| be45066d08 |
@@ -287,20 +287,7 @@ std::function<bool(cli_result_t &)> cli_tool_t::start_modify(json11::Json cfg)
|
||||
changer->parent = this;
|
||||
changer->image_name = cfg["image"].string_value();
|
||||
changer->new_name = cfg["rename"].string_value();
|
||||
if (!cfg["resize"].is_null())
|
||||
{
|
||||
bool ok = false;
|
||||
changer->new_size = parse_size(cfg["resize"].as_string(), &ok);
|
||||
if (!ok)
|
||||
{
|
||||
delete changer;
|
||||
return [size = cfg["resize"].as_string()](cli_result_t & result)
|
||||
{
|
||||
result = (cli_result_t){ .err = EINVAL, .text = "Invalid syntax for size: "+size };
|
||||
return true;
|
||||
};
|
||||
}
|
||||
}
|
||||
changer->new_size = parse_size(cfg["resize"].as_string());
|
||||
changer->force_size = cfg["force_size"].bool_value();
|
||||
changer->inc_size = cfg["inc_size"].bool_value();
|
||||
changer->force = cfg["force"].bool_value();
|
||||
|
||||
@@ -170,7 +170,8 @@ 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 them.\n";
|
||||
(still_up.size() == 1 ? " is" : " are") + " still up. Use `vitastor-disk purge` to delete " +
|
||||
(still_up.size() == 1 ? "it" : "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)
|
||||
|
||||
@@ -64,10 +64,10 @@ OLD=1 ./test_move_reappear.sh
|
||||
|
||||
./test_rm.sh
|
||||
|
||||
./test_modify_image_resize.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
|
||||
|
||||
@@ -1,28 +0,0 @@
|
||||
#!/bin/bash -ex
|
||||
|
||||
# Test that modify refuses an invalid --resize value instead of ignoring it
|
||||
|
||||
. `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"}}'
|
||||
|
||||
$VITASTOR_CLI create -s 1G --pool testpool testimg
|
||||
|
||||
for size in 1.5G 10X abc ''; do
|
||||
r=0
|
||||
$VITASTOR_CLI modify testimg --resize "$size" || r=$?
|
||||
if [[ $r != 22 ]]; then
|
||||
format_error "modify --resize '$size' should fail with EINVAL (22), but exited with $r"
|
||||
fi
|
||||
done
|
||||
|
||||
$ETCDCTL get --print-value-only /vitastor/config/inode/1/1 | jq -e '.size == 1073741824' || \
|
||||
format_error "Image size should stay 1G after refused resizes"
|
||||
|
||||
$VITASTOR_CLI modify testimg --resize 2G
|
||||
$ETCDCTL get --print-value-only /vitastor/config/inode/1/1 | jq -e '.size == 2147483648' || \
|
||||
format_error "Image size should be 2G after --resize 2G"
|
||||
|
||||
format_green OK
|
||||
14
tests/test_rm_osd_msg.sh
Executable file
14
tests/test_rm_osd_msg.sh
Executable file
@@ -0,0 +1,14 @@
|
||||
#!/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
|
||||
Reference in New Issue
Block a user