From be45066d08ad0d3558a845e0e8aa4bec9278d68e Mon Sep 17 00:00:00 2001 From: Yury Luneff Date: Tue, 20 Oct 2026 10:37:33 +0300 Subject: [PATCH] Fix missing space in vitastor-cli rm-osd "still up" message rm-osd printed "OSD 1is still up" and "OSDs 2, 3are still up" because the verb was appended to the OSD list without a space. Also say "it" instead of "them" when only one OSD is up. --- src/cmd/cli_rm_osd.cpp | 3 ++- tests/run_tests.sh | 2 ++ tests/test_rm_osd_msg.sh | 14 ++++++++++++++ 3 files changed, 18 insertions(+), 1 deletion(-) create mode 100755 tests/test_rm_osd_msg.sh diff --git a/src/cmd/cli_rm_osd.cpp b/src/cmd/cli_rm_osd.cpp index 5a2f0f2c..3521a6d6 100644 --- a/src/cmd/cli_rm_osd.cpp +++ b/src/cmd/cli_rm_osd.cpp @@ -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) diff --git a/tests/run_tests.sh b/tests/run_tests.sh index d72fcf78..8f0d0602 100755 --- a/tests/run_tests.sh +++ b/tests/run_tests.sh @@ -66,6 +66,8 @@ 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 diff --git a/tests/test_rm_osd_msg.sh b/tests/test_rm_osd_msg.sh new file mode 100755 index 00000000..edc58c4e --- /dev/null +++ b/tests/test_rm_osd_msg.sh @@ -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 -- 2.47.3