* Thu Mar 5 2020 Klaus Wenninger <kwenning@redhat.com> - 1.4.1-1

- Rebase to upstream v1.4.1
- Make coverity happy with parameter passing in regressions.sh
- Add auto generated environment section to man-page
- Overhaul setting scheduler policy/priority
- Enable Fedora CI Gating
This commit is contained in:
Klaus Wenninger 2020-03-06 14:25:25 +01:00
parent cfa13334a6
commit 050f11c6be
10 changed files with 1785 additions and 150 deletions

1
.gitignore vendored
View File

@ -1 +1,2 @@
/sbd-*.tar.gz
/sbd-*.src.rpm

View File

@ -0,0 +1,82 @@
From 1d2a7b8d059d4f090b351b8decca0ddf274c82a0 Mon Sep 17 00:00:00 2001
From: Klaus Wenninger <klaus.wenninger@aon.at>
Date: Wed, 20 Nov 2019 15:20:19 +0100
Subject: [PATCH] Fix: regressions.sh: make parameter passing consistent
---
tests/regressions.sh | 24 ++++++++++++------------
1 file changed, 12 insertions(+), 12 deletions(-)
diff --git a/tests/regressions.sh b/tests/regressions.sh
index 6cfb303..7ab80be 100755
--- a/tests/regressions.sh
+++ b/tests/regressions.sh
@@ -32,7 +32,7 @@
: ${SBD_USE_DM:="yes"}
sbd() {
- LD_PRELOAD=${SBD_PRELOAD} SBD_WATCHDOG_TIMEOUT=5 SBD_DEVICE="${SBD_DEVICE}" SBD_PRELOAD_LOG=${SBD_PRELOAD_LOG} SBD_WATCHDOG_DEV=/dev/watchdog setsid ${SBD_BINARY} -p ${SBD_PIDFILE} $*
+ LD_PRELOAD=${SBD_PRELOAD} SBD_WATCHDOG_TIMEOUT=5 SBD_DEVICE="${SBD_DEVICE}" SBD_PRELOAD_LOG=${SBD_PRELOAD_LOG} SBD_WATCHDOG_DEV=/dev/watchdog setsid ${SBD_BINARY} -p ${SBD_PIDFILE} "$@"
}
sbd_wipe_disk() {
@@ -98,26 +98,26 @@ sbd_daemon_cleanup() {
pkill -TERM --pidfile ${SBD_PIDFILE} 2>/dev/null
sleep 5
pkill -KILL --pidfile ${SBD_PIDFILE} 2>/dev/null
- pkill -KILL --parent $(cat ${SBD_PIDFILE} 2>/dev/null) 2>/dev/null
+ pkill -KILL --parent "$(cat ${SBD_PIDFILE} 2>/dev/null)" 2>/dev/null
echo > ${SBD_PIDFILE}
}
_ok() {
- echo -- $@
- $@
+ echo "-- $*"
+ "$@"
rc=$?
if [ $rc -ne 0 ]; then
- echo "$@ failed with $rc"
+ echo "$* failed with $rc"
exit $rc
fi
}
_no() {
- echo -- $@
- $@
+ echo "-- $*"
+ "$@"
rc=$?
if [ $rc -eq 0 ]; then
- echo "$@ did NOT fail ($rc)"
+ echo "$* did NOT fail ($rc)"
exit $rc
fi
return 0
@@ -126,7 +126,7 @@ _no() {
_in_log() {
grep "$@" ${SBD_PRELOAD_LOG} >/dev/null
if [ $? -ne 0 ]; then
- echo "didn't find '$@' in log:"
+ echo "didn't find '$*' in log:"
cat ${SBD_PRELOAD_LOG}
sbd_daemon_cleanup
exit 1
@@ -227,10 +227,10 @@ test_stall_inquisitor() {
sbd_daemon_cleanup
sbd -d ${D[1]} -d ${D[2]} -d ${D[3]} -n test-1 watch
sleep 10
- _ok kill -0 $(cat ${SBD_PIDFILE})
- kill -STOP $(cat ${SBD_PIDFILE})
+ _ok kill -0 "$(cat ${SBD_PIDFILE})"
+ kill -STOP "$(cat ${SBD_PIDFILE})"
sleep 10
- kill -CONT $(cat ${SBD_PIDFILE}) 2>/dev/null
+ kill -CONT "$(cat ${SBD_PIDFILE})" 2>/dev/null
_in_log "watchdog fired"
}
--
1.8.3.1

View File

@ -1,142 +0,0 @@
From 8301cbafed191f30656a22876941cc7c9189b623 Mon Sep 17 00:00:00 2001
From: Klaus Wenninger <klaus.wenninger@aon.at>
Date: Thu, 31 Jan 2019 14:42:01 +0100
Subject: [PATCH] Refactor: fail earlier on invalid servants
---
src/sbd-inquisitor.c | 51 ++++++++++++++++++++++++++++++++-------------------
src/sbd-md.c | 7 +------
src/sbd.h | 2 +-
3 files changed, 34 insertions(+), 26 deletions(-)
diff --git a/src/sbd-inquisitor.c b/src/sbd-inquisitor.c
index 8e0bc87..9be6c99 100644
--- a/src/sbd-inquisitor.c
+++ b/src/sbd-inquisitor.c
@@ -42,19 +42,36 @@ void recruit_servant(const char *devname, pid_t pid)
struct servants_list_item *newbie;
if (lookup_servant_by_dev(devname)) {
- cl_log(LOG_DEBUG, "Servant %s already exists", devname);
- return;
+ cl_log(LOG_DEBUG, "Servant %s already exists", devname);
+ return;
}
newbie = malloc(sizeof(*newbie));
- if (!newbie) {
- fprintf(stderr, "malloc failed in recruit_servant.\n");
- exit(1);
+ if (newbie) {
+ memset(newbie, 0, sizeof(*newbie));
+ newbie->devname = strdup(devname);
+ newbie->pid = pid;
+ newbie->first_start = 1;
+ }
+ if (!newbie || !newbie->devname) {
+ fprintf(stderr, "heap allocation failed in recruit_servant.\n");
+ exit(1);
+ }
+
+ /* some sanity-check on our newbie */
+ if (sbd_is_disk(newbie)) {
+ cl_log(LOG_INFO, "Monitoring %s", devname);
+ disk_count++;
+ } else if (sbd_is_pcmk(newbie) || sbd_is_cluster(newbie)) {
+ /* alive just after pcmk and cluster servants have shown up */
+ newbie->outdated = 1;
+ } else {
+ /* toss our newbie */
+ cl_log(LOG_ERR, "Refusing to recruit unrecognized servant %s", devname);
+ free((void *) newbie->devname);
+ free(newbie);
+ return;
}
- memset(newbie, 0, sizeof(*newbie));
- newbie->devname = strdup(devname);
- newbie->pid = pid;
- newbie->first_start = 1;
if (!s) {
servants_leader = newbie;
@@ -65,12 +82,6 @@ void recruit_servant(const char *devname, pid_t pid)
}
servant_count++;
- if(sbd_is_disk(newbie)) {
- cl_log(LOG_INFO, "Monitoring %s", devname);
- disk_count++;
- } else {
- newbie->outdated = 1;
- }
}
int assign_servant(const char* devname, functionp_t functionp, int mode, const void* argp)
@@ -148,7 +159,7 @@ void servant_start(struct servants_list_item *s)
if (sbd_is_disk(s)) {
#if SUPPORT_SHARED_DISK
DBGLOG(LOG_INFO, "Starting servant for device %s", s->devname);
- s->pid = assign_servant(s->devname, servant, start_mode, s);
+ s->pid = assign_servant(s->devname, servant_md, start_mode, s);
#else
cl_log(LOG_ERR, "Shared disk functionality not supported");
return;
@@ -785,12 +796,14 @@ parse_device_line(const char *line)
if (lpc > last) {
entry = calloc(1, 1 + lpc - last);
+ if (!entry) {
+ fprintf(stderr, "heap allocation failed parsing device-line.\n");
+ exit(1);
+ }
rc = sscanf(line + last, "%[^;]", entry);
}
- if (entry == NULL) {
- /* Skip */
- } else if (rc != 1) {
+ if (rc != 1) {
cl_log(LOG_WARNING, "Could not parse (%d %d): %s", last, lpc, line + last);
} else {
cl_log(LOG_DEBUG, "Adding '%s'", entry);
diff --git a/src/sbd-md.c b/src/sbd-md.c
index 579d273..ba2c34d 100644
--- a/src/sbd-md.c
+++ b/src/sbd-md.c
@@ -1031,7 +1031,7 @@ static int servant_check_timeout_inconsistent(struct sector_header_s *hdr)
return 0;
}
-int servant(const char *diskname, int mode, const void* argp)
+int servant_md(const char *diskname, int mode, const void* argp)
{
struct sector_mbox_s *s_mbox = NULL;
struct sector_node_s *s_node = NULL;
@@ -1046,11 +1046,6 @@ int servant(const char *diskname, int mode, const void* argp)
char uuid[37];
const struct servants_list_item *s = argp;
- if (!diskname) {
- cl_log(LOG_ERR, "Empty disk name %s.", diskname);
- return -1;
- }
-
cl_log(LOG_INFO, "Servant starting for device %s", diskname);
/* Block most of the signals */
diff --git a/src/sbd.h b/src/sbd.h
index 386c85c..6fe07f9 100644
--- a/src/sbd.h
+++ b/src/sbd.h
@@ -175,7 +175,7 @@ int ping_via_slots(const char *name, struct servants_list_item *servants);
int dump_headers(struct servants_list_item *servants);
unsigned long get_first_msgwait(struct servants_list_item *servants);
int messenger(const char *name, const char *msg, struct servants_list_item *servants);
-int servant(const char *diskname, int mode, const void* argp);
+int servant_md(const char *diskname, int mode, const void* argp);
#endif
int servant_pcmk(const char *diskname, int mode, const void* argp);
--
1.8.3.1

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,152 @@
From 4bc08cf76fc01e98cbec76bf32bb333b77f69217 Mon Sep 17 00:00:00 2001
From: Klaus Wenninger <klaus.wenninger@aon.at>
Date: Thu, 27 Feb 2020 19:02:57 +0100
Subject: [PATCH] Fix: scheduling: overhaul the whole thing
- prevent possible lockup when format in proc changes
- properly get and handle scheduler policy & prio
- on SCHED_RR failing push to the max with SCHED_OTHER
---
src/sbd-common.c | 56 ++++++++++++++++++++++++++++++++++++++++++++------------
1 file changed, 44 insertions(+), 12 deletions(-)
diff --git a/src/sbd-common.c b/src/sbd-common.c
index 9ec43b2..c2da758 100644
--- a/src/sbd-common.c
+++ b/src/sbd-common.c
@@ -26,6 +26,9 @@
#include <pwd.h>
#include <unistd.h>
#include <dirent.h>
+#include <sys/time.h>
+#include <sys/resource.h>
+#include <limits.h>
#ifdef _POSIX_MEMLOCK
# include <sys/mman.h>
@@ -298,7 +301,7 @@ watchdog_populate_list(void)
FILE *file;
snprintf(entry_name, sizeof(entry_name),
- SYS_CLASS_WATCHDOG "/%s/dev", entry->d_name);
+ SYS_CLASS_WATCHDOG "/%s/dev", entry->d_name);
file = fopen(entry_name, "r");
if (file) {
int major, minor;
@@ -667,7 +670,7 @@ static int get_realtime_budget(void)
{
FILE *f;
char fname[PATH_MAX];
- int res = -1, lnum = 0;
+ int res = -1, lnum = 0, num;
char *cgroup = NULL, *namespecs = NULL;
snprintf(fname, PATH_MAX, "/proc/%jd/cgroup", (intmax_t)getpid());
@@ -677,7 +680,8 @@ static int get_realtime_budget(void)
(intmax_t)getpid());
goto exit_res;
}
- while( fscanf(f, "%d:%m[^:]:%m[^\n]", &lnum, &namespecs, &cgroup) !=EOF ) {
+ while( (num = fscanf(f, "%d:%m[^:]:%m[^\n]\n", &lnum,
+ &namespecs, &cgroup)) !=EOF ) {
if (namespecs && strstr(namespecs, "cpuacct")) {
free(namespecs);
break;
@@ -690,6 +694,11 @@ static int get_realtime_budget(void)
free(namespecs);
namespecs = NULL;
}
+ /* not to get stuck if format changes */
+ if ((num < 3) && ((fscanf(f, "%*[^\n]") == EOF) ||
+ (fscanf(f, "\n") == EOF))) {
+ break;
+ }
}
fclose(f);
if (cgroup == NULL) {
@@ -776,15 +785,17 @@ sbd_make_realtime(int priority, int stackgrowK, int heapgrowK)
return;
}
+do {
#ifdef SCHED_RR
if (move_to_root_cgroup) {
sbd_move_to_root_cgroup(enforce_moving_to_root_cgroup);
}
{
- int pcurrent = 0;
int pmin = sched_get_priority_min(SCHED_RR);
int pmax = sched_get_priority_max(SCHED_RR);
+ struct sched_param sp;
+ int pcurrent;
if (priority == 0) {
priority = pmax;
@@ -794,26 +805,47 @@ sbd_make_realtime(int priority, int stackgrowK, int heapgrowK)
priority = pmax;
}
- pcurrent = sched_getscheduler(0);
- if (pcurrent < 0) {
+ if (sched_getparam(0, &sp) < 0) {
cl_perror("Unable to get scheduler priority");
- } else if(pcurrent < priority) {
- struct sched_param sp;
+ } else if ((pcurrent = sched_getscheduler(0)) < 0) {
+ cl_perror("Unable to get scheduler policy");
+ } else if ((pcurrent == SCHED_RR) &&
+ (sp.sched_priority >= priority)) {
+ cl_log(LOG_INFO,
+ "Stay with priority (%d) for policy SCHED_RR",
+ sp.sched_priority);
+ break;
+ } else {
memset(&sp, 0, sizeof(sp));
sp.sched_priority = priority;
if (sched_setscheduler(0, SCHED_RR, &sp) < 0) {
- cl_perror("Unable to set scheduler priority to %d", priority);
+ cl_perror(
+ "Unable to set scheduler policy to SCHED_RR priority %d",
+ priority);
} else {
- cl_log(LOG_INFO, "Scheduler priority is now %d", priority);
+ cl_log(LOG_INFO,
+ "Scheduler policy is now SCHED_RR priority %d",
+ priority);
+ break;
}
}
}
#else
- cl_log(LOG_ERR, "System does not support updating the scheduler priority");
+ cl_log(LOG_ERR, "System does not support updating the scheduler policy");
+#endif
+#ifdef PRIO_PGRP
+ if (setpriority(PRIO_PGRP, 0, INT_MIN) < 0) {
+ cl_perror("Unable to raise the scheduler priority");
+ } else {
+ cl_log(LOG_INFO, "Scheduler priority raised to the maximum");
+ }
+#else
+ cl_perror("System does not support setting the scheduler priority");
#endif
+} while (0);
sbd_memlock(heapgrowK, stackgrowK);
}
@@ -826,7 +858,7 @@ maximize_priority(void)
return;
}
- sbd_make_realtime(0, 256, 256);
+ sbd_make_realtime(0, 256, 256);
if (ioprio_set(IOPRIO_WHO_PROCESS, getpid(),
IOPRIO_PRIO_VALUE(IOPRIO_CLASS_RT, 1)) != 0) {
--
1.8.3.1

15
gating.yaml Normal file
View File

@ -0,0 +1,15 @@
--- !Policy
product_versions:
- fedora-*
decision_context: bodhi_update_push_testing
subject_type: koji_build
rules:
- !PassingTestCaseRule {test_case_name: fedora-ci.koji-build.tier0.functional}
--- !Policy
product_versions:
- fedora-*
decision_context: bodhi_update_push_stable
subject_type: koji_build
rules:
- !PassingTestCaseRule {test_case_name: fedora-ci.koji-build.tier0.functional}

View File

@ -15,24 +15,28 @@
# Please submit bugfixes or comments via http://bugs.opensuse.org/
#
%global commit 7f33d1a409d0a4e2cd69946688c48eaa8f3c5d26
%global commit 25fce8a7d5e8cd5abc2379077381b10bd6cec183
%global shortcommit %(c=%{commit}; echo ${c:0:7})
%global github_owner clusterlabs
%global github_owner Clusterlabs
%global buildnum 1
Name: sbd
Summary: Storage-based death
License: GPLv2+
Version: 1.4.0
Release: 3%{?dist}
Group: System Environment/Daemons
Version: 1.4.1
Release: %{buildnum}%{?dist}
Url: https://github.com/%{github_owner}/%{name}
Source0: https://github.com/%{github_owner}/%{name}/archive/%{commit}/%{name}-%{commit}.tar.gz
Patch0: 0001-Refactor-fail-earlier-on-invalid-servants.patch
Patch0: 0001-Fix-regressions.sh-make-parameter-passing-consistent.patch
Patch1: 0002-Doc-add-environment-section-to-man-page.patch
Patch2: 0003-Fix-scheduling-overhaul-the-whole-thing.patch
BuildRequires: autoconf
BuildRequires: automake
BuildRequires: libuuid-devel
BuildRequires: glib2-devel
BuildRequires: libaio-devel
BuildRequires: corosynclib-devel
BuildRequires: corosync-devel
BuildRequires: pacemaker-libs-devel
BuildRequires: libtool
BuildRequires: libuuid-devel
@ -40,6 +44,7 @@ BuildRequires: libxml2-devel
BuildRequires: pkgconfig
BuildRequires: make
BuildRequires: systemd
Conflicts: fence-agents-sbd < 4.5.0
%if 0%{?rhel}
ExclusiveArch: i686 x86_64 s390x aarch64 ppc64le
@ -53,15 +58,28 @@ ExclusiveArch: i686 x86_64 s390x aarch64 ppc64le
This package contains the storage-based death functionality.
%package tests
Summary: Storage-based death environment for regression tests
License: GPLv2+
Group: System Environment/Daemons
%description tests
This package provides an environment + testscripts for
regression-testing sbd.
###########################################################
%prep
%autosetup -n %{name}-%{commit} -p1
%ifarch s390x s390
sed -i src/sbd.sysconfig -e "s/Default: 5/Default: 15/"
sed -i src/sbd.sysconfig -e "s/SBD_WATCHDOG_TIMEOUT=5/SBD_WATCHDOG_TIMEOUT=15/"
%endif
###########################################################
%build
autoreconf -i
./autogen.sh
export CFLAGS="$RPM_OPT_FLAGS -Wall -Werror"
%configure
make %{?_smp_mflags}
@ -73,6 +91,7 @@ make %{?_smp_mflags}
make DESTDIR=$RPM_BUILD_ROOT LIBDIR=%{_libdir} install
rm -rf ${RPM_BUILD_ROOT}%{_libdir}/stonith
install -D -m 0755 tests/regressions.sh $RPM_BUILD_ROOT/usr/share/sbd/regressions.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
@ -81,12 +100,26 @@ install -D -m 0644 src/sbd_remote.service $RPM_BUILD_ROOT/%{_unitdir}/sbd_remote
mkdir -p ${RPM_BUILD_ROOT}%{_sysconfdir}/sysconfig
install -m 644 src/sbd.sysconfig ${RPM_BUILD_ROOT}%{_sysconfdir}/sysconfig/sbd
# Don't package static libs
find %{buildroot} -name '*.a' -type f -print0 | xargs -0 rm -f
find %{buildroot} -name '*.la' -type f -print0 | xargs -0 rm -f
###########################################################
%if %{defined _unitdir}
%post
%systemd_post sbd.service
%systemd_post sbd_remote.service
if [ $1 -ne 1 ] ; then
if systemctl --quiet is-enabled sbd.service 2>/dev/null
then
systemctl --quiet reenable sbd.service 2>/dev/null || :
fi
if systemctl --quiet is-enabled sbd_remote.service 2>/dev/null
then
systemctl --quiet reenable sbd_remote.service 2>/dev/null || :
fi
fi
%preun
%systemd_preun sbd.service
@ -102,6 +135,7 @@ install -m 644 src/sbd.sysconfig ${RPM_BUILD_ROOT}%{_sysconfdir}/sysconfig/sbd
%defattr(-,root,root)
%config(noreplace) %{_sysconfdir}/sysconfig/sbd
%{_sbindir}/sbd
%exclude %{_datadir}/sbd/regressions.sh
%doc %{_mandir}/man8/sbd*
%if %{defined _unitdir}
%{_unitdir}/sbd.service
@ -109,7 +143,21 @@ install -m 644 src/sbd.sysconfig ${RPM_BUILD_ROOT}%{_sysconfdir}/sysconfig/sbd
%endif
%doc COPYING
%files tests
###########################################################
%defattr(-,root,root)
%dir %{_datadir}/sbd
%{_datadir}/sbd/regressions.sh
%{_libdir}/libsbdtestbed*
%changelog
* Thu Mar 5 2020 Klaus Wenninger <kwenning@redhat.com> - 1.4.1-4
- Rebase to upstream v1.4.1
- Make coverity happy with parameter passing in regressions.sh
- Add auto generated environment section to man-page
- Overhaul setting scheduler policy/priority
- Enable Fedora CI Gating
* Thu Jan 30 2020 Fedora Release Engineering <releng@fedoraproject.org> - 1.4.0-3
- Rebuilt for https://fedoraproject.org/wiki/Fedora_32_Mass_Rebuild

View File

@ -1 +1 @@
SHA512 (sbd-7f33d1a409d0a4e2cd69946688c48eaa8f3c5d26.tar.gz) = 1baca43ad95d8d0886cbd1db82eeb617a2055e5a31d16f2802c27b120894c6829bfc99663e2da402a37e6c52d0cda6cec63cbc15cb6c580895e5a1d30e5b1c62
SHA512 (sbd-25fce8a7d5e8cd5abc2379077381b10bd6cec183.tar.gz) = 3b89ee0aa88282f17c8daf725a1e7a8c2f2affdcf6ff6f4ca4faf250760d778a65c5693e5df3fcc7554d60dd9b0cb1a0350e266fadb7668320f3c676d8799a29

4
tests/inventory Executable file
View File

@ -0,0 +1,4 @@
#!/bin/bash
export TEST_DOCKER_EXTRA_ARGS="--privileged --network host"
exec merge-standard-inventory "$@"

16
tests/tests.yml Normal file
View File

@ -0,0 +1,16 @@
---
- hosts: localhost
roles:
- role: standard-test-basic
tags:
- classic
- container
tests:
- smoke:
dir: .
run: /usr/share/sbd/regressions.sh
required_packages:
- sbd
- sbd-tests
- device-mapper