MEDIUM: mworker: remove USE_SYSTEMD requirement for -Ws

Since sd_notify() is now implemented in src/systemd.c, there is no need
anymore to build its support conditionnally with USE_SYSTEMD.

This patch add supports for -Ws for every build and removes the
USE_SYSTEMD build option. It also remove every reference to USE_SYSTEMD
in the documentation and the CI.

This also allows to run the reg-tests in -Ws with the new VTest support.
This commit is contained in:
William Lallemand 2024-11-20 12:02:39 +01:00
parent 16147e6cf3
commit 15845247db
10 changed files with 9 additions and 48 deletions

2
.github/matrix.py vendored
View File

@ -127,7 +127,6 @@ def main(ref_name):
"USE_PCRE2_JIT=1", "USE_PCRE2_JIT=1",
"USE_LUA=1", "USE_LUA=1",
"USE_OPENSSL=1", "USE_OPENSSL=1",
"USE_SYSTEMD=1",
"USE_WURFL=1", "USE_WURFL=1",
"WURFL_INC=addons/wurfl/dummy", "WURFL_INC=addons/wurfl/dummy",
"WURFL_LIB=addons/wurfl/dummy", "WURFL_LIB=addons/wurfl/dummy",
@ -161,7 +160,6 @@ def main(ref_name):
"USE_PCRE2_JIT=1", "USE_PCRE2_JIT=1",
"USE_LUA=1", "USE_LUA=1",
"USE_OPENSSL=1", "USE_OPENSSL=1",
"USE_SYSTEMD=1",
"USE_WURFL=1", "USE_WURFL=1",
"WURFL_INC=addons/wurfl/dummy", "WURFL_INC=addons/wurfl/dummy",
"WURFL_LIB=addons/wurfl/dummy", "WURFL_LIB=addons/wurfl/dummy",

View File

@ -38,7 +38,7 @@ jobs:
- name: Build with Coverity build tool - name: Build with Coverity build tool
run: | run: |
export PATH=`pwd`/coverity_tool/bin:$PATH export PATH=`pwd`/coverity_tool/bin:$PATH
cov-build --dir cov-int make CC=clang TARGET=linux-glibc USE_ZLIB=1 USE_PCRE2=1 USE_PCRE2_JIT=1 USE_LUA=1 USE_OPENSSL=1 USE_QUIC=1 USE_SYSTEMD=1 USE_WURFL=1 WURFL_INC=addons/wurfl/dummy WURFL_LIB=addons/wurfl/dummy USE_DEVICEATLAS=1 DEVICEATLAS_SRC=addons/deviceatlas/dummy USE_51DEGREES=1 51DEGREES_SRC=addons/51degrees/dummy/pattern ADDLIB=\"-Wl,-rpath,$HOME/opt/lib/\" SSL_LIB=${HOME}/opt/lib SSL_INC=${HOME}/opt/include DEBUG+=-DDEBUG_STRICT=1 DEBUG+=-DDEBUG_USE_ABORT=1 cov-build --dir cov-int make CC=clang TARGET=linux-glibc USE_ZLIB=1 USE_PCRE2=1 USE_PCRE2_JIT=1 USE_LUA=1 USE_OPENSSL=1 USE_QUIC=1 USE_WURFL=1 WURFL_INC=addons/wurfl/dummy WURFL_LIB=addons/wurfl/dummy USE_DEVICEATLAS=1 DEVICEATLAS_SRC=addons/deviceatlas/dummy USE_51DEGREES=1 51DEGREES_SRC=addons/51degrees/dummy/pattern ADDLIB=\"-Wl,-rpath,$HOME/opt/lib/\" SSL_LIB=${HOME}/opt/lib SSL_INC=${HOME}/opt/include DEBUG+=-DDEBUG_STRICT=1 DEBUG+=-DDEBUG_USE_ABORT=1
- name: Submit build result to Coverity Scan - name: Submit build result to Coverity Scan
run: | run: |
tar czvf cov.tar.gz cov-int tar czvf cov.tar.gz cov-int

View File

