Skip to content

Commit adafc28

Browse files
committed
Fix: sbd-cluster: exit if cmap is disconnected
To avoid problems with lost CMAP connection, just exit and let the inquisitor fix the situation by restarting the servant.
1 parent 838dd14 commit adafc28

File tree

3 files changed

+28
-5
lines changed

3 files changed

+28
-5
lines changed

src/sbd-cluster.c

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -67,12 +67,10 @@ static int reconnect_msec = 1000;
6767
static GMainLoop *mainloop = NULL;
6868
static guint notify_timer = 0;
6969
static crm_cluster_t cluster;
70+
static void clean_up(int rc);
7071
static gboolean sbd_remote_check(gpointer user_data);
7172
static long unsigned int find_pacemaker_remote(void);
7273
static void sbd_membership_destroy(gpointer user_data);
73-
#if CHECK_TWO_NODE
74-
static void cmap_destroy(void);
75-
#endif
7674

7775

7876
#if SUPPORT_PLUGIN
@@ -190,9 +188,9 @@ cmap_dispatch_callback (gint cmap_fd,
190188
/* CMAP connection lost */
191189
if (condition & G_IO_HUP) {
192190
cl_log(LOG_WARNING, "CMAP service connection lost\n");
193-
cmap_destroy();
191+
clean_up(EXIT_CLUSTER_DISCONNECT);
194192
/* remove the source from the main loop */
195-
return G_SOURCE_REMOVE;
193+
return G_SOURCE_REMOVE; /* never reached */
196194
}
197195
cmap_dispatch(cmap_handle, CS_DISPATCH_ALL);
198196
return G_SOURCE_CONTINUE;
@@ -557,6 +555,14 @@ find_pacemaker_remote(void)
557555
static void
558556
clean_up(int rc)
559557
{
558+
#if SUPPORT_COROSYNC && CHECK_TWO_NODE
559+
cmap_destroy();
560+
#endif
561+
562+
if (rc >= 0) {
563+
exit(rc);
564+
}
565+
560566
return;
561567
}
562568

src/sbd-inquisitor.c

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -526,6 +526,20 @@ void inquisitor_child(void)
526526
break;
527527
}
528528
}
529+
} else if (sbd_is_cluster(s)) {
530+
if (WIFEXITED(status)) {
531+
switch(WEXITSTATUS(status)) {
532+
case EXIT_CLUSTER_DISCONNECT:
533+
cl_log(LOG_WARNING, "Cluster-Servant has exited (connection lost)");
534+
s->restarts = 0;
535+
s->restart_blocked = 0;
536+
s->outdated = 1;
537+
s->t_last.tv_sec = 0;
538+
break;
539+
default:
540+
break;
541+
}
542+
}
529543
}
530544
cleanup_servant_by_pid(pid);
531545
}

src/sbd.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,9 @@
6262
/* exit status for pcmk-servant */
6363
#define EXIT_PCMK_SERVANT_GRACEFUL_SHUTDOWN 30
6464

65+
/* exit status for cluster-servant */
66+
#define EXIT_CLUSTER_DISCONNECT 40
67+
6568
#define HOG_CHAR 0xff
6669
#define SECTOR_NAME_MAX 63
6770

0 commit comments

Comments
 (0)