Skip to content

Commit

Permalink
Merge pull request #25 from gao-yan/sbd-sysconfig-compatibility
Browse files Browse the repository at this point in the history
Backward compatibility and another fix
  • Loading branch information
wenningerk authored Nov 2, 2017
2 parents 8a0800c + 2e076d4 commit 681ce1a
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 11 deletions.
5 changes: 4 additions & 1 deletion man/sbd.8.pod
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,10 @@ If set to zero, processes will be restarted indefinitely and immediately.

=item B<-P>

Check Pacemaker quorum and node health.
Enable Pacemaker integration which checks Pacemaker quorum and node health.
Specify this once to enable, twice to disable.

Defaults to I<enabled>.

=item B<-S> I<N>

Expand Down
43 changes: 33 additions & 10 deletions src/sbd-inquisitor.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@
static struct servants_list_item *servants_leader = NULL;

int disk_priority = 1;
int check_pcmk = 0;
int check_cluster = 0;
int check_pcmk = 1;
int check_cluster = 1;
int disk_count = 0;
int servant_count = 0;
int servant_restart_interval = 5;
Expand Down Expand Up @@ -803,11 +803,19 @@ parse_device_line(const char *line)
return found;
}

int
arg_enabled(int arg_count)
{
return arg_count % 2;
}

int main(int argc, char **argv, char **envp)
{
int exit_status = 0;
int c;
int w = 0;
int W_count = 0;
int c_count = 0;
int P_count = 0;
int qb_facility;
const char *value = NULL;
int start_delay = 0;
Expand Down Expand Up @@ -866,6 +874,13 @@ int main(int argc, char **argv, char **envp)
watchdogdev = strdup(value);
}

/* SBD_WATCHDOG has been dropped from sbd.sysconfig example.
* This is for backward compatibility. */
value = getenv("SBD_WATCHDOG");
if(value) {
watchdog_use = crm_is_true(value);
}

value = getenv("SBD_WATCHDOG_TIMEOUT");
if(value) {
timeout_watchdog = crm_get_msec(value) / 1000;
Expand Down Expand Up @@ -925,7 +940,7 @@ int main(int argc, char **argv, char **envp)
cl_log(LOG_INFO, "Setting watchdog timeout disabled; using defaults.");
break;
case 'W':
w++;
W_count++;
break;
case 'w':
cl_log(LOG_NOTICE, "Using watchdog device '%s'", watchdogdev);
Expand All @@ -942,10 +957,10 @@ int main(int argc, char **argv, char **envp)
#endif
break;
case 'c':
check_cluster = 1;
c_count++;
break;
case 'P':
check_pcmk = 1;
P_count++;
break;
case 'z':
disk_priority = 0;
Expand Down Expand Up @@ -1008,11 +1023,11 @@ int main(int argc, char **argv, char **envp)
}
}

if (w > 0) {
watchdog_use = w % 2;

} else if(watchdogdev == NULL || strcmp(watchdogdev, "/dev/null") == 0) {
if (watchdogdev == NULL || strcmp(watchdogdev, "/dev/null") == 0) {
watchdog_use = 0;

} else if (W_count > 0) {
watchdog_use = arg_enabled(W_count);
}

if (watchdog_use) {
Expand All @@ -1021,6 +1036,14 @@ int main(int argc, char **argv, char **envp)
cl_log(LOG_INFO, "Watchdog disabled.");
}

if (c_count > 0) {
check_cluster = arg_enabled(c_count);
}

if (P_count > 0) {
check_pcmk = arg_enabled(P_count);
}

if ((disk_count > 0) && (strlen(local_uname) > SECTOR_NAME_MAX)) {
fprintf(stderr, "Node name mustn't be longer than %d chars.\n",
SECTOR_NAME_MAX);
Expand Down

0 comments on commit 681ce1a

Please sign in to comment.