@ -40,7 +40,7 @@ jobs:
make dev/hpack/decode dev/hpack/gen-enc dev/hpack/gen-rht make dev/hpack/decode dev/hpack/gen-enc dev/hpack/gen-rht
- name: Compile HAProxy with ${{ matrix.platform.cc }} - name: Compile HAProxy with ${{ matrix.platform.cc }}
run: | run: |
make -j3 CC=${{ matrix.platform.cc }} V=1 ERR=1 TARGET=linux-glibc USE_OPENSSL=1 USE_QUIC=1 USE_ZLIB=1 USE_PCRE=1 USE_PCRE_JIT=1 USE_LUA=1 USE_SYSTEMD=1 ADDLIB="${{ matrix.platform.ADDLIB_ATOMIC }} -Wl,-rpath,${HOME}/opt/lib" SSL_LIB=${HOME}/opt/lib SSL_INC=${HOME}/opt/include ARCH_FLAGS="${{ matrix.platform.ARCH_FLAGS }}" make -j3 CC=${{ matrix.platform.cc }} V=1 ERR=1 TARGET=linux-glibc USE_OPENSSL=1 USE_QUIC=1 USE_ZLIB=1 USE_PCRE=1 USE_PCRE_JIT=1 USE_LUA=1 ADDLIB="${{ matrix.platform.ADDLIB_ATOMIC }} -Wl,-rpath,${HOME}/opt/lib" SSL_LIB=${HOME}/opt/lib SSL_INC=${HOME}/opt/include ARCH_FLAGS="${{ matrix.platform.ARCH_FLAGS }}"
make install make install
- name: Show HAProxy version - name: Show HAProxy version
id: show-version id: show-version

View File

@ -8,7 +8,7 @@ branches:
env: env:
global: global:
- FLAGS="USE_LUA=1 USE_OPENSSL=1 USE_PCRE=1 USE_PCRE_JIT=1 USE_SYSTEMD=1 USE_ZLIB=1" - FLAGS="USE_LUA=1 USE_OPENSSL=1 USE_PCRE=1 USE_PCRE_JIT=1 USE_ZLIB=1"
- TMPDIR=/tmp - TMPDIR=/tmp
addons: addons:

View File

@ -465,12 +465,6 @@ are the extra libraries that may be referenced at build time :
on Linux. It is automatically detected and may be disabled on Linux. It is automatically detected and may be disabled
using "USE_DL=", though it should never harm. using "USE_DL=", though it should never harm.
- USE_SYSTEMD=1 enables support for the sdnotify features of systemd,
allowing better integration with systemd on Linux systems
which come with it. It is never enabled by default so there
is no need to disable it.
4.10) Common errors 4.10) Common errors
------------------- -------------------
Some build errors may happen depending on the options combinations or the Some build errors may happen depending on the options combinations or the

View File

