repmgr: "cluster show" to return non-zero value if an issue encountered

This commit is contained in:
Ian Barwick
2018-07-05 13:32:50 +09:00
parent 4c7c681a14
commit 92d0e6809b
3 changed files with 43 additions and 1 deletions

View File

@@ -487,7 +487,7 @@ do_node_status(void)
termPQExpBuffer(&output);
if (runtime_options.output_mode == OM_TEXT && warnings.head != NULL && runtime_options.terse == false)
if (warnings.head != NULL && runtime_options.terse == false && runtime_options.output_mode == OM_TEXT)
{
log_warning(_("following issue(s) were detected:"));
print_item_list(&warnings);
@@ -498,8 +498,20 @@ do_node_status(void)
key_value_list_free(&node_status);
item_list_free(&warnings);
PQfinish(conn);
/*
* If warnings were noted, even if they're not displayed (e.g. in --csv node),
* that means something's not right so we need to emit a non-zero exit code.
*/
if (warnings.head != NULL)
{
exit(ERR_NODE_STATUS);
}
return;
}
/*
* Returns information about the running state of the node.
* For internal use during "standby switchover".