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

@@ -4,6 +4,7 @@
repmgr: fix "standby register --wait-sync" when no timeout provided (Ian)
repmgr: "cluster show" returns non-zero value if an issue encountered;
GitHub #456 (Ian)
repmgr: "node status" returns non-zero value if an issue encountered (Ian)
repmgrd: create a PID file by default; GitHub #457 (Ian)
repmgrd: daemonize process by default; GitHub #458 (Ian)

View File

@@ -52,6 +52,35 @@
</para>
</refsect1>
<refsect1>
<title>Exit codes</title>
<para>
Following exit codes can be emitted by <command>repmgr node status</command>:
</para>
<variablelist>
<varlistentry>
<term><option>SUCCESS (0)</option></term>
<listitem>
<para>
No issues were detected.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><option>ERR_NODE_STATUS (25)</option></term>
<listitem>
<para>
One or more issues were detected.
</para>
</listitem>
</varlistentry>
</variablelist>
</refsect1>
<refsect1>
<title>See also</title>
<para>

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".