Skip to content

Commit

Permalink
Fix: libpacemaker: crm_mon --one-shot can fail during pacemaker shutdown
Browse files Browse the repository at this point in the history
crm_mon --one-shot checks the pacemakerd state before trying to get a
CIB connection. If pacemakerd is shutting down, it returns ENOTCONN.
This can cause a resource agent that calls crm_mon (for example,
ocf:heartbeat:pgsql) to fail to stop during shutdown.

This may be a regression introduced by commit 3f342e3.
crm_mon.c:pacemakerd_status() returns pcmk_rc_ok if pacemakerd is
shutting down, since 49ebe4c and 46d6edd (fixes for CLBZ#5471). 3f342e3
refactored crm_mon --one-shot to use library functions, and
pcmk_status.c:pacemakerd_status() returns ENOTCONN if pacemakerd is
shutting down. As a result, we don't try to connect to the CIB.

Fixes CLBZ#5501

Signed-off-by: Reid Wahl <[email protected]>
  • Loading branch information
nrwahl2 committed Oct 6, 2022
1 parent 2b821b2 commit ae51b37
Showing 1 changed file with 17 additions and 7 deletions.
24 changes: 17 additions & 7 deletions lib/pacemaker/pcmk_status.c
Original file line number Diff line number Diff line change
Expand Up @@ -122,15 +122,25 @@ pacemakerd_status(pcmk__output_t *out)
rc = pcmk_pacemakerd_api_ping(pacemakerd_api, crm_system_name);

if (rc != pcmk_rc_ok) {
/* Got some error from pcmk_pacemakerd_api_ping, so return it. */
} else if (state == pcmk_pacemakerd_state_running) {
rc = pcmk_rc_ok;
} else if (state == pcmk_pacemakerd_state_shutting_down) {
rc = ENOTCONN;
} else {
rc = EAGAIN;
// Got some error from pcmk_pacemakerd_api_ping, so return it
pcmk_free_ipc_api(pacemakerd_api);
return rc;
}

switch (state) {
case pcmk_pacemakerd_state_init:
case pcmk_pacemakerd_state_starting_daemons:
case pcmk_pacemakerd_state_wait_for_ping:
rc = EAGAIN;
break;
case pcmk_pacemakerd_state_running:
case pcmk_pacemakerd_state_shutting_down:
// CIB may still be accessible while shutting down
break;
default:
rc = ENOTCONN;
break;
}
pcmk_free_ipc_api(pacemakerd_api);
return rc;
}
Expand Down

0 comments on commit ae51b37

Please sign in to comment.