diff --git a/.gitignore b/.gitignore index 11b1b16..e913688 100644 --- a/.gitignore +++ b/.gitignore @@ -1,27 +1,29 @@ *.m4 *.cache compile config.* configure *.list depcomp install-sh Makefile Makefile.in missing stamp-* sbd *.8 *.o *.service sbd.sh *~ *.swp *.patch *.diff *.orig *.rej *.rpm *.tar.* !.copr/Makefile - +sbd-*/ +.deps +test-driver diff --git a/.travis.yml b/.travis.yml index 58286f1..e5aa69e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,42 +1,49 @@ sudo: required language: c os: - linux - linux-ppc64le env: global: - PACKAGE=sbd - BUILD_OS_TYPE=fedora BUILD_OS_DIST= BUILD_OS_VERSION=29 matrix: exclude: - os: linux - os: linux-ppc64le include: - os: linux env: OS_ARCH=x86_64 OS_TYPE=centos OS_MOCK=epel OS_DIST=centos OS_VERSION=7 - os: linux env: OS_ARCH=x86_64 OS_TYPE=centos OS_MOCK=epel OS_DIST=centos OS_VERSION=6 - os: linux env: OS_ARCH=x86_64 OS_TYPE=fedora OS_MOCK=fedora OS_DIST= OS_VERSION=28 - os: linux env: OS_ARCH=x86_64 OS_TYPE=fedora OS_MOCK=fedora OS_DIST= OS_VERSION=29 - os: linux-ppc64le env: OS_ARCH=ppc64le OS_TYPE=fedora OS_MOCK=fedora OS_DIST= OS_VERSION=29 services: - docker install: true script: - - make -f Makefile.am spec export PACKAGE=${PACKAGE} + - make -f Makefile.am srpm PACKAGE=${PACKAGE} - docker pull ${BUILD_OS_TYPE}:${BUILD_OS_DIST}${BUILD_OS_VERSION} - - docker run --privileged -v ${PWD}:/rpms ${BUILD_OS_TYPE}:${BUILD_OS_DIST}${BUILD_OS_VERSION} /bin/bash -c "dnf install -y mock dnf-utils && mock -r ${OS_MOCK}-${OS_VERSION}-${OS_ARCH} --resultdir=/rpms --no-bootstrap-chroot --old-chroot --disable-plugin=yum_cache --disable-plugin=selinux --buildsrpm --spec /rpms/${PACKAGE}.spec --sources /rpms && mock --no-clean -r ${OS_MOCK}-${OS_VERSION}-${OS_ARCH} --resultdir=/rpms --disable-plugin=yum_cache --disable-plugin=selinux --no-bootstrap-chroot --old-chroot /rpms/sbd*.src.rpm" + - docker run --privileged -v ${PWD}:/rpms ${BUILD_OS_TYPE}:${BUILD_OS_DIST}${BUILD_OS_VERSION} /bin/bash -c "dnf install -y mock dnf-utils && mock --no-clean -r ${OS_MOCK}-${OS_VERSION}-${OS_ARCH} --resultdir=/rpms --disable-plugin=yum_cache --disable-plugin=selinux --no-bootstrap-chroot --old-chroot /rpms/sbd*.src.rpm" - ls ${PWD}/${PACKAGE}*.${OS_ARCH}.rpm - docker pull ${OS_TYPE}:${OS_DIST}${OS_VERSION} - docker run --privileged -v ${PWD}:/rpms -v ${PWD}/tests:/tests ${OS_TYPE}:${OS_DIST}${OS_VERSION} /bin/bash -c "yum install -y device-mapper /rpms/${PACKAGE}*.${OS_ARCH}.rpm && /tests/regressions.sh && touch /rpms/regressions.sh.SUCCESS" - ls ${PWD}/regressions.sh.SUCCESS + +addons: + apt: + packages: + - rpm + + diff --git a/Makefile.am b/Makefile.am index f0f6d4e..73be519 100644 --- a/Makefile.am +++ b/Makefile.am @@ -1,55 +1,84 @@ SUBDIRS = src agent man # .gz because github doesn't support .xz yet :-( - -TAG ?= $(shell git log --pretty="format:%H" -n 1) +# this is modified +# +TAG ?= $(shell git log --pretty="format:%H" -n 1 || sed -n -e "s/%global commit //p" sbd.spec)$(shell test -n "$$(git status -s)" && echo -n "-mod") distdir = $(PACKAGE)-$(TAG) TARFILE = $(distdir).tar.gz DIST_ARCHIVES = $(TARFILE) +KEEP_EXISTING_TAR = no +INJECT_GIT_COMMIT = yes +DISTCLEANFILES = sbd-* sbd-*/ +CLEANFILES = *.rpm *.tar.* sbd-* RPM_ROOT = $(shell pwd) RPM_OPTS = --define "_sourcedir $(RPM_ROOT)" \ --define "_specdir $(RPM_ROOT)" \ - --define "_srcrpmdir $(RPM_ROOT)" + --define "_srcrpmdir $(RPM_ROOT)" \ + --define "_builddir $(RPM_ROOT)" \ + --define "_rpmdir $(RPM_ROOT)" MOCK_TARGET ?= rhel-7.1-candidate-x86_64 MOCK_OPTIONS ?= --resultdir=$(RPM_ROOT)/mock --no-cleanup-after BUILD_COUNTER ?= build.counter LAST_COUNT = $(shell test ! -e $(BUILD_COUNTER) && echo 0; test -e $(BUILD_COUNTER) && cat $(BUILD_COUNTER)) COUNT = $(shell expr 1 + $(LAST_COUNT)) +TESTS = tests/regressions.sh +export SBD_BINARY := src/sbd +EXTRA_DIST = sbd.spec tests/regressions.sh + export: rm -f $(PACKAGE)-HEAD.tar.* + if test "$(KEEP_EXISTING_TAR)" != "yes"; then \ + rm -f $(TARFILE); \ + fi; + ! (git status -s | grep "??" && echo "untracked files present in git-repo" ) if [ -f $(TARFILE) ]; then \ echo `date`: Using existing tarball: $(TARFILE); \ else \ - rm -f $(PACKAGE).tar.*; \ - git archive --prefix=$(distdir)/ $(TAG) | gzip > $(TARFILE); \ + rm -f $(PACKAGE).tar.*; \ + (git archive --prefix=$(distdir)/ $(shell echo $(TAG)|cut -f1 -d-) || tar -c --transform="s,^,$(distdir)/," --exclude="*.tar.*" --exclude="$(distdir)" --exclude="*.o" --exclude="*.8" --exclude="config.*" --exclude="Makefile" --exclude="Makefile.in" --exclude="stamp-*" --exclude="*.service" --exclude="sbd" --exclude="*.m4" --exclude="*.cache" --exclude="configure" --exclude="*.list" --exclude="depcomp" --exclude="install-sh" --exclude="missing" --exclude="compile" --exclude="sbd.sh" --exclude="~" --exclude="*.swp" --exclude="*.patch" --exclude="*.diff" --exclude="*.orig" --exclude="*.rej" --exclude="*.rpm" --exclude=".deps" --exclude="test-driver" *) | gzip > $(TARFILE); \ + if test -n "$$(git status -s)" || test "$(INJECT_GIT_COMMIT)" = "yes"; then \ + if test -n "$$(git status -s)"; then git diff HEAD > uncommitted.diff; fi; \ + rm -rf $(distdir); tar -xzf $(TARFILE); rm $(TARFILE); \ + cd $(distdir); \ + if test -n "$$(git status -s)"; then patch -p1 -i ../uncommitted.diff; fi; \ + cd ..; \ + sed -i 's/global\ commit.*/global\ commit\ $(TAG)/' $(distdir)/$(PACKAGE).spec; \ + tar -czf $(TARFILE) $(distdir); rm -rf $(distdir); \ + rm -f uncommitted.diff; \ + fi; \ echo `date`: Rebuilt $(TARFILE); \ fi -#replace commit id in sbd.spce +#replace commit id in sbd.spec spec: rm -f *.src.rpm - sed -i 's/global\ commit.*/global\ commit\ $(TAG)/' $(PACKAGE).spec + rm -rf $(distdir) + mkdir $(distdir) + cp $(PACKAGE).spec $(distdir) + sed -i 's/global\ commit.*/global\ commit\ $(TAG)/' $(distdir)/$(PACKAGE).spec -srpm: spec export +srpm: export spec if [ -e $(BUILD_COUNTER) ]; then \ - sed -i 's/global\ buildnum.*/global\ buildnum\ $(COUNT)/' $(PACKAGE).spec; \ + sed -i 's/global\ buildnum.*/global\ buildnum\ $(COUNT)/' $(distdir)/$(PACKAGE).spec; \ echo $(COUNT) > $(BUILD_COUNTER); \ fi - rpmbuild $(RPM_OPTS) -bs $(PACKAGE).spec + rpmbuild $(RPM_OPTS) -bs $(distdir)/$(PACKAGE).spec -rpm: spec export - rpmbuild $(RPM_OPTS) -ba $(PACKAGE).spec +rpm: export spec + rpmbuild $(RPM_OPTS) -ba $(distdir)/$(PACKAGE).spec mock: srpm -rm -rf $(RPM_ROOT)/mock @echo "mock --root=$* --rebuild $(MOCK_OPTIONS) $(RPM_ROOT)/*.src.rpm" mock --root=$(MOCK_TARGET) --rebuild $(MOCK_OPTIONS) $(RPM_ROOT)/*.src.rpm beekhof: mock cluster-helper -- 'rm -f sbd-*.x86_64.rpm' cluster-helper --copy $(RPM_ROOT)/mock/sbd-*.x86_64.rpm {}: cluster-helper -- yum install -y sbd-*.x86_64.rpm + diff --git a/man/Makefile.am b/man/Makefile.am index 28efd74..3f89085 100644 --- a/man/Makefile.am +++ b/man/Makefile.am @@ -1,7 +1,7 @@ -man_MANS = sbd.8 +dist_man_MANS = sbd.8 -EXTRA_DIST = $(man_MANS) +EXTRA_DIST = sbd.8.pod sbd.8: sbd.8.pod @POD2MAN@ -s 8 -c "STONITH Block Device" -r "SBD" -n "SBD" $< $@ diff --git a/sbd.spec b/sbd.spec index 03f2fab..4584c7c 100644 --- a/sbd.spec +++ b/sbd.spec @@ -1,155 +1,156 @@ # # spec file for package sbd # # Copyright (c) 2014 SUSE LINUX Products GmbH, Nuernberg, Germany. # Copyright (c) 2013 Lars Marowsky-Bree # # All modifications and additions to the file contributed by third parties # remain the property of their copyright owners, unless otherwise agreed # upon. The license for this file, and modifications and additions to the # file, is the same license as for the pristine package itself (unless the # license for the pristine package is not an Open Source License, in which # case the license is the MIT License). An "Open Source License" is a # license that conforms to the Open Source Definition (Version 1.9) # published by the Open Source Initiative. # Please submit bugfixes or comments via http://bugs.opensuse.org/ # -%global commit 2d595fdde4f62278b96db1b7fb79aae5e990bb0b -%global shortcommit %(c=%{commit}; echo ${c:0:7}) +%global commit 5705703da3db01bb4c34fd73ae33f24b43a16b78-mod +%global shortcommit %(echo %{commit}|cut -c1-8) +%global modified %(echo %{commit}-|cut -f2 -d-) %global github_owner beekhof %global buildnum 1 Name: sbd Summary: Storage-based death License: GPLv2+ Group: System Environment/Daemons Version: 1.4.0 -Release: 0.%{buildnum}.%{shortcommit}.git%{?dist} +Release: 99.%{buildnum}.%{shortcommit}.%{modified}git%{?dist} Url: https://github.com/%{github_owner}/%{name} Source0: https://github.com/%{github_owner}/%{name}/archive/%{commit}/%{name}-%{commit}.tar.gz BuildRoot: %{_tmppath}/%{name}-%{version}-build BuildRequires: autoconf BuildRequires: automake BuildRequires: libuuid-devel BuildRequires: glib2-devel BuildRequires: libaio-devel BuildRequires: corosynclib-devel BuildRequires: pacemaker-libs-devel BuildRequires: libtool BuildRequires: libuuid-devel BuildRequires: libxml2-devel BuildRequires: pkgconfig BuildRequires: make %if 0%{?rhel} > 0 ExclusiveArch: i686 x86_64 s390x aarch64 ppc64le %endif %if %{defined systemd_requires} %systemd_requires %endif %description This package contains the storage-based death functionality. %prep ########################################################### # %setup -n sbd-%{version} -q %setup -q -n %{name}-%{commit} ########################################################### %build autoreconf -i export CFLAGS="$RPM_OPT_FLAGS -Wall -Werror" %configure make %{?_smp_mflags} ########################################################### %install ########################################################### make DESTDIR=$RPM_BUILD_ROOT LIBDIR=%{_libdir} install rm -rf ${RPM_BUILD_ROOT}%{_libdir}/stonith 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 install -D -m 0644 src/sbd_remote.service $RPM_BUILD_ROOT/%{_unitdir}/sbd_remote.service %endif mkdir -p ${RPM_BUILD_ROOT}%{_sysconfdir}/sysconfig install -m 644 src/sbd.sysconfig ${RPM_BUILD_ROOT}%{_sysconfdir}/sysconfig/sbd %clean rm -rf %{buildroot} %if %{defined _unitdir} %post %systemd_post sbd.service %systemd_post sbd_remote.service %preun %systemd_preun sbd.service %systemd_preun sbd_remote.service %postun %systemd_postun sbd.service %systemd_postun sbd_remote.service %endif %files ########################################################### %defattr(-,root,root) %config(noreplace) %{_sysconfdir}/sysconfig/sbd %{_sbindir}/sbd %{_datadir}/sbd %doc %{_mandir}/man8/sbd* %if %{defined _unitdir} %{_unitdir}/sbd.service %{_unitdir}/sbd_remote.service %endif %doc COPYING %changelog * Mon Jan 14 2019 - 1.4.0-0.1.2d595fdd.git - updated travis-CI (ppc64le-build, fedora29, remove need for alectolytic-build-container) - make watchdog-device-query easier to be handled by an SELinux-policy - configurable delay value for SBD_DELAY_START - use pacemaker's new pe api with constructors/destructors - make timeout-action executed by sbd configurable - init script for sysv systems - version bump to v1.4.0 to denote Pacemaker 2.0.0 compatibility * Fri Jun 29 2018 - 1.3.1-0.1.e102d9ed.git - removed unneeded python-devel build-requirement - changed legacy corosync-devel to corosynclib-devel * Fri Nov 3 2017 - 1.3.1-0.1.a180176c.git - Add commands to test/query watchdogs - Allow 2-node-operation with a single shared-disk - Overhaul of the command-line options & config-file - Proper handling of off instead of reboot - Refactored disk-servant for more robust communication with parent - Fix config for Debian + configurable location of config - Fixes in sbd.sh - multiple SBD devices and others * Sun Mar 27 2016 - 1.3.0-0.1.4ee36fa3.git - Changes since v1.2.0 like adding the possibility to have a watchdog-only setup without shared-block-devices legitimate a bump to v1.3.0. * Mon Oct 13 2014 - 1.2.1-0.4.3de531ed.git - Fixes for suitability to the el7 environment * Tue Sep 30 2014 - 1.2.1-0.3.8f912945.git - Only build on archs supported by the HA Add-on * Fri Aug 29 2014 - 1.2.1-0.2.8f912945.git - Remove some additional SUSE-isms * Fri Aug 29 2014 - 1.2.1-0.1.8f912945.git - Prepare for package review Resolves: rhbz#1134245 diff --git a/src/Makefile.am b/src/Makefile.am index 4d509c2..ec51dde 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -1,15 +1,15 @@ AM_CFLAGS = -D_GNU_SOURCE -DCHECK_AIS -DSBINDIR=\"$(sbindir)\" AM_CPPFLAGS = -I$(includedir)/pacemaker \ -I$(includedir)/heartbeat \ $(glib_CFLAGS) sbin_PROGRAMS = sbd -sbd_SOURCES = sbd-common.c sbd-inquisitor.c sbd-pacemaker.c sbd-cluster.c setproctitle.c +sbd_SOURCES = sbd-common.c sbd-inquisitor.c sbd-pacemaker.c sbd-cluster.c setproctitle.c sbd.h sbd.sysconfig if SUPPORT_SHARED_DISK sbd_SOURCES += sbd-md.c endif sbd_LDADD = $(glib_LIBS) $(libcoroipcc_LIBS) diff --git a/tests/regressions.sh b/tests/regressions.sh index 4c531ae..2ab816c 100755 --- a/tests/regressions.sh +++ b/tests/regressions.sh @@ -1,175 +1,181 @@ #!/bin/bash # # Copyright (C) 2013 Lars Marowsky-Bree # # 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 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 program; if not, write to the Free Software Foundation, Inc., # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. # # TODO: # - More tests # - Handle optional, long-running tests better # - Support for explicitly running a single test # - Verify output from commands # - Normalize uuids and device names so they are diffable # - Log to file, instead of syslog is needed # - How to test watch mode? # - Can the unit/service file be tested? or at least the wrapper? +: ${SBD_BINARY:="/usr/sbin/sbd"} + +sbd() { + ${SBD_BINARY} $* +} + sbd_setup() { trap sbd_teardown EXIT for N in $(seq 3) ; do F[$N]=$(mktemp /tmp/sbd.device.$N.XXXXXX) dd if=/dev/zero of=${F[$N]} count=2048 L[$N]=$(losetup -f) losetup ${L[$N]} ${F[$N]} D[$N]="/dev/mapper/sbd_$N" dmsetup create sbd_$N --table "0 2048 linear ${L[$N]} 0" dmsetup mknodes sbd_$N done } sbd_teardown() { for N in $(seq 3) ; do dmsetup remove sbd_$N losetup -d ${L[$N]} rm -f ${F[$N]} done } sbd_dev_fail() { dmsetup wipe_table sbd_$1 } sbd_dev_resume() { dmsetup suspend sbd_$1 dmsetup load sbd_$1 --table "0 2048 linear ${L[$1]} 0" dmsetup resume sbd_$1 } _ok() { echo -- $@ $@ rc=$? if [ $rc -ne 0 ]; then echo "$@ failed with $rc" exit $rc fi } _no() { echo -- $@ $@ rc=$? if [ $rc -eq 0 ]; then echo "$@ did NOT fail ($rc)" exit $rc fi return 0 } test_1() { echo "Creating three devices" _ok sbd -d ${D[1]} -d ${D[2]} -d ${D[3]} create _ok sbd -d ${D[1]} -d ${D[2]} -d ${D[3]} dump } test_2() { echo "Basic functionality" for S in `seq 2` ; do _ok sbd -d ${D[1]} -d ${D[2]} -d ${D[3]} allocate "test-$S" done _ok sbd -d ${D[1]} -d ${D[2]} -d ${D[3]} -n test-1 message test-2 reset _ok sbd -d ${D[1]} -d ${D[2]} -d ${D[3]} list } test_3() { echo "Start mode (expected not to start, because reset was written in test_2)" _no sbd -d ${D[1]} -d ${D[2]} -d ${D[3]} -n test-2 -Z -Z -Z -S 1 watch } test_4() { echo "Deliver message with 1 failure" sbd_dev_fail 1 _no sbd -d ${D[1]} -n test-1 message test-2 exit _no sbd -d ${D[1]} -d ${D[2]} -n test-1 message test-2 exit _ok sbd -d ${D[1]} -d ${D[2]} -d ${D[3]} -n test-1 message test-2 exit sbd_dev_resume 1 } test_5() { echo "Deliver message with 2 failures" sbd_dev_fail 1 sbd_dev_fail 2 _no sbd -d ${D[1]} -d ${D[2]} -n test-1 message test-2 exit _no sbd -d ${D[1]} -d ${D[2]} -d ${D[3]} -n test-1 message test-2 exit sbd_dev_resume 1 sbd_dev_resume 2 } test_6() { echo "Deliver message with 3 failures" sbd_dev_fail 1 sbd_dev_fail 2 sbd_dev_fail 3 _no sbd -d ${D[1]} -d ${D[2]} -d ${D[3]} -n test-1 message test-2 exit sbd_dev_resume 1 sbd_dev_resume 2 sbd_dev_resume 3 } test_101() { echo "Creating one device" _ok sbd -d ${D[1]} create } test_102() { echo "Creating two devices" _ok sbd -d ${D[1]} -d ${D[2]} create } test_7() { echo "Allocate all slots plus 1" _ok sbd -d ${D[1]} -d ${D[2]} -d ${D[3]} -2 0 create for S in `seq 255` ; do _ok sbd -d ${D[1]} -d ${D[2]} -d ${D[3]} allocate "test-$S" done _no sbd -d ${D[1]} -d ${D[2]} -d ${D[3]} allocate "test-256" } test_8() { echo "Non-existent device path" _no sbd -d /dev/kfdifdifdfdlfd -create 2>/dev/null } test_9() { echo "Basic sbd invocation" _no sbd _ok sbd -h } sbd_setup for T in $(seq 9); do if ! test_$T ; then echo "FAILURE: Test $T" break fi echo "SUCCESS: Test $T" done echo "SUCCESS: All tests completed"