node check: handle --upstream option when node is primary

This commit is contained in:
Ian Barwick
2020-03-31 10:49:30 +09:00
parent d9cb38c7f0
commit bffb8fa11b
2 changed files with 37 additions and 25 deletions

View File

@@ -37,6 +37,7 @@
Server role: OK (node is primary)
Replication lag: OK (N/A - node is primary)
WAL archiving: OK (0 pending files)
Upstream connection: OK (N/A - is primary)
Downstream servers: OK (2 of 2 downstream nodes attached)
Replication slots: OK (node has no physical replication slots)
Missing replication slots: OK (node has no missing physical replication slots)</programlisting>

View File

@@ -1358,7 +1358,6 @@ do_node_check_upstream(PGconn *conn, OutputMode mode, t_node_info *node_info, Ch
CheckStatus status = CHECK_STATUS_OK;
if (mode == OM_CSV && list_output == NULL)
{
log_error(_("--csv output not provided with --upstream option"));
@@ -1366,15 +1365,26 @@ do_node_check_upstream(PGconn *conn, OutputMode mode, t_node_info *node_info, Ch
exit(ERR_BAD_CONFIG);
}
if (get_node_record(conn, node_info->upstream_node_id, &upstream_node_info) != RECORD_FOUND)
{
log_error(_("no record found for upstream node %i"), node_info->upstream_node_id);
PQfinish(conn);
exit(ERR_BAD_CONFIG);
}
initPQExpBuffer(&details);
if (get_node_record(conn, node_info->upstream_node_id, &upstream_node_info) != RECORD_FOUND)
{
if (get_recovery_type(conn) == RECTYPE_STANDBY)
{
appendPQExpBuffer(&details,
_("node \"%s\" (ID: %i) is a standby but no upstream record found"),
node_info->node_name,
node_info->node_id);
status = CHECK_STATUS_CRITICAL;
}
else
{
appendPQExpBufferStr(&details,
_("N/A - node is primary"));
}
}
else
{
upstream_conn = establish_db_connection(upstream_node_info.conninfo, true);
/* check our node is connected */
@@ -1397,6 +1407,7 @@ do_node_check_upstream(PGconn *conn, OutputMode mode, t_node_info *node_info, Ch
upstream_node_info.node_name,
upstream_node_info.node_id);
}
}
switch (mode)
{