From 15845247db4527f1cc594b48e60e9b99bc4a498f Mon Sep 17 00:00:00 2001 From: William Lallemand Date: Wed, 20 Nov 2024 12:02:39 +0100 Subject: [PATCH] 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. --- .github/matrix.py | 2 -- .github/workflows/coverity.yml | 2 +- .github/workflows/fedora-rawhide.yml | 2 +- .travis.yml | 2 +- INSTALL | 6 ------ Makefile | 11 +++-------- doc/management.txt | 2 -- src/cli.c | 7 +------ src/haproxy.c | 17 +---------------- src/mworker.c | 6 +----- 10 files changed, 9 insertions(+), 48 deletions(-) diff --git a/.github/matrix.py b/.github/matrix.py index f90bbac4e6..c08bbfb171 100755 --- a/.github/matrix.py +++ b/.github/matrix.py @@ -127,7 +127,6 @@ def main(ref_name): "USE_PCRE2_JIT=1", "USE_LUA=1", "USE_OPENSSL=1", - "USE_SYSTEMD=1", "USE_WURFL=1", "WURFL_INC=addons/wurfl/dummy", "WURFL_LIB=addons/wurfl/dummy", @@ -161,7 +160,6 @@ def main(ref_name): "USE_PCRE2_JIT=1", "USE_LUA=1", "USE_OPENSSL=1", - "USE_SYSTEMD=1", "USE_WURFL=1", "WURFL_INC=addons/wurfl/dummy", "WURFL_LIB=addons/wurfl/dummy", diff --git a/.github/workflows/coverity.yml b/.github/workflows/coverity.yml index fa28acfc92..e52e6de040 100644 --- a/.github/workflows/coverity.yml +++ b/.github/workflows/coverity.yml @@ -38,7 +38,7 @@ jobs: - name: Build with Coverity build tool run: | 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 run: | tar czvf cov.tar.gz cov-int diff --git a/.github/workflows/fedora-rawhide.yml b/.github/workflows/fedora-rawhide.yml index 3035219974..f1b1afaab8 100644 --- a/.github/workflows/fedora-rawhide.yml +++ b/.github/workflows/fedora-rawhide.yml @@ -40,7 +40,7 @@ jobs: make dev/hpack/decode dev/hpack/gen-enc dev/hpack/gen-rht - name: Compile HAProxy with ${{ matrix.platform.cc }} 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 - name: Show HAProxy version id: show-version diff --git a/.travis.yml b/.travis.yml index 7f5110e323..e995143a7e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -8,7 +8,7 @@ branches: env: 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 addons: diff --git a/INSTALL b/INSTALL index 46ff3cd529..40c051c331 100644 --- a/INSTALL +++ b/INSTALL @@ -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 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 ------------------- Some build errors may happen depending on the options combinations or the diff --git a/Makefile b/Makefile index 4a8066daa0..e70891ee2d 100644 --- a/Makefile +++ b/Makefile @@ -56,7 +56,6 @@ # USE_DEVICEATLAS : enable DeviceAtlas api. # USE_51DEGREES : enable third party device detection library from 51Degrees # 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_THREAD_DUMP : use the more advanced thread state dump system. Automatic. # 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_CPU_AFFINITY USE_TFO USE_NS USE_DL USE_RT USE_LIBATOMIC \ 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_MEMORY_PROFILING USE_SHM_OPEN \ 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_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_GETADDRINFO USE_BACKTRACE USE_SHM_OPEN USE_SYSTEMD) + USE_GETADDRINFO USE_BACKTRACE USE_SHM_OPEN) INSTALL = install -v endif @@ -765,10 +764,6 @@ ifneq ($(USE_WURFL:0=),) WURFL_LDFLAGS = $(if $(WURFL_LIB),-L$(WURFL_LIB)) -lwurfl 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_PCRE2:0=)$(USE_STATIC_PCRE2:0=)$(USE_PCRE2_JIT:0=),) $(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/cebul_tree.o src/cebus_tree.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),) OBJS += src/calltrace.o diff --git a/doc/management.txt b/doc/management.txt index a62116ac41..a27f2454a5 100644 --- a/doc/management.txt +++ b/doc/management.txt @@ -191,8 +191,6 @@ list of options is : recommended to use this mode with multiprocess and systemd. -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 to bind. The exit status is zero if everything is OK, or non-zero if an diff --git a/src/cli.c b/src/cli.c index 48e58bb586..a64ce8aa2f 100644 --- a/src/cli.c +++ b/src/cli.c @@ -26,10 +26,6 @@ #include -#if defined(USE_SYSTEMD) -#include -#endif - #include #include #include @@ -63,6 +59,7 @@ #include #include #include +#include #include #include #include @@ -2532,10 +2529,8 @@ static int _send_status(char **args, char *payload, struct appctx *appctx, void load_status = 1; ha_notice("Loading success.\n"); -#if defined(USE_SYSTEMD) if (global.tune.options & GTUNE_USE_SYSTEMD) sd_notifyf(0, "READY=1\nMAINPID=%lu\nSTATUS=Ready.\n", (unsigned long)getpid()); -#endif return 1; } diff --git a/src/haproxy.c b/src/haproxy.c index f32d488d09..6f371cf2b7 100644 --- a/src/haproxy.c +++ b/src/haproxy.c @@ -59,9 +59,6 @@ #ifdef DEBUG_FULL #include #endif -#if defined(USE_SYSTEMD) -#include -#endif #include @@ -123,6 +120,7 @@ #include #include #include +#include #include #include #include @@ -619,9 +617,7 @@ static void usage(char *name) " -V enters verbose mode (disables quiet mode)\n" " -D goes daemon ; -C changes to before loading files.\n" " -W master-worker mode.\n" -#if defined(USE_SYSTEMD) " -Ws master-worker mode with systemd notify support.\n" -#endif " -q quiet mode : don't display messages\n" " -c check mode : only check config files and exit\n" " -cc check condition : evaluate a condition and exit\n" @@ -868,7 +864,6 @@ void mworker_reload(int hardreload) child->reloads++; } -#if defined(USE_SYSTEMD) if (global.tune.options & GTUNE_USE_SYSTEMD) { struct timespec ts; @@ -880,7 +875,6 @@ void mworker_reload(int hardreload) "MONOTONIC_USEC=%" PRIu64 "\n", (ts.tv_sec * 1000000ULL + ts.tv_nsec / 1000ULL)); } -#endif mworker_reexec(hardreload); } @@ -938,12 +932,10 @@ void on_new_child_failure() usermsgs_clr(NULL); load_status = 0; 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 READY=1 signal still need to be sent */ if (global.tune.options & GTUNE_USE_SYSTEMD) 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; else if (*flag == 'W' && flag[1] == 's') { arg_mode |= MODE_MWORKER | MODE_FOREGROUND; -#if defined(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') 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) { proc->failedreloads++; } -#if defined(USE_SYSTEMD) /* the sd_notify API is not able to send a reload failure signal. So * the READY=1 signal still need to be sent */ 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"); -#endif global.nbtgroups = 1; global.nbthread = 1; diff --git a/src/mworker.c b/src/mworker.c index d0ef3141e2..be453990a2 100644 --- a/src/mworker.c +++ b/src/mworker.c @@ -38,12 +38,10 @@ #include #include #include +#include #include #include -#if defined(USE_SYSTEMD) -#include -#endif static int exitcode = -1; 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; -#if defined(USE_SYSTEMD) if (global.tune.options & GTUNE_USE_SYSTEMD) { sd_notify(0, "STOPPING=1"); } -#endif ha_warning("Exiting Master process...\n"); mworker_kill(sig); }