@ -56,7 +56,6 @@
# USE_DEVICEATLAS : enable DeviceAtlas api. # USE_DEVICEATLAS : enable DeviceAtlas api.
# USE_51DEGREES : enable third party device detection library from 51Degrees # USE_51DEGREES : enable third party device detection library from 51Degrees
# USE_WURFL : enable WURFL detection library from Scientiamobile # USE_WURFL : enable WURFL detection library from Scientiamobile
# USE_SYSTEMD : enable sd_notify() support.
# USE_OBSOLETE_LINKER : use when the linker fails to emit __start_init/__stop_init # USE_OBSOLETE_LINKER : use when the linker fails to emit __start_init/__stop_init
# USE_THREAD_DUMP : use the more advanced thread state dump system. Automatic. # USE_THREAD_DUMP : use the more advanced thread state dump system. Automatic.
# USE_OT : enable the OpenTracing filter # USE_OT : enable the OpenTracing filter
@ -340,7 +339,7 @@ use_opts = USE_EPOLL USE_KQUEUE USE_NETFILTER USE_POLL \
USE_SSL USE_LUA USE_ACCEPT4 USE_CLOSEFROM USE_ZLIB USE_SLZ \ USE_SSL USE_LUA USE_ACCEPT4 USE_CLOSEFROM USE_ZLIB USE_SLZ \
USE_CPU_AFFINITY USE_TFO USE_NS USE_DL USE_RT USE_LIBATOMIC \ USE_CPU_AFFINITY USE_TFO USE_NS USE_DL USE_RT USE_LIBATOMIC \
USE_MATH USE_DEVICEATLAS USE_51DEGREES \ USE_MATH USE_DEVICEATLAS USE_51DEGREES \
USE_WURFL USE_SYSTEMD USE_OBSOLETE_LINKER USE_PRCTL USE_PROCCTL \ USE_WURFL USE_OBSOLETE_LINKER USE_PRCTL USE_PROCCTL \
USE_THREAD_DUMP USE_EVPORTS USE_OT USE_QUIC USE_PROMEX \ USE_THREAD_DUMP USE_EVPORTS USE_OT USE_QUIC USE_PROMEX \
USE_MEMORY_PROFILING USE_SHM_OPEN \ USE_MEMORY_PROFILING USE_SHM_OPEN \
USE_STATIC_PCRE USE_STATIC_PCRE2 \ USE_STATIC_PCRE USE_STATIC_PCRE2 \
@ -381,7 +380,7 @@ ifeq ($(TARGET),linux-glibc)
USE_POLL USE_TPROXY USE_LIBCRYPT USE_DL USE_RT USE_CRYPT_H USE_NETFILTER \ USE_POLL USE_TPROXY USE_LIBCRYPT USE_DL USE_RT USE_CRYPT_H USE_NETFILTER \
USE_CPU_AFFINITY USE_THREAD USE_EPOLL USE_LINUX_TPROXY USE_LINUX_CAP \ USE_CPU_AFFINITY USE_THREAD USE_EPOLL USE_LINUX_TPROXY USE_LINUX_CAP \
USE_ACCEPT4 USE_LINUX_SPLICE USE_PRCTL USE_THREAD_DUMP USE_NS USE_TFO \ USE_ACCEPT4 USE_LINUX_SPLICE USE_PRCTL USE_THREAD_DUMP USE_NS USE_TFO \
USE_GETADDRINFO USE_BACKTRACE USE_SHM_OPEN USE_SYSTEMD) USE_GETADDRINFO USE_BACKTRACE USE_SHM_OPEN)
INSTALL = install -v INSTALL = install -v
endif endif
@ -765,10 +764,6 @@ ifneq ($(USE_WURFL:0=),)
WURFL_LDFLAGS = $(if $(WURFL_LIB),-L$(WURFL_LIB)) -lwurfl WURFL_LDFLAGS = $(if $(WURFL_LIB),-L$(WURFL_LIB)) -lwurfl
endif endif
ifneq ($(USE_SYSTEMD:0=),)
OPTIONS_OBJS += src/systemd.o
endif
ifneq ($(USE_PCRE:0=)$(USE_STATIC_PCRE:0=)$(USE_PCRE_JIT:0=),) ifneq ($(USE_PCRE:0=)$(USE_STATIC_PCRE:0=)$(USE_PCRE_JIT:0=),)
ifneq ($(USE_PCRE2:0=)$(USE_STATIC_PCRE2:0=)$(USE_PCRE2_JIT:0=),) ifneq ($(USE_PCRE2:0=)$(USE_STATIC_PCRE2:0=)$(USE_PCRE2_JIT:0=),)
$(error cannot compile both PCRE and PCRE2 support) $(error cannot compile both PCRE and PCRE2 support)
@ -988,7 +983,7 @@ OBJS += src/mux_h2.o src/mux_h1.o src/mux_fcgi.o src/stream.o \
src/cebub_tree.o src/cebuib_tree.o src/cebuis_tree.o \ src/cebub_tree.o src/cebuib_tree.o src/cebuis_tree.o \
src/cebul_tree.o src/cebus_tree.o \ src/cebul_tree.o src/cebus_tree.o \
src/ebtree.o src/dgram.o src/hash.o src/version.o \ src/ebtree.o src/dgram.o src/hash.o src/version.o \
src/limits.o src/mux_spop.o src/limits.o src/mux_spop.o src/systemd.o
ifneq ($(TRACE),) ifneq ($(TRACE),)
OBJS += src/calltrace.o OBJS += src/calltrace.o

View File

@ -191,8 +191,6 @@ list of options is :
recommended to use this mode with multiprocess and systemd. recommended to use this mode with multiprocess and systemd.
-Ws : master-worker mode with support of `notify` type of systemd service. -Ws : master-worker mode with support of `notify` type of systemd service.
This option is only available when HAProxy was built with `USE_SYSTEMD`
build option enabled.
-c : only performs a check of the configuration files and exits before trying -c : only performs a check of the configuration files and exits before trying
to bind. The exit status is zero if everything is OK, or non-zero if an to bind. The exit status is zero if everything is OK, or non-zero if an

