mirror of
git://sourceware.org/git/lvm2.git
synced 2025-01-18 10:04:20 +03:00
In script-processing mode, stop if any command fails.
Warn if command exits with non-zero status code without a prior log_error.
This commit is contained in:
parent
0a5b690b70
commit
de24008109
@ -1,5 +1,7 @@
|
||||
Version 2.02.38 -
|
||||
=================================
|
||||
In script-processing mode, stop if any command fails.
|
||||
Warn if command exits with non-zero status code without a prior log_error.
|
||||
Make clvmd-cman use a hash rather than an array for node updown info.
|
||||
Check lv_count in vg_validate.
|
||||
Add --prefixes to reporting tools for field name prefix output format.
|
||||
|
@ -51,6 +51,7 @@ static int _already_logging = 0;
|
||||
static int _mirror_in_sync = 0;
|
||||
static int _dmeventd_monitor = DEFAULT_DMEVENTD_MONITOR;
|
||||
static int _ignore_suspended_devices = 0;
|
||||
static int _error_message_produced = 0;
|
||||
|
||||
static lvm2_log_fn_t _lvm2_log_fn = NULL;
|
||||
|
||||
@ -238,6 +239,16 @@ void init_indent(int indent)
|
||||
_indent = indent;
|
||||
}
|
||||
|
||||
void init_error_message_produced(int error_message_produced)
|
||||
{
|
||||
_error_message_produced = error_message_produced;
|
||||
}
|
||||
|
||||
int error_message_produced(void)
|
||||
{
|
||||
return _error_message_produced;
|
||||
}
|
||||
|
||||
int test_mode()
|
||||
{
|
||||
return _test;
|
||||
@ -322,6 +333,9 @@ void print_log(int level, const char *file, int line, const char *format, ...)
|
||||
if (_log_suppress == 2)
|
||||
return;
|
||||
|
||||
if (level <= _LOG_ERR)
|
||||
_error_message_produced = 1;
|
||||
|
||||
trformat = _(format);
|
||||
|
||||
if (_lvm2_log_fn) {
|
||||
|
@ -79,6 +79,7 @@ void init_security_level(int level);
|
||||
void init_mirror_in_sync(int in_sync);
|
||||
void init_dmeventd_monitor(int reg);
|
||||
void init_ignore_suspended_devices(int ignore);
|
||||
void init_error_message_produced(int error_message_produced);
|
||||
|
||||
void set_cmd_name(const char *cmd_name);
|
||||
|
||||
@ -94,6 +95,7 @@ int lockingfailed(void);
|
||||
int security_level(void);
|
||||
int mirror_in_sync(void);
|
||||
int ignore_suspended_devices(void);
|
||||
int error_message_produced(void);
|
||||
|
||||
#define DMEVENTD_MONITOR_IGNORE -1
|
||||
int dmeventd_monitor_mode(void);
|
||||
|
@ -236,6 +236,10 @@ int lvm_shell(struct cmd_context *cmd, struct cmdline_context *cmdline)
|
||||
log_error("No such command '%s'. Try 'help'.",
|
||||
argv[0]);
|
||||
|
||||
if (ret && !error_message_produced()) {
|
||||
log_debug("Internal error: Failed command did not use log_error");
|
||||
log_error("Command failed with status code %d.", ret);
|
||||
}
|
||||
_write_history();
|
||||
}
|
||||
|
||||
|
@ -875,6 +875,8 @@ int lvm_run_command(struct cmd_context *cmd, int argc, char **argv)
|
||||
int ret = 0;
|
||||
int locking_type;
|
||||
|
||||
init_error_message_produced(0);
|
||||
|
||||
/* each command should start out with sigint flag cleared */
|
||||
sigint_clear();
|
||||
|
||||
@ -1096,7 +1098,14 @@ static int _run_script(struct cmd_context *cmd, int argc, char **argv)
|
||||
continue;
|
||||
if (!strcmp(argv[0], "quit") || !strcmp(argv[0], "exit"))
|
||||
break;
|
||||
lvm_run_command(cmd, argc, argv);
|
||||
ret = lvm_run_command(cmd, argc, argv);
|
||||
if (ret) {
|
||||
if (!error_message_produced()) {
|
||||
log_debug("Internal error: Failed command did not use log_error");
|
||||
log_error("Command failed with status code %d.", ret);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (fclose(script))
|
||||
@ -1218,6 +1227,11 @@ int lvm2_main(int argc, char **argv, unsigned is_static)
|
||||
if (ret == ENO_SUCH_CMD)
|
||||
log_error("No such command. Try 'help'.");
|
||||
|
||||
if (ret && !error_message_produced()) {
|
||||
log_debug("Internal error: Failed command did not use log_error");
|
||||
log_error("Command failed with status code %d.", ret);
|
||||
}
|
||||
|
||||
out:
|
||||
lvm_fin(cmd);
|
||||
if (ret == ECMD_PROCESSED)
|
||||
|
Loading…
x
Reference in New Issue
Block a user