[arch-commits] Commit in keepalived/repos (3 files)

Christian Hesse eworm at gemini.archlinux.org
Wed Dec 22 08:17:55 UTC 2021


    Date: Wednesday, December 22, 2021 @ 08:17:55
  Author: eworm
Revision: 1082762

archrelease: copy trunk to community-testing-x86_64

Added:
  keepalived/repos/community-testing-x86_64/
  keepalived/repos/community-testing-x86_64/0001-init-Make-parent-process-exit-with-meaningful-status.patch
    (from rev 1082761, keepalived/trunk/0001-init-Make-parent-process-exit-with-meaningful-status.patch)
  keepalived/repos/community-testing-x86_64/PKGBUILD
    (from rev 1082761, keepalived/trunk/PKGBUILD)

-----------------------------------------------------------------+
 0001-init-Make-parent-process-exit-with-meaningful-status.patch |  270 ++++++++++
 PKGBUILD                                                        |   54 ++
 2 files changed, 324 insertions(+)

Copied: keepalived/repos/community-testing-x86_64/0001-init-Make-parent-process-exit-with-meaningful-status.patch (from rev 1082761, keepalived/trunk/0001-init-Make-parent-process-exit-with-meaningful-status.patch)
===================================================================
--- community-testing-x86_64/0001-init-Make-parent-process-exit-with-meaningful-status.patch	                        (rev 0)
+++ community-testing-x86_64/0001-init-Make-parent-process-exit-with-meaningful-status.patch	2021-12-22 08:17:55 UTC (rev 1082762)
@@ -0,0 +1,270 @@
+From 3b13dccf2bf66f49e2ff5784d3aa359e56871a42 Mon Sep 17 00:00:00 2001
+From: Quentin Armitage <quentin at armitage.org.uk>
+Date: Wed, 22 Dec 2021 07:27:24 +0000
+Subject: [PATCH 1/1] init: Make parent process exit with meaningful status on
+ error
+
+Signed-off-by: Quentin Armitage <quentin at armitage.org.uk>
+
+(cherry picked from commit 367473dd4e54dfea9ca4c0c4aa10260173826f4e)
+---
+ keepalived/bfd/bfd_daemon.c     |  5 +++--
+ keepalived/check/check_daemon.c |  5 +++--
+ keepalived/core/main.c          |  2 +-
+ keepalived/vrrp/vrrp_daemon.c   |  5 +++--
+ lib/scheduler.c                 | 33 ++++++++++++++++++++++-----------
+ lib/scheduler.h                 | 24 +++++++++++++-----------
+ 6 files changed, 45 insertions(+), 29 deletions(-)
+
+diff --git a/keepalived/bfd/bfd_daemon.c b/keepalived/bfd/bfd_daemon.c
+index d49dff55..11bcb5d9 100644
+--- a/keepalived/bfd/bfd_daemon.c
++++ b/keepalived/bfd/bfd_daemon.c
+@@ -313,12 +313,13 @@ static void
+ bfd_respawn_thread(thread_ref_t thread)
+ {
+ 	unsigned restart_delay;
++	int ret;
+ 
+ 	/* We catch a SIGCHLD, handle it */
+ 	bfd_child = 0;
+ 
+-	if (report_child_status(thread->u.c.status, thread->u.c.pid, NULL))
+-		thread_add_terminate_event(thread->master);
++	if ((ret = report_child_status(thread->u.c.status, thread->u.c.pid, NULL)))
++		thread_add_parent_terminate_event(thread->master, ret);
+ 	else if (!__test_bit(DONT_RESPAWN_BIT, &debug)) {
+ 		log_child_died("BFD", thread->u.c.pid);
+ 
+diff --git a/keepalived/check/check_daemon.c b/keepalived/check/check_daemon.c
+index 13385cad..3d8c09fc 100644
+--- a/keepalived/check/check_daemon.c
++++ b/keepalived/check/check_daemon.c
+@@ -591,12 +591,13 @@ static void
+ check_respawn_thread(thread_ref_t thread)
+ {
+ 	unsigned restart_delay;
++	int ret;
+ 
+ 	/* We catch a SIGCHLD, handle it */
+ 	checkers_child = 0;
+ 
+-	if (report_child_status(thread->u.c.status, thread->u.c.pid, NULL))
+-		thread_add_terminate_event(thread->master);
++	if ((ret = report_child_status(thread->u.c.status, thread->u.c.pid, NULL)))
++		thread_add_parent_terminate_event(thread->master, ret);
+ 	else if (!__test_bit(DONT_RESPAWN_BIT, &debug)) {
+ 		log_child_died("Healthcheck", thread->u.c.pid);
+ 
+diff --git a/keepalived/core/main.c b/keepalived/core/main.c
+index 9fc0426d..92ef0bfb 100644
+--- a/keepalived/core/main.c
++++ b/keepalived/core/main.c
+@@ -2717,7 +2717,7 @@ keepalived_main(int argc, char **argv)
+ #endif
+ 
+ 	/* Launch the scheduling I/O multiplexer */
+-	launch_thread_scheduler(master);
++	exit_code = launch_thread_scheduler(master);
+ 
+ 	/* Finish daemon process */
+ 	stop_keepalived();
+diff --git a/keepalived/vrrp/vrrp_daemon.c b/keepalived/vrrp/vrrp_daemon.c
+index db191344..315a8db9 100644
+--- a/keepalived/vrrp/vrrp_daemon.c
++++ b/keepalived/vrrp/vrrp_daemon.c
+@@ -909,12 +909,13 @@ static void
+ vrrp_respawn_thread(thread_ref_t thread)
+ {
+ 	unsigned restart_delay;
++	int ret;
+ 
+ 	/* We catch a SIGCHLD, handle it */
+ 	vrrp_child = 0;
+ 
+-	if (report_child_status(thread->u.c.status, thread->u.c.pid, NULL))
+-		thread_add_terminate_event(thread->master);
++	if ((ret = report_child_status(thread->u.c.status, thread->u.c.pid, NULL)))
++		thread_add_parent_terminate_event(thread->master, ret);
+ 	else if (!__test_bit(DONT_RESPAWN_BIT, &debug)) {
+ 		log_child_died("VRRP", thread->u.c.pid);
+ 
+diff --git a/lib/scheduler.c b/lib/scheduler.c
+index 9e7a710c..3e199cc0 100644
+--- a/lib/scheduler.c
++++ b/lib/scheduler.c
+@@ -509,7 +509,7 @@ log_child_died(const char *process, pid_t pid)
+ }
+ 
+ /* report_child_status returns true if the exit is a hard error, so unable to continue */
+-bool
++int
+ report_child_status(int status, pid_t pid, char const *prog_name)
+ {
+ 	char const *prog_id = NULL;
+@@ -533,7 +533,7 @@ report_child_status(int status, pid_t pid, char const *prog_name)
+ 		if (exit_status == KEEPALIVED_EXIT_FATAL ||
+ 		    exit_status == KEEPALIVED_EXIT_CONFIG) {
+ 			log_message(LOG_INFO, "%s exited with permanent error %s. Terminating", prog_id, exit_status == KEEPALIVED_EXIT_CONFIG ? "CONFIG" : "FATAL" );
+-			return true;
++			return exit_status;
+ 		}
+ 
+ 		if (exit_status != EXIT_SUCCESS)
+@@ -576,7 +576,7 @@ report_child_status(int status, pid_t pid, char const *prog_name)
+ 					WTERMSIG(status) == SIGKILL ? " - has rlimit_rttime been exceeded?" : "");
+ 	}
+ 
+-	return false;
++	return 0;
+ }
+ #endif
+ 
+@@ -1418,7 +1418,7 @@ thread_add_event(thread_master_t * m, thread_func_t func, void *arg, int val)
+ 
+ /* Add terminate event thread. */
+ static thread_ref_t
+-thread_add_generic_terminate_event(thread_master_t * m, thread_type_t type, thread_func_t func)
++thread_add_generic_terminate_event(thread_master_t * m, thread_type_t type, thread_func_t func, int status)
+ {
+ 	thread_t *thread;
+ 
+@@ -1429,7 +1429,7 @@ thread_add_generic_terminate_event(thread_master_t * m, thread_type_t type, thre
+ 	thread->master = m;
+ 	thread->func = func;
+ 	thread->arg = NULL;
+-	thread->u.val = 0;
++	thread->u.val = status;
+ 	INIT_LIST_HEAD(&thread->e_list);
+ 	list_add_tail(&thread->e_list, &m->event);
+ 
+@@ -1439,13 +1439,19 @@ thread_add_generic_terminate_event(thread_master_t * m, thread_type_t type, thre
+ thread_ref_t
+ thread_add_terminate_event(thread_master_t *m)
+ {
+-	return thread_add_generic_terminate_event(m, THREAD_TERMINATE, NULL);
++	return thread_add_generic_terminate_event(m, THREAD_TERMINATE, NULL, 0);
++}
++
++thread_ref_t
++thread_add_parent_terminate_event(thread_master_t *m, int status)
++{
++	return thread_add_generic_terminate_event(m, THREAD_TERMINATE, NULL, status);
+ }
+ 
+ thread_ref_t
+ thread_add_start_terminate_event(thread_master_t *m, thread_func_t func)
+ {
+-	return thread_add_generic_terminate_event(m, THREAD_TERMINATE_START, func);
++	return thread_add_generic_terminate_event(m, THREAD_TERMINATE_START, func, 0);
+ }
+ 
+ #ifdef USE_SIGNAL_THREADS
+@@ -1965,12 +1971,13 @@ thread_call(thread_t * thread)
+ 	(*thread->func) (thread);
+ }
+ 
+-void
++int
+ process_threads(thread_master_t *m)
+ {
+ 	thread_t* thread;
+ 	list_head_t *thread_list;
+ 	int thread_type;
++	int exit_code = 0;
+ 
+ 	/*
+ 	 * Processing the master thread queues,
+@@ -2025,6 +2032,8 @@ process_threads(thread_master_t *m)
+ 		    thread->type == THREAD_CHILD_TERMINATED ||
+ 		    thread->type == THREAD_TIMER_SHUTDOWN ||
+ 		    thread->type == THREAD_TERMINATE) {
++			exit_code = thread->u.val;
++
+ 			if (thread->func)
+ 				thread_call(thread);
+ 
+@@ -2060,8 +2069,10 @@ process_threads(thread_master_t *m)
+ 
+ 		/* If daemon hanging event is received stop processing */
+ 		if (thread_type == THREAD_TERMINATE)
+-			break;
++			return exit_code;
+ 	}
++
++	return 0;
+ }
+ 
+ static void
+@@ -2137,13 +2148,13 @@ thread_add_base_threads(thread_master_t *m,
+ }
+ 
+ /* Our infinite scheduling loop */
+-void
++int
+ launch_thread_scheduler(thread_master_t *m)
+ {
+ // TODO - do this somewhere better
+ 	signal_set(SIGCHLD, thread_child_handler, m);
+ 
+-	process_threads(m);
++	return process_threads(m);
+ }
+ 
+ #ifdef THREAD_DUMP
+diff --git a/lib/scheduler.h b/lib/scheduler.h
+index 782f06ee..9e2cf7f0 100644
+--- a/lib/scheduler.h
++++ b/lib/scheduler.h
+@@ -200,16 +200,17 @@ typedef enum {
+ #define THREAD_CHILD_PID(X) ((X)->u.c.pid)
+ #define THREAD_CHILD_STATUS(X) ((X)->u.c.status)
+ 
+-/* Exit codes */
++/* Exit codes. The values comply with the LSB so far as possible,
++ * and are also documented in the systemd.exec(5) man page. */
+ enum exit_code {
+ 	KEEPALIVED_EXIT_OK = EXIT_SUCCESS,
+-	KEEPALIVED_EXIT_NO_MEMORY = EXIT_FAILURE,
+-	KEEPALIVED_EXIT_PROGRAM_ERROR,
+-	KEEPALIVED_EXIT_FATAL,
+-	KEEPALIVED_EXIT_CONFIG,
+-	KEEPALIVED_EXIT_CONFIG_TEST,
+-	KEEPALIVED_EXIT_CONFIG_TEST_SECURITY,
+-	KEEPALIVED_EXIT_NO_CONFIG,
++	KEEPALIVED_EXIT_NO_MEMORY = 204,	// EXIT_MEMORY
++	KEEPALIVED_EXIT_PROGRAM_ERROR = 70,	// EX_SOFTWARE
++	KEEPALIVED_EXIT_FATAL = 1,		// EXIT_FAILURE
++	KEEPALIVED_EXIT_CONFIG = 2,		// EXIT_INVALIDARGUMENT
++	KEEPALIVED_EXIT_CONFIG_TEST = 150,
++	KEEPALIVED_EXIT_CONFIG_TEST_SECURITY = 151,
++	KEEPALIVED_EXIT_NO_CONFIG = 6,		// EXIT_NOTCONFIGURED
+ } ;
+ 
+ #define DEFAULT_CHILD_FINDER ((void *)1)
+@@ -240,10 +241,11 @@ extern void log_command_line(unsigned);
+ #ifndef _ONE_PROCESS_DEBUG_
+ extern unsigned calc_restart_delay(const timeval_t *, unsigned *, const char *);
+ extern void log_child_died(const char *, pid_t);
+-extern bool report_child_status(int, pid_t, const char *);
++extern int report_child_status(int, pid_t, const char *);
+ #endif
+ extern thread_master_t *thread_make_master(void);
+ extern thread_ref_t thread_add_terminate_event(thread_master_t *);
++extern thread_ref_t thread_add_parent_terminate_event(thread_master_t *, int);
+ extern thread_ref_t thread_add_start_terminate_event(thread_master_t *, thread_func_t);
+ #ifdef THREAD_DUMP
+ extern void dump_thread_data(const thread_master_t *, FILE *);
+@@ -272,10 +274,10 @@ extern void snmp_timeout_thread(thread_ref_t);
+ extern void snmp_epoll_info(thread_master_t *);
+ extern void snmp_epoll_clear(thread_master_t *);
+ #endif
+-extern void process_threads(thread_master_t *);
++extern int process_threads(thread_master_t *);
+ extern void thread_child_handler(void *, int);
+ extern void thread_add_base_threads(thread_master_t *, bool);
+-extern void launch_thread_scheduler(thread_master_t *);
++extern int launch_thread_scheduler(thread_master_t *);
+ #ifndef _ONE_PROCESS_DEBUG_
+ extern void register_shutdown_function(void (*)(int));
+ #endif

Copied: keepalived/repos/community-testing-x86_64/PKGBUILD (from rev 1082761, keepalived/trunk/PKGBUILD)
===================================================================
--- community-testing-x86_64/PKGBUILD	                        (rev 0)
+++ community-testing-x86_64/PKGBUILD	2021-12-22 08:17:55 UTC (rev 1082762)
@@ -0,0 +1,54 @@
+# Maintainer: Sébastien Luttringer
+# Contributor: Andrea Zucchelli <zukka77 at gmail.com>
+
+pkgname=keepalived
+pkgver=2.2.4
+pkgrel=2
+pkgdesc='Failover and monitoring daemon for LVS clusters'
+arch=('x86_64')
+url='https://www.keepalived.org/'
+license=('GPL2')
+backup=('etc/keepalived/keepalived.conf' 'etc/sysconfig/keepalived')
+makedepends=('ipset')
+depends=('glibc' 'libnl' 'openssl' 'file' 'iptables' 'systemd-libs')
+optdepends=('ipset: ipset support')
+makedepends=('libnfnetlink' 'ipset' 'systemd')
+options=('!emptydirs')
+source=("https://www.keepalived.org/software/$pkgname-$pkgver.tar.gz"
+        '0001-init-Make-parent-process-exit-with-meaningful-status.patch')
+sha256sums=('0138d69087d44beaaa589527f0cfa6885958b320a837147d02b6b7df73ebc1df'
+            '573dd42f157293eac74ed214fca7bc0b8725d1f5ae7fd759a7e91a79d1afb81d')
+
+prepare() {
+  cd "${pkgname}-${pkgver}"
+
+  patch -Np1 < ../0001-init-Make-parent-process-exit-with-meaningful-status.patch
+}
+
+build() {
+  # trick broken ./configure systemctl test
+  printf "#!/bin/sh\necho -.mount\n" > systemctl
+  chmod +x systemctl
+  PATH=$PWD:$PATH
+
+  cd "${pkgname}-${pkgver}"
+
+  ./configure \
+    --prefix=/usr \
+    --sysconfdir=/etc \
+    --sbindir=/usr/bin \
+    --localstatedir=/var \
+    --runstatedir=/run
+  make
+}
+
+package() {
+  cd "${pkgname}-${pkgver}"
+
+  make DESTDIR="$pkgdir" install
+  # move examples to /usr/share
+  install -d -m 755 "$pkgdir/usr/share/$pkgname"
+  mv "$pkgdir/etc/keepalived/samples" "$pkgdir/usr/share/$pkgname/samples"
+}
+
+# vim:set ts=2 sw=2 et:



More information about the arch-commits mailing list