View File

@ -26,10 +26,6 @@
#include <net/if.h> #include <net/if.h>
#if defined(USE_SYSTEMD)
#include <haproxy/systemd.h>
#endif
#include <haproxy/api.h> #include <haproxy/api.h>
#include <haproxy/applet.h> #include <haproxy/applet.h>
#include <haproxy/base64.h> #include <haproxy/base64.h>
@ -63,6 +59,7 @@
#include <haproxy/stats-t.h> #include <haproxy/stats-t.h>
#include <haproxy/stconn.h> #include <haproxy/stconn.h>
#include <haproxy/stream.h> #include <haproxy/stream.h>
#include <haproxy/systemd.h>
#include <haproxy/task.h> #include <haproxy/task.h>
#include <haproxy/ticks.h> #include <haproxy/ticks.h>
#include <haproxy/time.h> #include <haproxy/time.h>
@ -2532,10 +2529,8 @@ static int _send_status(char **args, char *payload, struct appctx *appctx, void
load_status = 1; load_status = 1;
ha_notice("Loading success.\n"); ha_notice("Loading success.\n");
#if defined(USE_SYSTEMD)
if (global.tune.options & GTUNE_USE_SYSTEMD) if (global.tune.options & GTUNE_USE_SYSTEMD)
sd_notifyf(0, "READY=1\nMAINPID=%lu\nSTATUS=Ready.\n", (unsigned long)getpid()); sd_notifyf(0, "READY=1\nMAINPID=%lu\nSTATUS=Ready.\n", (unsigned long)getpid());
#endif
return 1; return 1;
} }

View File

