1
0
mirror of git://sourceware.org/git/lvm2.git synced 2025-01-03 05:18:29 +03:00

improve error messages when command rules fail

When certain cmd def RULE's fail, the error messages can
sometimes be confusing.  This expands the error messages
to help clarify why the rule failed, especially in cases
where options are used incorrectly.
This commit is contained in:
David Teigland 2017-09-20 10:51:52 -05:00
parent f2ee0e7aca
commit 0ab9e4b6a7
2 changed files with 26 additions and 10 deletions

View File

@ -677,7 +677,7 @@ DESC: Replace failed PVs in a raid or mirror LV.
DESC: Repair a thin pool.
DESC: Repair a cache pool.
RULE: all not lv_is_locked lv_is_pvmove
RULE: --poolmetadataspare Bool and LV_cache LV_cachepool LV_thinpool
RULE: --poolmetadataspare and LV_cache LV_cachepool LV_thinpool
lvconvert --replace PV LV_raid
OO: OO_LVCONVERT

View File

@ -2819,7 +2819,7 @@ static int _check_lv_rules(struct cmd_context *cmd, struct logical_volume *lv)
if (rule->check_opts && (rule->rule == RULE_INVALID) && opts_match_count) {
memset(buf, 0, sizeof(buf));
opt_array_to_str(cmd, rule->check_opts, rule->check_opts_count, buf, sizeof(buf));
log_warn("Command on LV %s does not accept option %s.",
log_warn("Command on LV %s has invalid use of option %s.",
display_lvname(lv), buf);
ret = 0;
}
@ -2837,7 +2837,11 @@ static int _check_lv_rules(struct cmd_context *cmd, struct logical_volume *lv)
/* Fail if the LV matches any of the invalid LV types. */
if (rule->check_lvt_bits && (rule->rule == RULE_INVALID) && lv_types_match_bits) {
log_warn("Command on LV %s does not accept LV type %s.",
if (rule->opts_count)
log_warn("Command on LV %s uses options invalid with LV type %s.",
display_lvname(lv), lvtype ? lvtype->name : "unknown");
else
log_warn("Command on LV %s with invalid LV type %s.",
display_lvname(lv), lvtype ? lvtype->name : "unknown");
ret = 0;
}
@ -2847,6 +2851,10 @@ static int _check_lv_rules(struct cmd_context *cmd, struct logical_volume *lv)
if (rule->check_lvt_bits && (rule->rule == RULE_REQUIRE) && !lv_types_match_bits) {
memset(buf, 0, sizeof(buf));
lvt_bits_to_str(rule->check_lvt_bits, buf, sizeof(buf));
if (rule->opts_count)
log_warn("Command on LV %s uses options that require LV types %s.",
display_lvname(lv), buf);
else
log_warn("Command on LV %s does not accept LV type %s. Required LV types are %s.",
display_lvname(lv), lvtype ? lvtype->name : "unknown", buf);
ret = 0;
@ -2857,7 +2865,11 @@ static int _check_lv_rules(struct cmd_context *cmd, struct logical_volume *lv)
if (rule->check_lvp_bits && (rule->rule == RULE_INVALID) && lv_props_match_bits) {
memset(buf, 0, sizeof(buf));
lvp_bits_to_str(lv_props_match_bits, buf, sizeof(buf));
log_warn("Command on LV %s does not accept LV with properties: %s.",
if (rule->opts_count)
log_warn("Command on LV %s uses options that are invalid with LV properties: %s.",
display_lvname(lv), buf);
else
log_warn("Command on LV %s is invalid on LV with properties: %s.",
display_lvname(lv), buf);
ret = 0;
}
@ -2867,6 +2879,10 @@ static int _check_lv_rules(struct cmd_context *cmd, struct logical_volume *lv)
if (rule->check_lvp_bits && (rule->rule == RULE_REQUIRE) && lv_props_unmatch_bits) {
memset(buf, 0, sizeof(buf));
lvp_bits_to_str(lv_props_unmatch_bits, buf, sizeof(buf));
if (rule->opts_count)
log_warn("Command on LV %s uses options that require LV properties: %s.",
display_lvname(lv), buf);
else
log_warn("Command on LV %s requires LV with properties: %s.",
display_lvname(lv), buf);
ret = 0;