forked from vitalif/vitastor
Compare commits
3 Commits
pause-sync
...
cli-descri
| Author | SHA1 | Date | |
|---|---|---|---|
| a85a4febc9 | |||
| 4fa06ef7e1 | |||
| bb0ce4e552 |
@@ -687,7 +687,7 @@ static int run(cli_tool_t *p, json11::Json::object cfg)
|
|||||||
{
|
{
|
||||||
printf("%s\n", result.data.dump().c_str());
|
printf("%s\n", result.data.dump().c_str());
|
||||||
}
|
}
|
||||||
else if (p->json_output && result.err)
|
else if (p->json_output && result.err && !p->json_printed)
|
||||||
{
|
{
|
||||||
printf("%s\n", json11::Json(json11::Json::object {
|
printf("%s\n", json11::Json(json11::Json::object {
|
||||||
{ "error_code", result.err },
|
{ "error_code", result.err },
|
||||||
|
|||||||
@@ -38,6 +38,7 @@ public:
|
|||||||
bool json_output = false;
|
bool json_output = false;
|
||||||
int log_level = 0;
|
int log_level = 0;
|
||||||
bool is_command_line = false;
|
bool is_command_line = false;
|
||||||
|
bool json_printed = false;
|
||||||
bool color = false;
|
bool color = false;
|
||||||
|
|
||||||
std::shared_ptr<user_info_t> user; // for http mode
|
std::shared_ptr<user_info_t> user; // for http mode
|
||||||
|
|||||||
@@ -33,6 +33,13 @@ std::vector<uint64_t> parse_uint64_list(json11::Json val)
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool is_osd_up(cli_tool_t *parent, osd_num_t osd_num)
|
||||||
|
{
|
||||||
|
auto & peer_states = parent->cli->st_cli->peer_states;
|
||||||
|
auto peer_it = peer_states.find(osd_num);
|
||||||
|
return peer_it != peer_states.end() && !peer_it->second.is_null();
|
||||||
|
}
|
||||||
|
|
||||||
struct cli_describe_t
|
struct cli_describe_t
|
||||||
{
|
{
|
||||||
uint64_t object_state = 0;
|
uint64_t object_state = 0;
|
||||||
@@ -41,6 +48,8 @@ struct cli_describe_t
|
|||||||
std::vector<osd_num_t> only_osds;
|
std::vector<osd_num_t> only_osds;
|
||||||
uint64_t min_inode = 0, max_inode = 0;
|
uint64_t min_inode = 0, max_inode = 0;
|
||||||
uint64_t min_offset = 0, max_offset = 0;
|
uint64_t min_offset = 0, max_offset = 0;
|
||||||
|
std::map<osd_num_t, std::string> skipped_pgs;
|
||||||
|
bool incomplete = false;
|
||||||
|
|
||||||
cli_tool_t *parent = NULL;
|
cli_tool_t *parent = NULL;
|
||||||
int state = 0;
|
int state = 0;
|
||||||
@@ -83,19 +92,18 @@ struct cli_describe_t
|
|||||||
}
|
}
|
||||||
only_pg = cfg["pg"].uint64_value();
|
only_pg = cfg["pg"].uint64_value();
|
||||||
min_inode = cfg["inode"].uint64_value();
|
min_inode = cfg["inode"].uint64_value();
|
||||||
|
min_offset = stoull_full(cfg["min_offset"].string_value(), 0);
|
||||||
|
max_offset = stoull_full(cfg["max_offset"].string_value(), 0);
|
||||||
if (min_inode)
|
if (min_inode)
|
||||||
{
|
{
|
||||||
if (!INODE_POOL(min_inode))
|
if (!INODE_POOL(min_inode))
|
||||||
min_inode |= (uint64_t)only_pool << (64-POOL_ID_BITS);
|
min_inode |= (uint64_t)only_pool << (64-POOL_ID_BITS);
|
||||||
max_inode = min_inode;
|
max_inode = min_inode;
|
||||||
min_offset = max_offset = 0;
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
min_inode = stoull_full(cfg["min_inode"].string_value(), 0); // to support 0x...
|
min_inode = stoull_full(cfg["min_inode"].string_value(), 0); // to support 0x...
|
||||||
max_inode = stoull_full(cfg["max_inode"].string_value(), 0);
|
max_inode = stoull_full(cfg["max_inode"].string_value(), 0);
|
||||||
min_offset = stoull_full(cfg["min_offset"].string_value(), 0);
|
|
||||||
max_offset = stoull_full(cfg["max_offset"].string_value(), 0);
|
|
||||||
if (!min_inode && !max_inode && only_pool)
|
if (!min_inode && !max_inode && only_pool)
|
||||||
{
|
{
|
||||||
min_inode = (uint64_t)only_pool << (64-POOL_ID_BITS);
|
min_inode = (uint64_t)only_pool << (64-POOL_ID_BITS);
|
||||||
@@ -103,6 +111,9 @@ struct cli_describe_t
|
|||||||
(((uint64_t)1 << (64-POOL_ID_BITS)) - 1);
|
(((uint64_t)1 << (64-POOL_ID_BITS)) - 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// The OSD ends the listing at (max_inode, max_offset) inclusive
|
||||||
|
if (max_inode && cfg["max_offset"].is_null())
|
||||||
|
max_offset = UINT64_MAX;
|
||||||
only_osds = parse_uint64_list(cfg["osds"]);
|
only_osds = parse_uint64_list(cfg["osds"]);
|
||||||
object_state = stoull_full(cfg["object_state"].string_value(), 0);
|
object_state = stoull_full(cfg["object_state"].string_value(), 0);
|
||||||
if (!object_state && cfg["object_state"].is_string())
|
if (!object_state && cfg["object_state"].is_string())
|
||||||
@@ -158,15 +169,49 @@ struct cli_describe_t
|
|||||||
if (pp.first >= min_pool && (!max_pool || pp.first <= max_pool))
|
if (pp.first >= min_pool && (!max_pool || pp.first <= max_pool))
|
||||||
{
|
{
|
||||||
for (auto & pgp: pp.second.pg_config)
|
for (auto & pgp: pp.second.pg_config)
|
||||||
only_osds.push_back(pgp.second.cur_primary);
|
{
|
||||||
|
if (only_pool && only_pg && (pp.first != only_pool || pgp.first != only_pg))
|
||||||
|
continue;
|
||||||
|
if (is_osd_up(parent, pgp.second.cur_primary))
|
||||||
|
only_osds.push_back(pgp.second.cur_primary);
|
||||||
|
else
|
||||||
|
{
|
||||||
|
auto & pgs = skipped_pgs[pgp.second.cur_primary];
|
||||||
|
pgs += (pgs == "" ? "" : ", ")+std::to_string(pp.first)+"/"+std::to_string(pgp.first);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
for (auto osd_num: only_osds)
|
||||||
|
{
|
||||||
|
if (!is_osd_up(parent, osd_num))
|
||||||
|
skipped_pgs[osd_num] = "";
|
||||||
|
}
|
||||||
|
only_osds.erase(std::remove_if(only_osds.begin(), only_osds.end(), [this](osd_num_t osd_num)
|
||||||
|
{
|
||||||
|
return !is_osd_up(parent, osd_num);
|
||||||
|
}), only_osds.end());
|
||||||
|
}
|
||||||
|
// Requests to an OSD which is down are never answered
|
||||||
|
for (auto & sk: skipped_pgs)
|
||||||
|
{
|
||||||
|
if (!sk.first)
|
||||||
|
fprintf(stderr, "No primary OSD for PG %s, skipping\n", sk.second.c_str());
|
||||||
|
else if (sk.second != "")
|
||||||
|
fprintf(stderr, "OSD %ju is down, skipping PG %s\n", sk.first, sk.second.c_str());
|
||||||
|
else
|
||||||
|
fprintf(stderr, "OSD %ju is down, skipping it\n", sk.first);
|
||||||
|
incomplete = true;
|
||||||
|
}
|
||||||
remove_duplicates(only_osds);
|
remove_duplicates(only_osds);
|
||||||
parent->cli->init_msgr();
|
parent->cli->init_msgr();
|
||||||
if (parent->json_output && parent->is_command_line)
|
if (parent->json_output && parent->is_command_line)
|
||||||
{
|
{
|
||||||
printf("[\n");
|
printf("[\n");
|
||||||
|
parent->json_printed = true;
|
||||||
}
|
}
|
||||||
for (int i = 0; i < only_osds.size(); i++)
|
for (int i = 0; i < only_osds.size(); i++)
|
||||||
{
|
{
|
||||||
@@ -190,6 +235,7 @@ struct cli_describe_t
|
|||||||
{
|
{
|
||||||
if (op->reply.hdr.retval < 0)
|
if (op->reply.hdr.retval < 0)
|
||||||
{
|
{
|
||||||
|
incomplete = true;
|
||||||
fprintf(
|
fprintf(
|
||||||
stderr, "Failed to describe objects on OSD %ju (retval=%jd)\n",
|
stderr, "Failed to describe objects on OSD %ju (retval=%jd)\n",
|
||||||
osd_num, op->reply.hdr.retval
|
osd_num, op->reply.hdr.retval
|
||||||
@@ -197,6 +243,7 @@ struct cli_describe_t
|
|||||||
}
|
}
|
||||||
else if (op->reply.describe.result_bytes != op->reply.hdr.retval * sizeof(osd_reply_describe_item_t))
|
else if (op->reply.describe.result_bytes != op->reply.hdr.retval * sizeof(osd_reply_describe_item_t))
|
||||||
{
|
{
|
||||||
|
incomplete = true;
|
||||||
fprintf(
|
fprintf(
|
||||||
stderr, "Invalid response size from OSD %ju (expected %ju bytes, got %ju bytes)\n",
|
stderr, "Invalid response size from OSD %ju (expected %ju bytes, got %ju bytes)\n",
|
||||||
osd_num, op->reply.hdr.retval * sizeof(osd_reply_describe_item_t), op->reply.describe.result_bytes
|
osd_num, op->reply.hdr.retval * sizeof(osd_reply_describe_item_t), op->reply.describe.result_bytes
|
||||||
@@ -263,6 +310,11 @@ struct cli_describe_t
|
|||||||
{
|
{
|
||||||
result.data = describe_items;
|
result.data = describe_items;
|
||||||
}
|
}
|
||||||
|
if (incomplete)
|
||||||
|
{
|
||||||
|
result.err = EIO;
|
||||||
|
result.text = "The listing is incomplete, see the messages above";
|
||||||
|
}
|
||||||
state = 100;
|
state = 100;
|
||||||
describe_items.clear();
|
describe_items.clear();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,6 +21,7 @@ struct cli_fix_t
|
|||||||
json11::Json options;
|
json11::Json options;
|
||||||
cli_result_t result;
|
cli_result_t result;
|
||||||
json11::Json::array fix_result;
|
json11::Json::array fix_result;
|
||||||
|
bool incomplete = false;
|
||||||
|
|
||||||
bool is_done()
|
bool is_done()
|
||||||
{
|
{
|
||||||
@@ -123,6 +124,20 @@ struct cli_fix_t
|
|||||||
state = 100;
|
state = 100;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
{
|
||||||
|
std::string down_osds;
|
||||||
|
for (auto osd_num: bad_osds)
|
||||||
|
{
|
||||||
|
if (!is_osd_up(parent, osd_num))
|
||||||
|
down_osds += (down_osds == "" ? "" : ", ")+std::to_string(osd_num);
|
||||||
|
}
|
||||||
|
if (down_osds != "")
|
||||||
|
{
|
||||||
|
result = (cli_result_t){ .err = EAGAIN, .text = "Bad OSD(s) "+down_osds+" are down, can't remove object copies from them" };
|
||||||
|
state = 100;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
remove_duplicates(objects);
|
remove_duplicates(objects);
|
||||||
parent->cli->init_msgr();
|
parent->cli->init_msgr();
|
||||||
resume_1:
|
resume_1:
|
||||||
@@ -138,6 +153,7 @@ struct cli_fix_t
|
|||||||
if (pool_cfg_it == parent->cli->st_cli->pool_config.end())
|
if (pool_cfg_it == parent->cli->st_cli->pool_config.end())
|
||||||
{
|
{
|
||||||
fprintf(stderr, "Object %jx:%jx is from unknown pool\n", obj.inode, obj.stripe);
|
fprintf(stderr, "Object %jx:%jx is from unknown pool\n", obj.inode, obj.stripe);
|
||||||
|
incomplete = true;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
auto & pool_cfg = pool_cfg_it->second;
|
auto & pool_cfg = pool_cfg_it->second;
|
||||||
@@ -150,9 +166,20 @@ struct cli_fix_t
|
|||||||
stderr, "Object %jx:%jx is from PG %u/%u which is not currently active\n",
|
stderr, "Object %jx:%jx is from PG %u/%u which is not currently active\n",
|
||||||
obj.inode, obj.stripe, pool_cfg_it->first, pg_num
|
obj.inode, obj.stripe, pool_cfg_it->first, pg_num
|
||||||
);
|
);
|
||||||
|
incomplete = true;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
osd_num_t primary_osd = pg_it->second.cur_primary;
|
osd_num_t primary_osd = pg_it->second.cur_primary;
|
||||||
|
if (!is_osd_up(parent, primary_osd))
|
||||||
|
{
|
||||||
|
// Requests to an OSD which is down are never answered
|
||||||
|
fprintf(
|
||||||
|
stderr, "Object %jx:%jx is from PG %u/%u whose primary OSD %ju is down\n",
|
||||||
|
obj.inode, obj.stripe, pool_cfg_it->first, pg_num, primary_osd
|
||||||
|
);
|
||||||
|
incomplete = true;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
// Describe -> Remove some copies -> Scrub again
|
// Describe -> Remove some copies -> Scrub again
|
||||||
osd_op_t *op = new osd_op_t;
|
osd_op_t *op = new osd_op_t;
|
||||||
op->req = (osd_any_op_t){
|
op->req = (osd_any_op_t){
|
||||||
@@ -172,6 +199,7 @@ struct cli_fix_t
|
|||||||
if (op->reply.hdr.retval < 0 || op->reply.describe.result_bytes != op->reply.hdr.retval * sizeof(osd_reply_describe_item_t))
|
if (op->reply.hdr.retval < 0 || op->reply.describe.result_bytes != op->reply.hdr.retval * sizeof(osd_reply_describe_item_t))
|
||||||
{
|
{
|
||||||
fprintf(stderr, "Failed to describe objects on OSD %ju (retval=%jd)\n", primary_osd, op->reply.hdr.retval);
|
fprintf(stderr, "Failed to describe objects on OSD %ju (retval=%jd)\n", primary_osd, op->reply.hdr.retval);
|
||||||
|
incomplete = true;
|
||||||
parent->waiting--;
|
parent->waiting--;
|
||||||
loop();
|
loop();
|
||||||
}
|
}
|
||||||
@@ -208,6 +236,7 @@ struct cli_fix_t
|
|||||||
(*rm_count)--;
|
(*rm_count)--;
|
||||||
if (rm_op->reply.hdr.retval < 0)
|
if (rm_op->reply.hdr.retval < 0)
|
||||||
{
|
{
|
||||||
|
incomplete = true;
|
||||||
fprintf(
|
fprintf(
|
||||||
stderr, "Failed to remove object %jx:%jx from OSD %ju (retval=%jd)\n",
|
stderr, "Failed to remove object %jx:%jx from OSD %ju (retval=%jd)\n",
|
||||||
rm_op->req.sec_del.oid.inode, rm_op->req.sec_del.oid.stripe,
|
rm_op->req.sec_del.oid.inode, rm_op->req.sec_del.oid.stripe,
|
||||||
@@ -252,6 +281,7 @@ struct cli_fix_t
|
|||||||
{
|
{
|
||||||
if (scrub_op->reply.hdr.retval < 0 && scrub_op->reply.hdr.retval != -ENOENT)
|
if (scrub_op->reply.hdr.retval < 0 && scrub_op->reply.hdr.retval != -ENOENT)
|
||||||
{
|
{
|
||||||
|
incomplete = true;
|
||||||
fprintf(
|
fprintf(
|
||||||
stderr, "Failed to scrub %jx:%jx on OSD %ju (retval=%jd)\n",
|
stderr, "Failed to scrub %jx:%jx on OSD %ju (retval=%jd)\n",
|
||||||
obj.inode, obj.stripe, primary_osd, scrub_op->reply.hdr.retval
|
obj.inode, obj.stripe, primary_osd, scrub_op->reply.hdr.retval
|
||||||
@@ -289,6 +319,11 @@ struct cli_fix_t
|
|||||||
{
|
{
|
||||||
result.data = fix_result;
|
result.data = fix_result;
|
||||||
}
|
}
|
||||||
|
if (incomplete)
|
||||||
|
{
|
||||||
|
result.err = EIO;
|
||||||
|
result.text = "Some objects were not fixed, see the messages above";
|
||||||
|
}
|
||||||
state = 100;
|
state = 100;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -7,6 +7,7 @@
|
|||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
|
||||||
std::vector<uint64_t> parse_uint64_list(json11::Json val);
|
std::vector<uint64_t> parse_uint64_list(json11::Json val);
|
||||||
|
bool is_osd_up(cli_tool_t *parent, osd_num_t osd_num);
|
||||||
|
|
||||||
template<class T> void remove_duplicates(std::vector<T> & ret)
|
template<class T> void remove_duplicates(std::vector<T> & ret)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -65,6 +65,7 @@ OLD=1 ./test_move_reappear.sh
|
|||||||
./test_rm.sh
|
./test_rm.sh
|
||||||
|
|
||||||
./test_rm_degraded.sh
|
./test_rm_degraded.sh
|
||||||
|
./test_describe.sh
|
||||||
|
|
||||||
./test_snapshot_chain.sh
|
./test_snapshot_chain.sh
|
||||||
SCHEME=ec ./test_snapshot_chain.sh
|
SCHEME=ec ./test_snapshot_chain.sh
|
||||||
|
|||||||
98
tests/test_describe.sh
Executable file
98
tests/test_describe.sh
Executable file
@@ -0,0 +1,98 @@
|
|||||||
|
#!/bin/bash -ex
|
||||||
|
|
||||||
|
# Test vitastor-cli describe and fix on degraded objects and with down OSDs
|
||||||
|
|
||||||
|
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/pg/state/ --print-value-only | jq -s -e '[ .[] | select((.state | index(\"active\")) and (.state | index(\"has_degraded\"))) ] | length == $PG_COUNT'" "PG peering with OSD 3"
|
||||||
|
|
||||||
|
INODE_ID=$($VITASTOR_CLI ls --json | jq -r '.[] | select(.name == "testimg") | .inode_id')
|
||||||
|
INODE=$(printf '0x%x' $INODE_ID)
|
||||||
|
INODE_NUM=$((INODE_ID & 0xffffffffffff))
|
||||||
|
|
||||||
|
# --inode lists the whole inode, not only its first object
|
||||||
|
all=$($VITASTOR_CLI describe --json | jq -c '[ .[] | select(.inode == "'$INODE'") | .stripe ] | unique')
|
||||||
|
if [[ $(echo "$all" | jq length) -le 1 ]]; then
|
||||||
|
format_error "describe should list more than one degraded object of testimg: $all"
|
||||||
|
fi
|
||||||
|
one=$($VITASTOR_CLI describe --pool 1 --inode $INODE_NUM --json | jq -c '[ .[].stripe ] | unique')
|
||||||
|
if [[ "$one" != "$all" ]]; then
|
||||||
|
format_error "describe --inode lists objects $one instead of $all"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# --min-offset and --max-offset narrow --inode, and --max-inode includes its whole inode
|
||||||
|
second=$(echo "$all" | jq -r '.[1]')
|
||||||
|
part=$($VITASTOR_CLI describe --pool 1 --inode $INODE_NUM --min-offset $second --max-offset $second --json | jq -c '[ .[].stripe ] | unique')
|
||||||
|
if [[ "$part" != "[\"$second\"]" ]]; then
|
||||||
|
format_error "describe --inode --min-offset $second --max-offset $second lists objects $part"
|
||||||
|
fi
|
||||||
|
range=$($VITASTOR_CLI describe --min-inode $INODE --max-inode $INODE --json | jq -c '[ .[].stripe ] | unique')
|
||||||
|
if [[ "$range" != "$all" ]]; then
|
||||||
|
format_error "describe --min-inode $INODE --max-inode $INODE lists objects $range instead of $all"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# describe and fix must not wait for an OSD which is down.
|
||||||
|
# Stop the monitor so that PGs keep the down OSD as their primary,
|
||||||
|
# and stop a primary OSD which has the latest data, so other PGs stay degraded.
|
||||||
|
VICTIM=$($VITASTOR_CLI ls-pgs --json | jq -r '[ .[].cur_primary | select(. == 1 or . == 2) ] | first')
|
||||||
|
VICTIM_PG=$($VITASTOR_CLI ls-pgs --json | jq -r '[ .[] | select(.cur_primary == '$VICTIM') | .pg_num ] | first')
|
||||||
|
OTHER_PG=$($VITASTOR_CLI ls-pgs --json | jq -r '[ .[] | select(.cur_primary != '$VICTIM') | .pg_num ] | first')
|
||||||
|
OTHER_PG_COUNT=$($VITASTOR_CLI ls-pgs --json | jq '[ .[] | select(.cur_primary != '$VICTIM') ] | length')
|
||||||
|
if [[ "$VICTIM" = null || "$OTHER_PG_COUNT" = 0 ]]; then
|
||||||
|
format_error "Expected PGs with primary OSD 1 or 2 and PGs with other primary OSDs"
|
||||||
|
fi
|
||||||
|
VICTIM_OBJ=$($VITASTOR_CLI describe --pool 1 --pg $VICTIM_PG --json | jq -r '.[0] | .inode+":"+.stripe')
|
||||||
|
OTHER_OBJ=$($VITASTOR_CLI describe --pool 1 --pg $OTHER_PG --json | jq -r '.[0] | .inode+":"+.stripe')
|
||||||
|
|
||||||
|
kill -9 $MON_PID
|
||||||
|
eval kill -9 \$OSD${VICTIM}_PID
|
||||||
|
$ETCDCTL del /vitastor/osd/state/$VICTIM
|
||||||
|
wait_condition 60 "$ETCDCTL get --prefix /vitastor/pg/state/ --print-value-only | jq -s -e '[ .[] | select(.primary != $VICTIM and (.state | index(\"degraded\"))) ] | length == $OTHER_PG_COUNT'" "PG peering without OSD $VICTIM"
|
||||||
|
# Keep PG 1/$VICTIM_PG active with the down primary, as it is until the OSD's etcd lease expires
|
||||||
|
$ETCDCTL put /vitastor/pg/state/1/$VICTIM_PG '{"peers":[1,2,3],"primary":'$VICTIM',"state":["active"]}'
|
||||||
|
|
||||||
|
# A listing with skipped OSDs or PGs is incomplete: EIO, but still valid JSON on stdout
|
||||||
|
for args in "" "--osds 1,2,3" "--pool 1 --pg $VICTIM_PG"; do
|
||||||
|
rc=0
|
||||||
|
timeout 30 $VITASTOR_CLI describe $args --json > ./testdata/describe.json 2> ./testdata/describe.err || rc=$?
|
||||||
|
[[ $rc == 5 ]] || format_error "describe $args exited with $rc instead of EIO with OSD $VICTIM down"
|
||||||
|
grep -q "OSD $VICTIM is down, skipping \(it\|PG 1/$VICTIM_PG\)" ./testdata/describe.err || \
|
||||||
|
format_error "describe $args should warn about OSD $VICTIM: $(cat ./testdata/describe.err)"
|
||||||
|
grep -q "The listing is incomplete" ./testdata/describe.err || \
|
||||||
|
format_error "describe $args should say that the listing is incomplete: $(cat ./testdata/describe.err)"
|
||||||
|
count=$(jq length ./testdata/describe.json) || format_error "describe $args printed invalid JSON"
|
||||||
|
if [[ "$args" == --pool* ]]; then
|
||||||
|
[[ $count == 0 ]] || format_error "describe $args should list nothing"
|
||||||
|
else
|
||||||
|
[[ $count -gt 0 ]] || format_error "describe $args should still list objects from the other OSDs"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
if timeout 30 $VITASTOR_CLI fix --bad-osds $VICTIM --objects $OTHER_OBJ 2> ./testdata/fix.err; then
|
||||||
|
format_error "fix should refuse to work with bad OSD $VICTIM down"
|
||||||
|
fi
|
||||||
|
grep -q "Bad OSD(s) $VICTIM are down" ./testdata/fix.err || format_error "fix printed: $(cat ./testdata/fix.err)"
|
||||||
|
|
||||||
|
# An object which is skipped is not fixed: EIO
|
||||||
|
rc=0
|
||||||
|
timeout 30 $VITASTOR_CLI fix --bad-osds 3 --objects $VICTIM_OBJ 2> ./testdata/fix.err || rc=$?
|
||||||
|
[[ $rc == 5 ]] || format_error "fix exited with $rc instead of EIO on an object from PG 1/$VICTIM_PG with primary OSD $VICTIM down"
|
||||||
|
grep -q "is from PG 1/$VICTIM_PG whose primary OSD $VICTIM is down" ./testdata/fix.err || \
|
||||||
|
format_error "fix should skip the object from PG 1/$VICTIM_PG: $(cat ./testdata/fix.err)"
|
||||||
|
grep -q "Some objects were not fixed" ./testdata/fix.err || \
|
||||||
|
format_error "fix should say that it skipped objects: $(cat ./testdata/fix.err)"
|
||||||
|
|
||||||
|
format_green OK
|
||||||
Reference in New Issue
Block a user