@ -59,9 +59,6 @@
#ifdef DEBUG_FULL #ifdef DEBUG_FULL
#include <assert.h> #include <assert.h>
#endif #endif
#if defined(USE_SYSTEMD)
#include <haproxy/systemd.h>
#endif
#include <import/sha1.h> #include <import/sha1.h>
@ -123,6 +120,7 @@
#include <haproxy/stats-file.h> #include <haproxy/stats-file.h>
#include <haproxy/stats-t.h> #include <haproxy/stats-t.h>
#include <haproxy/stream.h> #include <haproxy/stream.h>
#include <haproxy/systemd.h>
#include <haproxy/task.h> #include <haproxy/task.h>
#include <haproxy/thread.h> #include <haproxy/thread.h>
#include <haproxy/time.h> #include <haproxy/time.h>
@ -619,9 +617,7 @@ static void usage(char *name)
" -V enters verbose mode (disables quiet mode)\n" " -V enters verbose mode (disables quiet mode)\n"
" -D goes daemon ; -C changes to <dir> before loading files.\n" " -D goes daemon ; -C changes to <dir> before loading files.\n"
" -W master-worker mode.\n" " -W master-worker mode.\n"
#if defined(USE_SYSTEMD)
" -Ws master-worker mode with systemd notify support.\n" " -Ws master-worker mode with systemd notify support.\n"
#endif
" -q quiet mode : don't display messages\n" " -q quiet mode : don't display messages\n"
" -c check mode : only check config files and exit\n" " -c check mode : only check config files and exit\n"
" -cc check condition : evaluate a condition and exit\n" " -cc check condition : evaluate a condition and exit\n"
@ -868,7 +864,6 @@ void mworker_reload(int hardreload)
child->reloads++; child->reloads++;
} }
#if defined(USE_SYSTEMD)
if (global.tune.options & GTUNE_USE_SYSTEMD) { if (global.tune.options & GTUNE_USE_SYSTEMD) {
struct timespec ts; struct timespec ts;
@ -880,7 +875,6 @@ void mworker_reload(int hardreload)
"MONOTONIC_USEC=%" PRIu64 "\n", "MONOTONIC_USEC=%" PRIu64 "\n",
(ts.tv_sec * 1000000ULL + ts.tv_nsec / 1000ULL)); (ts.tv_sec * 1000000ULL + ts.tv_nsec / 1000ULL));
} }
#endif
mworker_reexec(hardreload); mworker_reexec(hardreload);
} }
@ -938,12 +932,10 @@ void on_new_child_failure()
usermsgs_clr(NULL); usermsgs_clr(NULL);
load_status = 0; load_status = 0;
ha_warning("Failed to load worker!\n"); ha_warning("Failed to load worker!\n");
#if defined(USE_SYSTEMD)
/* the sd_notify API is not able to send a reload failure signal. So /* the sd_notify API is not able to send a reload failure signal. So
* the READY=1 signal still need to be sent */ * the READY=1 signal still need to be sent */
if (global.tune.options & GTUNE_USE_SYSTEMD) if (global.tune.options & GTUNE_USE_SYSTEMD)
sd_notify(0, "READY=1\nSTATUS=Reload failed!\n"); sd_notify(0, "READY=1\nSTATUS=Reload failed!\n");
#endif
} }
/* /*
@ -1783,12 +1775,7 @@ static void init_args(int argc, char **argv)
arg_mode |= MODE_DAEMON; arg_mode |= MODE_DAEMON;
else if (*flag == 'W' && flag[1] == 's') { else if (*flag == 'W' && flag[1] == 's') {
arg_mode |= MODE_MWORKER | MODE_FOREGROUND; arg_mode |= MODE_MWORKER | MODE_FOREGROUND;
#if defined(USE_SYSTEMD)
global.tune.options |= GTUNE_USE_SYSTEMD; global.tune.options |= GTUNE_USE_SYSTEMD;
#else
ha_alert("master-worker mode with systemd support (-Ws) requested, but not compiled. Use master-worker mode (-W) if you are not using Type=notify in your unit file or recompile with USE_SYSTEMD=1.\n\n");
usage(progname);
#endif
} }
else if (*flag == 'W') else if (*flag == 'W')
arg_mode |= MODE_MWORKER; arg_mode |= MODE_MWORKER;
@ -3063,12 +3050,10 @@ static void run_master_in_recovery_mode(int argc, char **argv)
list_for_each_entry(proc, &proc_list, list) { list_for_each_entry(proc, &proc_list, list) {
proc->failedreloads++; proc->failedreloads++;
} }
#if defined(USE_SYSTEMD)
/* the sd_notify API is not able to send a reload failure signal. So /* the sd_notify API is not able to send a reload failure signal. So
* the READY=1 signal still need to be sent */ * the READY=1 signal still need to be sent */
if (global.tune.options & GTUNE_USE_SYSTEMD) if (global.tune.options & GTUNE_USE_SYSTEMD)
sd_notify(0, "READY=1\nSTATUS=Reload failed (master failed to load or to parse new configuration)!\n"); sd_notify(0, "READY=1\nSTATUS=Reload failed (master failed to load or to parse new configuration)!\n");
#endif
global.nbtgroups = 1; global.nbtgroups = 1;
global.nbthread = 1; global.nbthread = 1;

View File

@ -38,12 +38,10 @@
#include <haproxy/signal.h> #include <haproxy/signal.h>
#include <haproxy/stconn.h> #include <haproxy/stconn.h>
#include <haproxy/stream.h> #include <haproxy/stream.h>
#include <haproxy/systemd.h>
#include <haproxy/tools.h> #include <haproxy/tools.h>
#include <haproxy/version.h> #include <haproxy/version.h>
#if defined(USE_SYSTEMD)
#include <haproxy/systemd.h>
#endif
static int exitcode = -1; static int exitcode = -1;
int max_reloads = INT_MAX; /* max number of reloads a worker can have until they are killed */ int max_reloads = INT_MAX; /* max number of reloads a worker can have until they are killed */
@ -308,11 +306,9 @@ void mworker_catch_sigterm(struct sig_handler *sh)
{ {
int sig = sh->arg; int sig = sh->arg;
#if defined(USE_SYSTEMD)
if (global.tune.options & GTUNE_USE_SYSTEMD) { if (global.tune.options & GTUNE_USE_SYSTEMD) {
sd_notify(0, "STOPPING=1"); sd_notify(0, "STOPPING=1");
} }
#endif
ha_warning("Exiting Master process...\n"); ha_warning("Exiting Master process...\n");
mworker_kill(sig); mworker_kill(sig);
} }