|
|
7100e8 |
commit 02bc6c85f814e85b5840f75e198a29d86ac6f2f2
|
|
|
7100e8 |
Author: Andrew Beekhof <andrew@beekhof.net>
|
|
|
7100e8 |
Date: Thu Feb 27 11:27:30 2014 +1100
|
|
|
7100e8 |
|
|
|
7100e8 |
Log: Fencing: Send details of stonith_api_time() and stonith_api_kick() to syslog
|
|
|
7100e8 |
|
|
|
7100e8 |
(cherry picked from commit b0a8876fe230f5e3e5770734f78e36284c0bae62)
|
|
|
7100e8 |
|
|
|
7100e8 |
diff --git a/include/crm/stonith-ng.h b/include/crm/stonith-ng.h
|
|
|
7100e8 |
index 35f6e5a..7f6938a 100644
|
|
|
7100e8 |
--- a/include/crm/stonith-ng.h
|
|
|
7100e8 |
+++ b/include/crm/stonith-ng.h
|
|
|
7100e8 |
@@ -348,8 +348,8 @@ void stonith_key_value_freeall(stonith_key_value_t * kvp, int keys, int values);
|
|
|
7100e8 |
*
|
|
|
7100e8 |
* At least one of nodeid and uname are required
|
|
|
7100e8 |
*/
|
|
|
7100e8 |
-int stonith_api_kick(int nodeid, const char *uname, int timeout, bool off);
|
|
|
7100e8 |
-time_t stonith_api_time(int nodeid, const char *uname, bool in_progress);
|
|
|
7100e8 |
+int stonith_api_kick(uint32_t nodeid, const char *uname, int timeout, bool off);
|
|
|
7100e8 |
+time_t stonith_api_time(uint32_t nodeid, const char *uname, bool in_progress);
|
|
|
7100e8 |
|
|
|
7100e8 |
/*
|
|
|
7100e8 |
* Helpers for using the above functions without install-time dependancies
|
|
|
7100e8 |
@@ -394,7 +394,7 @@ time_t stonith_api_time(int nodeid, const char *uname, bool in_progress);
|
|
|
7100e8 |
# define STONITH_LIBRARY "libstonithd.so.2"
|
|
|
7100e8 |
|
|
|
7100e8 |
static inline int
|
|
|
7100e8 |
-stonith_api_kick_helper(int nodeid, int timeout, bool off)
|
|
|
7100e8 |
+stonith_api_kick_helper(uint32_t nodeid, int timeout, bool off)
|
|
|
7100e8 |
{
|
|
|
7100e8 |
static void *st_library = NULL;
|
|
|
7100e8 |
static int (*st_kick_fn) (int nodeid, const char *uname, int timeout, bool off) = NULL;
|
|
|
7100e8 |
@@ -413,7 +413,7 @@ stonith_api_kick_helper(int nodeid, int timeout, bool off)
|
|
|
7100e8 |
}
|
|
|
7100e8 |
|
|
|
7100e8 |
static inline time_t
|
|
|
7100e8 |
-stonith_api_time_helper(int nodeid, bool in_progress)
|
|
|
7100e8 |
+stonith_api_time_helper(uint32_t nodeid, bool in_progress)
|
|
|
7100e8 |
{
|
|
|
7100e8 |
static void *st_library = NULL;
|
|
|
7100e8 |
static time_t(*st_time_fn) (int nodeid, const char *uname, bool in_progress) = NULL;
|
|
|
7100e8 |
diff --git a/lib/fencing/st_client.c b/lib/fencing/st_client.c
|
|
|
7100e8 |
index 3c6a7e7..7f2204f 100644
|
|
|
7100e8 |
--- a/lib/fencing/st_client.c
|
|
|
7100e8 |
+++ b/lib/fencing/st_client.c
|
|
|
7100e8 |
@@ -2361,8 +2361,11 @@ stonith_key_value_freeall(stonith_key_value_t * head, int keys, int values)
|
|
|
7100e8 |
}
|
|
|
7100e8 |
}
|
|
|
7100e8 |
|
|
|
7100e8 |
+#define api_log_open() openlog("stonith-api", LOG_CONS | LOG_NDELAY | LOG_PID, LOG_DAEMON)
|
|
|
7100e8 |
+#define api_log(level, fmt, args...) syslog(level, "%s: "fmt, __FUNCTION__, args)
|
|
|
7100e8 |
+
|
|
|
7100e8 |
int
|
|
|
7100e8 |
-stonith_api_kick(int nodeid, const char *uname, int timeout, bool off)
|
|
|
7100e8 |
+stonith_api_kick(uint32_t nodeid, const char *uname, int timeout, bool off)
|
|
|
7100e8 |
{
|
|
|
7100e8 |
char *name = NULL;
|
|
|
7100e8 |
const char *action = "reboot";
|
|
|
7100e8 |
@@ -2371,9 +2374,13 @@ stonith_api_kick(int nodeid, const char *uname, int timeout, bool off)
|
|
|
7100e8 |
stonith_t *st = NULL;
|
|
|
7100e8 |
enum stonith_call_options opts = st_opt_sync_call | st_opt_allow_suicide;
|
|
|
7100e8 |
|
|
|
7100e8 |
+ api_log_open();
|
|
|
7100e8 |
st = stonith_api_new();
|
|
|
7100e8 |
if (st) {
|
|
|
7100e8 |
rc = st->cmds->connect(st, "stonith-api", NULL);
|
|
|
7100e8 |
+ if(rc != pcmk_ok) {
|
|
|
7100e8 |
+ api_log(LOG_ERR, "Connection failed, could not kick (%s) node %u/%s : %s (%d)", action, nodeid, uname, pcmk_strerror(rc), rc);
|
|
|
7100e8 |
+ }
|
|
|
7100e8 |
}
|
|
|
7100e8 |
|
|
|
7100e8 |
if (uname != NULL) {
|
|
|
7100e8 |
@@ -2390,6 +2397,11 @@ stonith_api_kick(int nodeid, const char *uname, int timeout, bool off)
|
|
|
7100e8 |
|
|
|
7100e8 |
if (rc == pcmk_ok) {
|
|
|
7100e8 |
rc = st->cmds->fence(st, opts, name, action, timeout, 0);
|
|
|
7100e8 |
+ if(rc != pcmk_ok) {
|
|
|
7100e8 |
+ api_log(LOG_ERR, "Could not kick (%s) node %u/%s : %s (%d)", action, nodeid, uname, pcmk_strerror(rc), rc);
|
|
|
7100e8 |
+ } else {
|
|
|
7100e8 |
+ api_log(LOG_NOTICE, "Node %u/%s kicked: %s ", nodeid, uname, action);
|
|
|
7100e8 |
+ }
|
|
|
7100e8 |
}
|
|
|
7100e8 |
|
|
|
7100e8 |
if (st) {
|
|
|
7100e8 |
@@ -2402,7 +2414,7 @@ stonith_api_kick(int nodeid, const char *uname, int timeout, bool off)
|
|
|
7100e8 |
}
|
|
|
7100e8 |
|
|
|
7100e8 |
time_t
|
|
|
7100e8 |
-stonith_api_time(int nodeid, const char *uname, bool in_progress)
|
|
|
7100e8 |
+stonith_api_time(uint32_t nodeid, const char *uname, bool in_progress)
|
|
|
7100e8 |
{
|
|
|
7100e8 |
int rc = 0;
|
|
|
7100e8 |
char *name = NULL;
|
|
|
7100e8 |
@@ -2416,6 +2428,9 @@ stonith_api_time(int nodeid, const char *uname, bool in_progress)
|
|
|
7100e8 |
st = stonith_api_new();
|
|
|
7100e8 |
if (st) {
|
|
|
7100e8 |
rc = st->cmds->connect(st, "stonith-api", NULL);
|
|
|
7100e8 |
+ if(rc != pcmk_ok) {
|
|
|
7100e8 |
+ api_log(LOG_NOTICE, "Connection failed: %s (%d)", pcmk_strerror(rc), rc);
|
|
|
7100e8 |
+ }
|
|
|
7100e8 |
}
|
|
|
7100e8 |
|
|
|
7100e8 |
if (uname != NULL) {
|
|
|
7100e8 |
@@ -2427,18 +2442,31 @@ stonith_api_time(int nodeid, const char *uname, bool in_progress)
|
|
|
7100e8 |
}
|
|
|
7100e8 |
|
|
|
7100e8 |
if (st && rc == pcmk_ok) {
|
|
|
7100e8 |
- st->cmds->history(st, st_opt_sync_call | st_opt_cs_nodeid, name, &history, 120);
|
|
|
7100e8 |
+ int entries = 0;
|
|
|
7100e8 |
+ int progress = 0;
|
|
|
7100e8 |
+ int completed = 0;
|
|
|
7100e8 |
+
|
|
|
7100e8 |
+ rc = st->cmds->history(st, st_opt_sync_call | st_opt_cs_nodeid, name, &history, 120);
|
|
|
7100e8 |
|
|
|
7100e8 |
for (hp = history; hp; hp = hp->next) {
|
|
|
7100e8 |
+ entries++;
|
|
|
7100e8 |
if (in_progress) {
|
|
|
7100e8 |
+ progress++;
|
|
|
7100e8 |
if (hp->state != st_done && hp->state != st_failed) {
|
|
|
7100e8 |
progress = time(NULL);
|
|
|
7100e8 |
}
|
|
|
7100e8 |
|
|
|
7100e8 |
} else if (hp->state == st_done) {
|
|
|
7100e8 |
+ completed++;
|
|
|
7100e8 |
when = hp->completed;
|
|
|
7100e8 |
}
|
|
|
7100e8 |
}
|
|
|
7100e8 |
+
|
|
|
7100e8 |
+ if(rc == pcmk_ok) {
|
|
|
7100e8 |
+ api_log(LOG_INFO, "Found %d entries for %u/%s: %d in progress, %d completed", entries, nodeid, uname, progress, completed);
|
|
|
7100e8 |
+ } else {
|
|
|
7100e8 |
+ api_log(LOG_ERR, "Could not retrieve fence history for %u/%s: %s (%d)", nodeid, uname, pcmk_strerror(rc), rc);
|
|
|
7100e8 |
+ }
|
|
|
7100e8 |
}
|
|
|
7100e8 |
|
|
|
7100e8 |
if (progress) {
|
|
|
7100e8 |
@@ -2450,6 +2478,9 @@ stonith_api_time(int nodeid, const char *uname, bool in_progress)
|
|
|
7100e8 |
stonith_api_delete(st);
|
|
|
7100e8 |
}
|
|
|
7100e8 |
|
|
|
7100e8 |
+ if(when) {
|
|
|
7100e8 |
+ api_log(LOG_INFO, "Node %u/%s last kicked at: %ld", nodeid, uname, (long int)when);
|
|
|
7100e8 |
+ }
|
|
|
7100e8 |
free(name);
|
|
|
7100e8 |
return when;
|
|
|
7100e8 |
}
|