sbd/SOURCES/0020-Fix-sbd-pacemaker-check-for-shutdown-attribute-on-ev.patch
2021-09-10 04:15:58 +00:00

55 lines
1.7 KiB
Diff

From c8e3de2a7e98550ea9f27a0c59e13013ce02992d Mon Sep 17 00:00:00 2001
From: Klaus Wenninger <klaus.wenninger@aon.at>
Date: Fri, 16 Aug 2019 12:07:32 +0200
Subject: [PATCH] Fix: sbd-pacemaker: check for shutdown attribute on every
cib-diff
---
src/sbd-pacemaker.c | 22 +++++++++++++++++++++-
1 file changed, 21 insertions(+), 1 deletion(-)
diff --git a/src/sbd-pacemaker.c b/src/sbd-pacemaker.c
index 2b35ff6..1217acf 100644
--- a/src/sbd-pacemaker.c
+++ b/src/sbd-pacemaker.c
@@ -383,6 +383,24 @@ mon_trigger_refresh(gpointer user_data)
return FALSE;
}
+#define XPATH_SHUTDOWN "//" XML_CIB_TAG_STATE "[@uname='%s']/" \
+ XML_TAG_TRANSIENT_NODEATTRS "/" XML_TAG_ATTR_SETS "/" \
+ XML_CIB_TAG_NVPAIR "[@name='" XML_CIB_ATTR_SHUTDOWN "']"
+
+static gboolean
+shutdown_attr_in_cib(void)
+{
+ xmlNode *match = NULL;
+ char *xpath_string;
+
+ xpath_string = crm_strdup_printf(XPATH_SHUTDOWN, local_uname);
+ if (xpath_string) {
+ match = get_xpath_object(xpath_string, current_cib, LOG_TRACE);
+ free(xpath_string);
+ }
+ return (match != NULL);
+}
+
static void
crm_diff_update(const char *event, xmlNode * msg)
{
@@ -426,8 +444,10 @@ crm_diff_update(const char *event, xmlNode * msg)
* - immediately if the last update was more than 1s ago
* - every 10 updates
* - at most 1s after the last update
+ * - shutdown attribute for our node set for the first time
*/
- if (updates > 10 || (now - last_refresh) > (reconnect_msec / 1000)) {
+ if ((!pcmk_shutdown && shutdown_attr_in_cib()) ||
+ (updates > 10 || (now - last_refresh) > (reconnect_msec / 1000))) {
mon_refresh_state(refresh_timer);
updates = 0;
--
1.8.3.1