Skip to content

Commit

Permalink
Fix: sbd-cluster: exit if cmap is disconnected
Browse files Browse the repository at this point in the history
To avoid problems with lost CMAP connection, just exit and let the
inquisitor fix the situation by restarting the servant.
  • Loading branch information
skazi0 committed May 29, 2019
1 parent 838dd14 commit adafc28
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 5 deletions.
16 changes: 11 additions & 5 deletions src/sbd-cluster.c
Original file line number Diff line number Diff line change
Expand Up @@ -67,12 +67,10 @@ static int reconnect_msec = 1000;
static GMainLoop *mainloop = NULL;
static guint notify_timer = 0;
static crm_cluster_t cluster;
static void clean_up(int rc);
static gboolean sbd_remote_check(gpointer user_data);
static long unsigned int find_pacemaker_remote(void);
static void sbd_membership_destroy(gpointer user_data);
#if CHECK_TWO_NODE
static void cmap_destroy(void);
#endif


#if SUPPORT_PLUGIN
Expand Down Expand Up @@ -190,9 +188,9 @@ cmap_dispatch_callback (gint cmap_fd,
/* CMAP connection lost */
if (condition & G_IO_HUP) {
cl_log(LOG_WARNING, "CMAP service connection lost\n");
cmap_destroy();
clean_up(EXIT_CLUSTER_DISCONNECT);
/* remove the source from the main loop */
return G_SOURCE_REMOVE;
return G_SOURCE_REMOVE; /* never reached */
}
cmap_dispatch(cmap_handle, CS_DISPATCH_ALL);
return G_SOURCE_CONTINUE;
Expand Down Expand Up @@ -557,6 +555,14 @@ find_pacemaker_remote(void)
static void
clean_up(int rc)
{
#if SUPPORT_COROSYNC && CHECK_TWO_NODE
cmap_destroy();
#endif

if (rc >= 0) {
exit(rc);
}

return;
}

Expand Down
14 changes: 14 additions & 0 deletions src/sbd-inquisitor.c
Original file line number Diff line number Diff line change
Expand Up @@ -526,6 +526,20 @@ void inquisitor_child(void)
break;
}
}
} else if (sbd_is_cluster(s)) {
if (WIFEXITED(status)) {
switch(WEXITSTATUS(status)) {
case EXIT_CLUSTER_DISCONNECT:
cl_log(LOG_WARNING, "Cluster-Servant has exited (connection lost)");
s->restarts = 0;
s->restart_blocked = 0;
s->outdated = 1;
s->t_last.tv_sec = 0;
break;
default:
break;
}
}
}
cleanup_servant_by_pid(pid);
}
Expand Down
3 changes: 3 additions & 0 deletions src/sbd.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,9 @@
/* exit status for pcmk-servant */
#define EXIT_PCMK_SERVANT_GRACEFUL_SHUTDOWN 30

/* exit status for cluster-servant */
#define EXIT_CLUSTER_DISCONNECT 40

#define HOG_CHAR 0xff
#define SECTOR_NAME_MAX 63

Expand Down

0 comments on commit adafc28

Please sign in to comment.