Hello community, here is the log from the commit of package sbd for openSUSE:Factory checked in at 2013-10-19 11:13:25 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/sbd (Old) and /work/SRC/openSUSE:Factory/.sbd.new (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "sbd" Changes: -------- --- /work/SRC/openSUSE:Factory/sbd/sbd.changes 2013-10-11 09:03:59.000000000 +0200 +++ /work/SRC/openSUSE:Factory/.sbd.new/sbd.changes 2013-10-19 11:19:47.000000000 +0200 @@ -1,0 +2,10 @@ +Thu Oct 10 09:12:41 UTC 2013 - [email protected] + +- systemd support +- /etc/sysconfig/sbd template added +- sbd: Add -p option to specify a pidfile +- sbd-pacemaker: detect whether to run the AIS plugin quorum check at + runtime +- cs: d7df351e09f903be79495dbe312cf670f1747ef2 + +------------------------------------------------------------------- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ sbd.spec ++++++ --- /var/tmp/diff_new_pack.KdOPgx/_old 2013-10-19 11:19:48.000000000 +0200 +++ /var/tmp/diff_new_pack.KdOPgx/_new 2013-10-19 11:19:48.000000000 +0200 @@ -34,6 +34,11 @@ BuildRequires: libglue-devel BuildRequires: libpacemaker-devel libcorosync-devel Conflicts: ClusterTools2 < 2.3.2 +Requires(pre): %fillup_prereq + +%if %{defined systemd_requires} +%systemd_requires +%endif %description @@ -56,6 +61,12 @@ %install ########################################################### make DESTDIR=$RPM_BUILD_ROOT LIBDIR=%{_libdir} install +install -D -m 0755 src/sbd.sh $RPM_BUILD_ROOT/usr/share/sbd/sbd.sh +%if %{defined _unitdir} +install -D -m 0644 src/sbd.service $RPM_BUILD_ROOT/%{_unitdir}/sbd.service +%endif +mkdir -p %{buildroot}%{_localstatedir}/adm/fillup-templates +cp -f src/sbd.sysconfig %{buildroot}%{_localstatedir}/adm/fillup-templates/sysconfig.sbd %clean ########################################################### @@ -65,12 +76,32 @@ rm -rf $RPM_BUILD_ROOT || true fi +%if %{defined _unitdir} +%post +%service_add_post sbd.service + +if [ ! -e %{_sysconfdir}/sysconfig/sbd ]; then + %fillup_only sbd +fi + +%preun +%service_del_preun sbd.service + +%postun +%service_del_postun sbd.service +%endif + %files ########################################################### %defattr(-,root,root) %{_libdir}/stonith/plugins/external/sbd %{_sbindir}/sbd +%{_datadir}/sbd %doc %{_mandir}/man8/sbd* +%if %{defined _unitdir} +%{_unitdir}/sbd.service +%endif +%{_localstatedir}/adm/fillup-templates/sysconfig.sbd %doc COPYING %changelog ++++++ sbd-1.2.1.tar.bz2 ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/sbd-1.2.1/man/sbd.8.pod new/sbd-1.2.1/man/sbd.8.pod --- old/sbd-1.2.1/man/sbd.8.pod 2013-10-01 10:22:53.000000000 +0200 +++ new/sbd-1.2.1/man/sbd.8.pod 2013-10-10 11:11:59.000000000 +0200 @@ -171,14 +171,11 @@ the message slot of the local node for incoming messages, reachability, and optionally take Pacemaker's state into account. +C<sbd> B<must> be started on boot before the cluster stack! See below +for enabling this according to your boot environment. + The options for this mode are rarely specified directly on the -commandline directly, but most frequently set via F</etc/sysconfig/sbd>. The -C<openais> or C<corosync> system start-up scripts take care of starting -or stopping C<sbd> as required before starting the rest of the cluster -stack. Thus, the daemon is brought online on each node before the rest of the -cluster stack is started, and terminated only after all other cluster -components have been shut down - ensuring that cluster resources are -never activated without SBD supervision. +commandline directly, but most frequently set via F</etc/sysconfig/sbd>. It also constantly monitors connectivity to the storage device, and self-fences in case the partition becomes unreachable, guaranteeing that it @@ -235,6 +232,10 @@ This can be used to override the default watchdog device used and should not usually be necessary. +=item B<-p> F</var/run/sbd.pid> + +This option can be used to specify a pidfile for the main sbd process. + =item B<-F> I<N> Number of failures before a failing servant process will not be restarted @@ -481,13 +482,32 @@ =head2 Configure SBD to start on boot -If configured via F</etc/sysconfig/sbd>, the cluster stack's init script -will automatically start and stop C<sbd> as required. In this file, you -must specify the device(s) used, as well as any options to pass to the -daemon: +On systems using C<sysvinit>, the C<openais> or C<corosync> system +start-up scripts must handle starting or stopping C<sbd> as required +before starting the rest of the cluster stack. + +For C<systemd>, sbd simply has to be enabled using + + systemctl enable sbd.service + +The daemon is brought online on each node before the Pacemaker is +started, and terminated only after all other cluster components have +been shut down - ensuring that cluster resources are never activated +without SBD supervision. + +=head2 Configuration via sysconfig + +The system instance of C<sbd> is configured via F</etc/sysconfig/sbd>. +In this file, you must specify the device(s) used, as well as any +options to pass to the daemon: SBD_DEVICE="/dev/sda1;/dev/sdb1;/dev/sdc1" - SBD_OPTS="-W -P" + SBD_PACEMAKER="true" + +C<sbd> will fail to start if no C<SBD_DEVICE> is specified. See the +installed template for more options that can be configured here. + +=head2 Testing the sbd installation After a restart of the cluster stack on this node, you can now try sending a test message to it as root, from this or any other node: @@ -501,8 +521,8 @@ This confirms that SBD is indeed up and running on the node, and that it is ready to receive messages. -Make sure that F</etc/sysconfig/sbd> is identical on all cluster nodes, -and that all cluster nodes are running the daemon! +Make B<sure> that F</etc/sysconfig/sbd> is identical on all cluster +nodes, and that all cluster nodes are running the daemon. =head1 Pacemaker CIB integration @@ -531,7 +551,6 @@ resource. This is B<not> recommended for production use, but only for debugging phases. - =head2 General cluster properties You must also enable STONITH in general, and set the STONITH timeout to diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/sbd-1.2.1/src/sbd-common.c new/sbd-1.2.1/src/sbd-common.c --- old/sbd-1.2.1/src/sbd-common.c 2013-10-01 10:22:53.000000000 +0200 +++ new/sbd-1.2.1/src/sbd-common.c 2013-10-10 11:11:59.000000000 +0200 @@ -63,6 +63,7 @@ "-W Use watchdog (recommended) (watch only)\n" "-w <dev> Specify watchdog device (optional) (watch only)\n" "-T Do NOT initialize the watchdog timeout (watch only)\n" +"-p <path> Write pidfile to the specified path (watch only)\n" "-v Enable some verbose debug logging (optional)\n" "\n" "-1 <N> Set watchdog timeout to N seconds (optional, create only)\n" diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/sbd-1.2.1/src/sbd-md.c new/sbd-1.2.1/src/sbd-md.c --- old/sbd-1.2.1/src/sbd-md.c 2013-10-01 10:22:53.000000000 +0200 +++ new/sbd-1.2.1/src/sbd-md.c 2013-10-10 11:11:59.000000000 +0200 @@ -26,6 +26,7 @@ static int servant_inform_parent = 0; static int check_pcmk = 0; static int start_mode = 0; +static char* pidfile = NULL; int quorum_write(int good_servants) { @@ -591,6 +592,12 @@ set_proc_title("sbd: inquisitor"); + if (pidfile) { + if (cl_lock_pidfile(pidfile) < 0) { + exit(1); + } + } + sigemptyset(&procmask); sigaddset(&procmask, SIGCHLD); sigaddset(&procmask, SIG_LIVENESS); @@ -673,9 +680,12 @@ } if (exiting) { - if (check_all_dead()) + if (check_all_dead()) { + if (pidfile) { + cl_unlock_pidfile(pidfile); + } exit(0); - else + } else continue; } @@ -933,7 +943,7 @@ sbd_get_uname(); - while ((c = getopt(argc, argv, "C:DPRTWZhvw:d:n:1:2:3:4:5:t:I:F:S:")) != -1) { + while ((c = getopt(argc, argv, "C:DPRTWZhvw:d:n:p:1:2:3:4:5:t:I:F:S:")) != -1) { switch (c) { case 'D': break; @@ -962,7 +972,7 @@ cl_log(LOG_INFO, "Watchdog enabled."); break; case 'w': - watchdogdev = optarg; + watchdogdev = strdup(optarg); break; case 'd': recruit_servant(optarg, 0); @@ -971,9 +981,13 @@ check_pcmk = 1; break; case 'n': - local_uname = optarg; + local_uname = strdup(optarg); cl_log(LOG_INFO, "Overriding local hostname to %s", local_uname); break; + case 'p': + pidfile = strdup(optarg); + cl_log(LOG_INFO, "pidfile set to %s", pidfile); + break; case 'C': timeout_watchdog_crashdump = atoi(optarg); cl_log(LOG_INFO, "Setting crashdump watchdog timeout to %d", diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/sbd-1.2.1/src/sbd-pacemaker.c new/sbd-1.2.1/src/sbd-pacemaker.c --- old/sbd-1.2.1/src/sbd-pacemaker.c 2013-10-01 10:22:53.000000000 +0200 +++ new/sbd-1.2.1/src/sbd-pacemaker.c 2013-10-10 11:11:59.000000000 +0200 @@ -78,8 +78,8 @@ #ifdef CHECK_AIS static guint timer_id_ais = 0; static enum cluster_type_e cluster_stack = pcmk_cluster_unknown; -static int local_id = 0; static struct timespec t_last_quorum; +static int check_ais = 0; #endif #define LOGONCE(state, lvl, fmt, args...) do { \ @@ -144,7 +144,7 @@ mon_refresh_state(); counter = 0; } else { - int rc = cib->cmds->noop(cib, 0); + cib->cmds->noop(cib, 0); notify_parent(); counter++; } @@ -290,19 +290,21 @@ } #ifdef CHECK_AIS - int quorum_age = t_now.tv_sec - t_last_quorum.tv_sec; + if (check_ais) { + int quorum_age = t_now.tv_sec - t_last_quorum.tv_sec; - if (quorum_age > (int)(timeout_io+timeout_loop)) { - if (t_last_quorum.tv_sec != 0) - LOGONCE(2, LOG_WARNING, "AIS: Quorum outdated!"); - goto out; - } + if (quorum_age > (int)(timeout_io+timeout_loop)) { + if (t_last_quorum.tv_sec != 0) + LOGONCE(2, LOG_WARNING, "AIS: Quorum outdated!"); + goto out; + } - if (crm_have_quorum) { - DBGLOG(LOG_INFO, "AIS: We have quorum!"); - } else { - LOGONCE(8, LOG_WARNING, "AIS: We do NOT have quorum!"); - goto out; + if (crm_have_quorum) { + DBGLOG(LOG_INFO, "AIS: We have quorum!"); + } else { + LOGONCE(8, LOG_WARNING, "AIS: We do NOT have quorum!"); + goto out; + } } #endif @@ -369,7 +371,6 @@ crm_diff_update(const char *event, xmlNode * msg) { int rc = -1; - long now = time(NULL); const char *op = NULL; if (current_cib != NULL) { @@ -454,21 +455,21 @@ cluster_stack = get_cluster_type(); if (cluster_stack != pcmk_cluster_classic_ais) { - cl_log(LOG_ERR, "SBD currently only supports legacy AIS for quorum state poll"); - /* TODO: Wonder if that's still true with the new code? - * Should be merged completely, right? */ - } + check_ais = 0; + } else { + check_ais = 1; + cl_log(LOG_INFO, "Legacy plug-in detected, AIS quorum check enabled"); + if(is_openais_cluster()) { + crm_cluster.destroy = ais_membership_destroy; + crm_cluster.cpg.cpg_deliver_fn = ais_membership_dispatch; + /* crm_cluster.cpg.cpg_confchg_fn = pcmk_cpg_membership; TODO? */ + crm_cluster.cpg.cpg_confchg_fn = NULL; + } - if(is_openais_cluster()) { - crm_cluster.destroy = ais_membership_destroy; - crm_cluster.cpg.cpg_deliver_fn = ais_membership_dispatch; - /* crm_cluster.cpg.cpg_confchg_fn = pcmk_cpg_membership; TODO? */ - crm_cluster.cpg.cpg_confchg_fn = NULL; - } - - while (!crm_cluster_connect(&crm_cluster)) { - cl_log(LOG_INFO, "Waiting to sign in with cluster ..."); - sleep(reconnect_msec / 1000); + while (!crm_cluster_connect(&crm_cluster)) { + cl_log(LOG_INFO, "Waiting to sign in with cluster ..."); + sleep(reconnect_msec / 1000); + } } #endif @@ -494,7 +495,9 @@ mainloop_add_signal(SIGINT, mon_shutdown); timer_id_notify = g_timeout_add(timeout_loop * 1000, mon_timer_notify, NULL); #ifdef CHECK_AIS - timer_id_ais = g_timeout_add(timeout_loop * 1000, mon_timer_ais, NULL); + if (check_ais) { + timer_id_ais = g_timeout_add(timeout_loop * 1000, mon_timer_ais, NULL); + } #endif g_main_run(mainloop); diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/sbd-1.2.1/src/sbd.h new/sbd-1.2.1/src/sbd.h --- old/sbd-1.2.1/src/sbd.h 2013-10-01 10:22:53.000000000 +0200 +++ new/sbd-1.2.1/src/sbd.h 2013-10-10 11:11:59.000000000 +0200 @@ -19,6 +19,7 @@ #include <arpa/inet.h> #include <asm/unistd.h> #include <clplumbing/cl_log.h> +#include <clplumbing/cl_pidfile.h> #include <clplumbing/cl_reboot.h> #include <clplumbing/coredumps.h> #include <clplumbing/realtime.h> diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/sbd-1.2.1/src/sbd.service new/sbd-1.2.1/src/sbd.service --- old/sbd-1.2.1/src/sbd.service 1970-01-01 01:00:00.000000000 +0100 +++ new/sbd-1.2.1/src/sbd.service 2013-10-10 11:11:59.000000000 +0200 @@ -0,0 +1,24 @@ +[Unit] +Description=Shared-storage based fencing daemon +Before=pacemaker.service +After=corosync.service +PartOf=pacemaker.service +RefuseManualStop=true +RefuseManualStart=true + +[Service] +Type=forking +ExecStart=/usr/share/sbd/sbd.sh start +ExecStop=/usr/share/sbd/sbd.sh stop +PIDFile=/var/run/sbd.pid +Restart=no +# Could this benefit from exit codes for restart? +# Does this need to be set to msgwait * 1.2? +# TimeoutSec= +# If SBD crashes, it'll very likely suicide immediately due to the +# hardware watchdog. But one can always try. +Restart=on-abort + +[Install] +RequiredBy=pacemaker.service + diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/sbd-1.2.1/src/sbd.sh new/sbd-1.2.1/src/sbd.sh --- old/sbd-1.2.1/src/sbd.sh 1970-01-01 01:00:00.000000000 +0100 +++ new/sbd-1.2.1/src/sbd.sh 2013-10-10 11:11:59.000000000 +0200 @@ -0,0 +1,99 @@ +#!/bin/bash +# +# Copyright (C) 2013 Lars Marowsky-Bree <[email protected]> +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License, or (at your option) any later version. +# +# This software is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# + +SBD_CONFIG=/etc/sysconfig/sbd +SBD_BIN="/usr/sbin/sbd" + +test -x $SBD_BIN || exit 1 +test -f $SBD_CONFIG || exit 1 + +. $SBD_CONFIG + +unset LC_ALL; export LC_ALL +unset LANGUAGE; export LANGUAGE + +: ${OCF_ROOT:=/usr/lib/ocf} +: ${OCF_FUNCTIONS_DIR=${OCF_ROOT}/lib/heartbeat} +. ${OCF_FUNCTIONS_DIR}/ocf-shellfuncs + +# Construct commandline for some common options +if [ -z "$SBD_DEVICE" ]; then + echo "No sbd devices defined" + exit 1 +fi +SBD_DEVS=${SBD_DEVICE%;} +SBD_DEVICE=${SBD_DEVS//;/ -d } + +: ${SBD_PIDFILE:=/var/run/sbd.pid} +SBD_OPTS+=" -p $SBD_PIDFILE" +: ${SBD_PACEMAKER:="true"} +if ocf_is_true "$SBD_PACEMAKER" ; then + SBD_OPTS+=" -P" +fi +: ${SBD_WATCHDOG:="true"} +if ocf_is_true "$SBD_WATCHDOG" ; then + SBD_OPTS+=" -W" +fi +if [ -n "$SBD_WATCHDOG_DEV" ]; then + SBD_OPTS+="-w $SBD_WATCHDOG_DEV" +fi +: ${SBD_STARTMODE:="always"} +case "$SBD_STARTMODE" in +always) SBD_OPTS+=" -S 0" ;; +clean) SBD_OPTS+=" -S 1" ;; +esac + +start() { + if ! pidofproc -p $SBD_PIDFILE $SBD_BIN >/dev/null 2>&1 ; then + if ! $SBD_BIN -d $SBD_DEVICE $SBD_OPTS watch ; then + echo "SBD failed to start; aborting." + exit 1 + fi + else + return 0 + fi +} + +stop() { + if ! $SBD_BIN -d $SBD_DEVICE -D $SBD_OPTS message LOCAL exit ; then + echo "SBD failed to stop; aborting." + exit 1 + fi + while pidofproc -p $SBD_PIDFILE $SBD_BIN >/dev/null 2>&1 ; do + sleep 1 + done +} + +case "$1" in +start|stop) + $1 ;; +*) + echo "Usage: $0 (start|stop)" + exit 1 + ;; +esac + +# TODO: +# - Make openais init script call out to this script too +# - How to handle the former "force-start" option? +# force-start) +# SBD_OPTS="$SBD_OPTS -S 0" +# start +# ;; + diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/sbd-1.2.1/src/sbd.sysconfig new/sbd-1.2.1/src/sbd.sysconfig --- old/sbd-1.2.1/src/sbd.sysconfig 1970-01-01 01:00:00.000000000 +0100 +++ new/sbd-1.2.1/src/sbd.sysconfig 2013-10-10 11:11:59.000000000 +0200 @@ -0,0 +1,39 @@ +## Type: string +## Default: "" +# +# SBD_DEVICE specifies the devices to use for exchanging sbd messages +# and to monitor. If specifying more than one path, use ";" as +# separator. +# +SBD_DEVICE="" + +## Type: yesno +## Default: yes +# +# Whether to enable the pacemaker integration. +# +SBD_PACEMAKER= + +## Type: list(always,clean) +## Default: always +# +# Specify the start mode for sbd. Setting this to "clean" will only +# allow sbd to start if it was not previously fenced. See the -S option +# in the man page. +# +SBD_STARTMODE= + +## Type: yesno +## Default: yes +# +# Whether to use a watchdog. +# +SBD_WATCHDOG= + +## Type: string +## Default: "" +# +# Additional options for starting sbd +# +SBD_OPTS= + -- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
