From 8a0a822aa75f4ba6ad8b43e878a9b4a1513383cd Mon Sep 17 00:00:00 2001 From: Aby Okhovat Date: Tue, 7 Apr 2026 18:51:54 +0000 Subject: [PATCH 1/8] Haproxy 3.2.15 upgrade --- haproxy-lua/activate.sh | 36 ++++++++++++++++--- .../0001-Initial-commit-of-Weir-QoS.patch | 19 +++++----- ...it-system-specific-hlua-and-Makefile.patch | 30 ++++++++-------- 3 files changed, 57 insertions(+), 28 deletions(-) diff --git a/haproxy-lua/activate.sh b/haproxy-lua/activate.sh index 03076b0..5a09ae9 100755 --- a/haproxy-lua/activate.sh +++ b/haproxy-lua/activate.sh @@ -1,8 +1,16 @@ #!/usr/bin/bash set -e - -WEIR_HAPROXY_BASE_COMMIT=v3.3.0 +WEIR_HAPROXY_BASE_COMMIT=v3.2.15 +# Use the major.minor series (for example, 3.3) for the upstream repo name. +# Accept commit tags in form v.. or ... +if [[ "$WEIR_HAPROXY_BASE_COMMIT" =~ ^v?([0-9]+\.[0-9]+)\.[0-9]+$ ]]; then + WEIR_HAPROXY_SERIES=${BASH_REMATCH[1]} +else + echo "Invalid WEIR_HAPROXY_BASE_COMMIT: $WEIR_HAPROXY_BASE_COMMIT" + echo "Expected format: [v].. (for example, v3.3.6 or 3.3.6)" + exit 1 +fi SCRIPT_DIR=$(dirname "$0") HAPROXY_SOURCE_DIR=$SCRIPT_DIR/haproxy-source @@ -10,7 +18,7 @@ HAPROXY_SOURCE_DIR=$SCRIPT_DIR/haproxy-source if [[ -d "$HAPROXY_SOURCE_DIR" ]]; then echo "HAProxy directory already exists @ $HAPROXY_SOURCE_DIR, skipping clone step..." else - git clone "${WEIR_HAPROXY_REPO_URL:-https://github.com/haproxy/haproxy.git}" "$HAPROXY_SOURCE_DIR" + git clone "${WEIR_HAPROXY_REPO_URL:-https://git.haproxy.org/git/haproxy-$WEIR_HAPROXY_SERIES.git}" "$HAPROXY_SOURCE_DIR" fi if (! git -C "$HAPROXY_SOURCE_DIR" diff --quiet) || (! git -C "$HAPROXY_SOURCE_DIR" diff --staged --quiet); then @@ -20,8 +28,26 @@ fi # Store the commit on which our local changes are based, so that we know which commits need to be # turned into patches when we later run the `deactivate` script. -git -C "$HAPROXY_SOURCE_DIR" checkout $WEIR_HAPROXY_BASE_COMMIT -git -C "$HAPROXY_SOURCE_DIR" show-ref -s $WEIR_HAPROXY_BASE_COMMIT > "$SCRIPT_DIR"/.haproxy-activated-commit +# Always fetch release tags from upstream source to avoid mirror tag lag. +WEIR_HAPROXY_TAG_SOURCE_URL=${WEIR_HAPROXY_TAG_SOURCE_URL:-https://git.haproxy.org/git/haproxy-$WEIR_HAPROXY_SERIES.git} +git -C "$HAPROXY_SOURCE_DIR" fetch --tags --force "$WEIR_HAPROXY_TAG_SOURCE_URL" + +WEIR_HAPROXY_TAG="$WEIR_HAPROXY_BASE_COMMIT" +if ! git -C "$HAPROXY_SOURCE_DIR" rev-parse --verify --quiet "refs/tags/$WEIR_HAPROXY_TAG" > /dev/null; then + if [[ "$WEIR_HAPROXY_BASE_COMMIT" == v* ]]; then + WEIR_HAPROXY_TAG=${WEIR_HAPROXY_BASE_COMMIT#v} + else + WEIR_HAPROXY_TAG=v$WEIR_HAPROXY_BASE_COMMIT + fi +fi + +if ! git -C "$HAPROXY_SOURCE_DIR" rev-parse --verify --quiet "refs/tags/$WEIR_HAPROXY_TAG" > /dev/null; then + echo "Tag $WEIR_HAPROXY_BASE_COMMIT (or alternate form $WEIR_HAPROXY_TAG) was not found in $HAPROXY_SOURCE_DIR" + exit 1 +fi + +git -C "$HAPROXY_SOURCE_DIR" checkout "$WEIR_HAPROXY_TAG" +git -C "$HAPROXY_SOURCE_DIR" show-ref -s "refs/tags/$WEIR_HAPROXY_TAG" > "$SCRIPT_DIR"/.haproxy-activated-commit # Enable ** for directory expansion in globs, and allow zero matches to result in an empty list shopt -s globstar nullglob diff --git a/haproxy-lua/patches/0001-Initial-commit-of-Weir-QoS.patch b/haproxy-lua/patches/0001-Initial-commit-of-Weir-QoS.patch index bd6868b..046aa42 100644 --- a/haproxy-lua/patches/0001-Initial-commit-of-Weir-QoS.patch +++ b/haproxy-lua/patches/0001-Initial-commit-of-Weir-QoS.patch @@ -5,26 +5,26 @@ Subject: [PATCH] Initial commit of Weir QoS --- Makefile | 1 + - src/hlua.c | 30 ++++++++++++++++++++++++++++++ - 2 files changed, 31 insertions(+) + src/hlua.c | 31 +++++++++++++++++++++++++++++++ + 2 files changed, 32 insertions(+) diff --git a/Makefile b/Makefile -index 90e791f39..e6be08e58 100644 +index 1959ac479..3a099edbc 100644 --- a/Makefile +++ b/Makefile -@@ -1003,6 +1003,7 @@ OBJS += src/mux_h2.o src/mux_h1.o src/mux_fcgi.o src/log.o \ +@@ -993,6 +993,7 @@ OBJS += src/mux_h2.o src/mux_h1.o src/mux_fcgi.o src/log.o \ src/http_acl.o src/dict.o src/dgram.o src/pipe.o \ src/hpack-huff.o src/hpack-enc.o src/ebtree.o src/hash.o \ - src/httpclient_cli.o src/version.o src/ncbmbuf.o src/ech.o + src/version.o src/ncbmbuf.o +OBJS += src/flt_weir.o ifneq ($(TRACE),) OBJS += src/calltrace.o diff --git a/src/hlua.c b/src/hlua.c -index ec2a8ee7b..2332e29c3 100644 +index 9699936e8..875f6113d 100644 --- a/src/hlua.c +++ b/src/hlua.c -@@ -14010,6 +14010,35 @@ static void *hlua_alloc(void *ud, void *ptr, size_t osize, size_t nsize) +@@ -14038,6 +14038,36 @@ static void *hlua_alloc(void *ud, void *ptr, size_t osize, size_t nsize) return ptr; } @@ -56,14 +56,15 @@ index ec2a8ee7b..2332e29c3 100644 + lua_pushboolean(L, success); + return 1; +} ++ + /* This function can fail with an abort() due to a Lua critical error. * We are in the initialisation process of HAProxy, this abort() is * tolerated. -@@ -14132,6 +14161,7 @@ lua_State *hlua_init_state(int thread_num) +@@ -14160,6 +14190,7 @@ lua_State *hlua_init_state(int thread_num) hlua_class_function(L, "Alert", hlua_log_alert); hlua_class_function(L, "done", hlua_done); - hlua_class_function(L, "use_native_mailers_config", hlua_use_native_mailers_config); + hlua_class_function(L, "disable_legacy_mailers", hlua_disable_legacy_mailers); + hlua_class_function(L, "ingest_weir_limit_share_update", hlua_ingest_weir_limit_share_update); hlua_fcn_reg_core_fcn(L); diff --git a/haproxy-lua/patches/0002-Add-old-rate-limit-system-specific-hlua-and-Makefile.patch b/haproxy-lua/patches/0002-Add-old-rate-limit-system-specific-hlua-and-Makefile.patch index 01aac9a..8d7addf 100644 --- a/haproxy-lua/patches/0002-Add-old-rate-limit-system-specific-hlua-and-Makefile.patch +++ b/haproxy-lua/patches/0002-Add-old-rate-limit-system-specific-hlua-and-Makefile.patch @@ -5,24 +5,24 @@ Subject: [PATCH] Add old-rate-limit-system-specific hlua and Makefile changes --- Makefile | 2 +- - src/hlua.c | 100 +++++++++++++++++++++++++++++++++++++++++++++++++++++ - 2 files changed, 101 insertions(+), 1 deletion(-) + src/hlua.c | 102 ++++++++++++++++++++++++++++++++++++++++++++++++++++- + 2 files changed, 102 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile -index e6be08e58..1e86ba270 100644 +index 3a099edbc..413534fa1 100644 --- a/Makefile +++ b/Makefile -@@ -1003,7 +1003,7 @@ OBJS += src/mux_h2.o src/mux_h1.o src/mux_fcgi.o src/log.o \ +@@ -993,7 +993,7 @@ OBJS += src/mux_h2.o src/mux_h1.o src/mux_fcgi.o src/log.o \ src/http_acl.o src/dict.o src/dgram.o src/pipe.o \ src/hpack-huff.o src/hpack-enc.o src/ebtree.o src/hash.o \ - src/httpclient_cli.o src/version.o src/ncbmbuf.o src/ech.o + src/version.o src/ncbmbuf.o -OBJS += src/flt_weir.o +OBJS += src/flt_weir.o src/rate_limit.o ifneq ($(TRACE),) OBJS += src/calltrace.o diff --git a/src/hlua.c b/src/hlua.c -index 2332e29c3..f47693239 100644 +index 875f6113d..a9263daed 100644 --- a/src/hlua.c +++ b/src/hlua.c @@ -69,6 +69,7 @@ @@ -33,7 +33,7 @@ index 2332e29c3..f47693239 100644 /* Global LUA flags */ -@@ -14039,6 +14040,100 @@ __LJMP static int hlua_ingest_weir_limit_share_update(lua_State *L) +@@ -14067,6 +14068,101 @@ __LJMP static int hlua_ingest_weir_limit_share_update(lua_State *L) return 1; } @@ -52,6 +52,7 @@ index 2332e29c3..f47693239 100644 +{ + + const char* put_get = MAY_LJMP(luaL_checkstring(L, 1)); ++ + if (strcmp(put_get, "upload") == 0){ + print_out_key_speed_table(RL_UPLOAD); + lua_pushboolean(L, 1); @@ -62,6 +63,7 @@ index 2332e29c3..f47693239 100644 + lua_pushboolean(L, 1); + return 1; + } ++ + lua_pushboolean(L, 0); + + return 1; @@ -130,13 +132,12 @@ index 2332e29c3..f47693239 100644 + } + return 0; +} -+ + /* This function can fail with an abort() due to a Lua critical error. * We are in the initialisation process of HAProxy, this abort() is - * tolerated. -@@ -14162,6 +14257,9 @@ lua_State *hlua_init_state(int thread_num) +@@ -14191,6 +14287,9 @@ lua_State *hlua_init_state(int thread_num) hlua_class_function(L, "done", hlua_done); - hlua_class_function(L, "use_native_mailers_config", hlua_use_native_mailers_config); + hlua_class_function(L, "disable_legacy_mailers", hlua_disable_legacy_mailers); hlua_class_function(L, "ingest_weir_limit_share_update", hlua_ingest_weir_limit_share_update); + hlua_class_function(L, "throttle_key_speed", hlua_throttle_key_speed); + hlua_class_function(L, "printout_speed_table", hlua_printout_speed_table); @@ -144,7 +145,7 @@ index 2332e29c3..f47693239 100644 hlua_fcn_reg_core_fcn(L); lua_setglobal(L, "core"); -@@ -14410,6 +14508,7 @@ lua_State *hlua_init_state(int thread_num) +@@ -14439,6 +14538,7 @@ lua_State *hlua_init_state(int thread_num) hlua_class_function(L, "req_set_path", hlua_http_req_set_path); hlua_class_function(L, "req_set_query", hlua_http_req_set_query); hlua_class_function(L, "req_set_uri", hlua_http_req_set_uri); @@ -152,10 +153,11 @@ index 2332e29c3..f47693239 100644 hlua_class_function(L, "res_get_headers",hlua_http_res_get_headers); hlua_class_function(L, "res_del_header", hlua_http_res_del_hdr); -@@ -14419,6 +14518,7 @@ lua_State *hlua_init_state(int thread_num) +@@ -14447,7 +14547,7 @@ lua_State *hlua_init_state(int thread_num) + hlua_class_function(L, "res_add_header", hlua_http_res_add_hdr); hlua_class_function(L, "res_set_header", hlua_http_res_set_hdr); hlua_class_function(L, "res_set_status", hlua_http_res_set_status); - +- + hlua_class_function(L, "res_get_status", hlua_http_res_get_status); lua_rawset(L, -3); From e1f0d344970302fbe42a72d7ad09db645ec1f434 Mon Sep 17 00:00:00 2001 From: Aby Okhovat Date: Tue, 14 Apr 2026 13:39:49 +0000 Subject: [PATCH 2/8] Update based on comments --- haproxy-lua/activate.sh | 24 +++---------------- .../0001-Initial-commit-of-Weir-QoS.patch | 1 - ...it-system-specific-hlua-and-Makefile.patch | 4 +--- 3 files changed, 4 insertions(+), 25 deletions(-) diff --git a/haproxy-lua/activate.sh b/haproxy-lua/activate.sh index 5a09ae9..1cbc599 100755 --- a/haproxy-lua/activate.sh +++ b/haproxy-lua/activate.sh @@ -28,26 +28,8 @@ fi # Store the commit on which our local changes are based, so that we know which commits need to be # turned into patches when we later run the `deactivate` script. -# Always fetch release tags from upstream source to avoid mirror tag lag. -WEIR_HAPROXY_TAG_SOURCE_URL=${WEIR_HAPROXY_TAG_SOURCE_URL:-https://git.haproxy.org/git/haproxy-$WEIR_HAPROXY_SERIES.git} -git -C "$HAPROXY_SOURCE_DIR" fetch --tags --force "$WEIR_HAPROXY_TAG_SOURCE_URL" - -WEIR_HAPROXY_TAG="$WEIR_HAPROXY_BASE_COMMIT" -if ! git -C "$HAPROXY_SOURCE_DIR" rev-parse --verify --quiet "refs/tags/$WEIR_HAPROXY_TAG" > /dev/null; then - if [[ "$WEIR_HAPROXY_BASE_COMMIT" == v* ]]; then - WEIR_HAPROXY_TAG=${WEIR_HAPROXY_BASE_COMMIT#v} - else - WEIR_HAPROXY_TAG=v$WEIR_HAPROXY_BASE_COMMIT - fi -fi - -if ! git -C "$HAPROXY_SOURCE_DIR" rev-parse --verify --quiet "refs/tags/$WEIR_HAPROXY_TAG" > /dev/null; then - echo "Tag $WEIR_HAPROXY_BASE_COMMIT (or alternate form $WEIR_HAPROXY_TAG) was not found in $HAPROXY_SOURCE_DIR" - exit 1 -fi - -git -C "$HAPROXY_SOURCE_DIR" checkout "$WEIR_HAPROXY_TAG" -git -C "$HAPROXY_SOURCE_DIR" show-ref -s "refs/tags/$WEIR_HAPROXY_TAG" > "$SCRIPT_DIR"/.haproxy-activated-commit +git -C "$HAPROXY_SOURCE_DIR" checkout $WEIR_HAPROXY_BASE_COMMIT +git -C "$HAPROXY_SOURCE_DIR" show-ref -s $WEIR_HAPROXY_BASE_COMMIT > "$SCRIPT_DIR"/.haproxy-activated-commit # Enable ** for directory expansion in globs, and allow zero matches to result in an empty list shopt -s globstar nullglob @@ -80,4 +62,4 @@ fi # shellcheck disable=SC2046 git -C "$HAPROXY_SOURCE_DIR" am $(realpath "$SCRIPT_DIR"/patches/*) -echo "Activation complete" +echo "Activation complete" \ No newline at end of file diff --git a/haproxy-lua/patches/0001-Initial-commit-of-Weir-QoS.patch b/haproxy-lua/patches/0001-Initial-commit-of-Weir-QoS.patch index 046aa42..a9a705a 100644 --- a/haproxy-lua/patches/0001-Initial-commit-of-Weir-QoS.patch +++ b/haproxy-lua/patches/0001-Initial-commit-of-Weir-QoS.patch @@ -56,7 +56,6 @@ index 9699936e8..875f6113d 100644 + lua_pushboolean(L, success); + return 1; +} -+ + /* This function can fail with an abort() due to a Lua critical error. * We are in the initialisation process of HAProxy, this abort() is diff --git a/haproxy-lua/patches/0002-Add-old-rate-limit-system-specific-hlua-and-Makefile.patch b/haproxy-lua/patches/0002-Add-old-rate-limit-system-specific-hlua-and-Makefile.patch index 8d7addf..911a16c 100644 --- a/haproxy-lua/patches/0002-Add-old-rate-limit-system-specific-hlua-and-Makefile.patch +++ b/haproxy-lua/patches/0002-Add-old-rate-limit-system-specific-hlua-and-Makefile.patch @@ -52,7 +52,6 @@ index 875f6113d..a9263daed 100644 +{ + + const char* put_get = MAY_LJMP(luaL_checkstring(L, 1)); -+ + if (strcmp(put_get, "upload") == 0){ + print_out_key_speed_table(RL_UPLOAD); + lua_pushboolean(L, 1); @@ -65,7 +64,6 @@ index 875f6113d..a9263daed 100644 + } + + lua_pushboolean(L, 0); -+ + return 1; +} + @@ -132,7 +130,7 @@ index 875f6113d..a9263daed 100644 + } + return 0; +} - ++ /* This function can fail with an abort() due to a Lua critical error. * We are in the initialisation process of HAProxy, this abort() is @@ -14191,6 +14287,9 @@ lua_State *hlua_init_state(int thread_num) From 1d09ed9212e82fbed291befec9f747cdc0ee20cb Mon Sep 17 00:00:00 2001 From: Aby Okhovat Date: Tue, 14 Apr 2026 13:46:26 +0000 Subject: [PATCH 3/8] Add new line: --- haproxy-lua/activate.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/haproxy-lua/activate.sh b/haproxy-lua/activate.sh index 1cbc599..2cb1a01 100755 --- a/haproxy-lua/activate.sh +++ b/haproxy-lua/activate.sh @@ -62,4 +62,4 @@ fi # shellcheck disable=SC2046 git -C "$HAPROXY_SOURCE_DIR" am $(realpath "$SCRIPT_DIR"/patches/*) -echo "Activation complete" \ No newline at end of file +echo "Activation complete" From 9096a5214944b3a6ff36f130714179b5491c4abd Mon Sep 17 00:00:00 2001 From: Aby Okhovat Date: Tue, 14 Apr 2026 13:54:09 +0000 Subject: [PATCH 4/8] Update activate.sh to fix error: pathspec 'v3.2.15' did not match any file(s) known to git --- haproxy-lua/activate.sh | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/haproxy-lua/activate.sh b/haproxy-lua/activate.sh index 2cb1a01..eb6980a 100755 --- a/haproxy-lua/activate.sh +++ b/haproxy-lua/activate.sh @@ -28,8 +28,25 @@ fi # Store the commit on which our local changes are based, so that we know which commits need to be # turned into patches when we later run the `deactivate` script. -git -C "$HAPROXY_SOURCE_DIR" checkout $WEIR_HAPROXY_BASE_COMMIT -git -C "$HAPROXY_SOURCE_DIR" show-ref -s $WEIR_HAPROXY_BASE_COMMIT > "$SCRIPT_DIR"/.haproxy-activated-commit +HAPROXY_BASE_REF="$WEIR_HAPROXY_BASE_COMMIT" +if [[ "$WEIR_HAPROXY_BASE_COMMIT" == v* ]]; then + HAPROXY_ALT_BASE_REF="${WEIR_HAPROXY_BASE_COMMIT#v}" +else + HAPROXY_ALT_BASE_REF="v$WEIR_HAPROXY_BASE_COMMIT" +fi + +if git -C "$HAPROXY_SOURCE_DIR" rev-parse --verify --quiet "$HAPROXY_BASE_REF^{commit}" >/dev/null; then + HAPROXY_RESOLVED_BASE_REF="$HAPROXY_BASE_REF" +elif git -C "$HAPROXY_SOURCE_DIR" rev-parse --verify --quiet "$HAPROXY_ALT_BASE_REF^{commit}" >/dev/null; then + HAPROXY_RESOLVED_BASE_REF="$HAPROXY_ALT_BASE_REF" +else + echo "Unable to resolve HAProxy base ref. Tried '$HAPROXY_BASE_REF' and '$HAPROXY_ALT_BASE_REF'." + echo "If this is a new release, update WEIR_HAPROXY_BASE_COMMIT to a ref that exists in the upstream repo." + exit 1 +fi + +git -C "$HAPROXY_SOURCE_DIR" checkout "$HAPROXY_RESOLVED_BASE_REF" +git -C "$HAPROXY_SOURCE_DIR" rev-parse "$HAPROXY_RESOLVED_BASE_REF^{commit}" > "$SCRIPT_DIR"/.haproxy-activated-commit # Enable ** for directory expansion in globs, and allow zero matches to result in an empty list shopt -s globstar nullglob From 268872f0ea877961f632f860c53eebfabb3629dd Mon Sep 17 00:00:00 2001 From: Aby Okhovat Date: Tue, 14 Apr 2026 13:56:40 +0000 Subject: [PATCH 5/8] Update activate.sh to fix error: Unable to resolve HAProxy base ref. Tried 'v3.2.15' and '3.2.15' --- haproxy-lua/activate.sh | 32 ++++++++++++++++++++++++-------- 1 file changed, 24 insertions(+), 8 deletions(-) diff --git a/haproxy-lua/activate.sh b/haproxy-lua/activate.sh index eb6980a..b158d09 100755 --- a/haproxy-lua/activate.sh +++ b/haproxy-lua/activate.sh @@ -35,14 +35,30 @@ else HAPROXY_ALT_BASE_REF="v$WEIR_HAPROXY_BASE_COMMIT" fi -if git -C "$HAPROXY_SOURCE_DIR" rev-parse --verify --quiet "$HAPROXY_BASE_REF^{commit}" >/dev/null; then - HAPROXY_RESOLVED_BASE_REF="$HAPROXY_BASE_REF" -elif git -C "$HAPROXY_SOURCE_DIR" rev-parse --verify --quiet "$HAPROXY_ALT_BASE_REF^{commit}" >/dev/null; then - HAPROXY_RESOLVED_BASE_REF="$HAPROXY_ALT_BASE_REF" -else - echo "Unable to resolve HAProxy base ref. Tried '$HAPROXY_BASE_REF' and '$HAPROXY_ALT_BASE_REF'." - echo "If this is a new release, update WEIR_HAPROXY_BASE_COMMIT to a ref that exists in the upstream repo." - exit 1 +resolve_base_ref() { + if git -C "$HAPROXY_SOURCE_DIR" rev-parse --verify --quiet "$HAPROXY_BASE_REF^{commit}" >/dev/null; then + echo "$HAPROXY_BASE_REF" + return 0 + fi + if git -C "$HAPROXY_SOURCE_DIR" rev-parse --verify --quiet "$HAPROXY_ALT_BASE_REF^{commit}" >/dev/null; then + echo "$HAPROXY_ALT_BASE_REF" + return 0 + fi + return 1 +} + +if ! HAPROXY_RESOLVED_BASE_REF=$(resolve_base_ref); then + SERIES_REPO_URL="https://git.haproxy.org/git/haproxy-$WEIR_HAPROXY_SERIES.git" + ORIGIN_URL=$(git -C "$HAPROXY_SOURCE_DIR" config --get remote.origin.url || true) + echo "HAProxy base ref not found in '$ORIGIN_URL'. Fetching tags from '$SERIES_REPO_URL' and retrying..." + git -C "$HAPROXY_SOURCE_DIR" fetch --tags "$SERIES_REPO_URL" + + if ! HAPROXY_RESOLVED_BASE_REF=$(resolve_base_ref); then + echo "Unable to resolve HAProxy base ref. Tried '$HAPROXY_BASE_REF' and '$HAPROXY_ALT_BASE_REF'." + echo "Checked cloned remote '$ORIGIN_URL' and fetched tags from '$SERIES_REPO_URL'." + echo "If this is a new release, update WEIR_HAPROXY_BASE_COMMIT to a ref that exists in upstream." + exit 1 + fi fi git -C "$HAPROXY_SOURCE_DIR" checkout "$HAPROXY_RESOLVED_BASE_REF" From bce34cab475537a704ea729b52ab719f202829dd Mon Sep 17 00:00:00 2001 From: Aby Okhovat Date: Tue, 14 Apr 2026 14:06:12 +0000 Subject: [PATCH 6/8] Fix patch files --- haproxy-lua/patches/0001-Initial-commit-of-Weir-QoS.patch | 4 ++-- ...old-rate-limit-system-specific-hlua-and-Makefile.patch | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/haproxy-lua/patches/0001-Initial-commit-of-Weir-QoS.patch b/haproxy-lua/patches/0001-Initial-commit-of-Weir-QoS.patch index a9a705a..fcf1756 100644 --- a/haproxy-lua/patches/0001-Initial-commit-of-Weir-QoS.patch +++ b/haproxy-lua/patches/0001-Initial-commit-of-Weir-QoS.patch @@ -24,7 +24,7 @@ diff --git a/src/hlua.c b/src/hlua.c index 9699936e8..875f6113d 100644 --- a/src/hlua.c +++ b/src/hlua.c -@@ -14038,6 +14038,36 @@ static void *hlua_alloc(void *ud, void *ptr, size_t osize, size_t nsize) +@@ -14038,6 +14038,35 @@ static void *hlua_alloc(void *ud, void *ptr, size_t osize, size_t nsize) return ptr; } @@ -60,7 +60,7 @@ index 9699936e8..875f6113d 100644 /* This function can fail with an abort() due to a Lua critical error. * We are in the initialisation process of HAProxy, this abort() is * tolerated. -@@ -14160,6 +14190,7 @@ lua_State *hlua_init_state(int thread_num) +@@ -14160,6 +14189,7 @@ lua_State *hlua_init_state(int thread_num) hlua_class_function(L, "Alert", hlua_log_alert); hlua_class_function(L, "done", hlua_done); hlua_class_function(L, "disable_legacy_mailers", hlua_disable_legacy_mailers); diff --git a/haproxy-lua/patches/0002-Add-old-rate-limit-system-specific-hlua-and-Makefile.patch b/haproxy-lua/patches/0002-Add-old-rate-limit-system-specific-hlua-and-Makefile.patch index 911a16c..3778158 100644 --- a/haproxy-lua/patches/0002-Add-old-rate-limit-system-specific-hlua-and-Makefile.patch +++ b/haproxy-lua/patches/0002-Add-old-rate-limit-system-specific-hlua-and-Makefile.patch @@ -33,7 +33,7 @@ index 875f6113d..a9263daed 100644 /* Global LUA flags */ -@@ -14067,6 +14068,101 @@ __LJMP static int hlua_ingest_weir_limit_share_update(lua_State *L) +@@ -14067,5 +14068,99 @@ __LJMP static int hlua_ingest_weir_limit_share_update(lua_State *L) return 1; } @@ -133,7 +133,7 @@ index 875f6113d..a9263daed 100644 + /* This function can fail with an abort() due to a Lua critical error. * We are in the initialisation process of HAProxy, this abort() is -@@ -14191,6 +14287,9 @@ lua_State *hlua_init_state(int thread_num) +@@ -14191,6 +14286,9 @@ lua_State *hlua_init_state(int thread_num) hlua_class_function(L, "done", hlua_done); hlua_class_function(L, "disable_legacy_mailers", hlua_disable_legacy_mailers); hlua_class_function(L, "ingest_weir_limit_share_update", hlua_ingest_weir_limit_share_update); @@ -143,7 +143,7 @@ index 875f6113d..a9263daed 100644 hlua_fcn_reg_core_fcn(L); lua_setglobal(L, "core"); -@@ -14439,6 +14538,7 @@ lua_State *hlua_init_state(int thread_num) +@@ -14439,6 +14537,7 @@ lua_State *hlua_init_state(int thread_num) hlua_class_function(L, "req_set_path", hlua_http_req_set_path); hlua_class_function(L, "req_set_query", hlua_http_req_set_query); hlua_class_function(L, "req_set_uri", hlua_http_req_set_uri); @@ -151,7 +151,7 @@ index 875f6113d..a9263daed 100644 hlua_class_function(L, "res_get_headers",hlua_http_res_get_headers); hlua_class_function(L, "res_del_header", hlua_http_res_del_hdr); -@@ -14447,7 +14547,7 @@ lua_State *hlua_init_state(int thread_num) +@@ -14447,7 +14546,7 @@ lua_State *hlua_init_state(int thread_num) hlua_class_function(L, "res_add_header", hlua_http_res_add_hdr); hlua_class_function(L, "res_set_header", hlua_http_res_set_hdr); hlua_class_function(L, "res_set_status", hlua_http_res_set_status); From 862b7a2be4a84d4e8beaf7042dbd2f998b52750d Mon Sep 17 00:00:00 2001 From: Aby Okhovat Date: Mon, 18 May 2026 19:20:16 +0000 Subject: [PATCH 7/8] Simplify activate.sh --- haproxy-lua/activate.sh | 30 ++++++------------------------ 1 file changed, 6 insertions(+), 24 deletions(-) diff --git a/haproxy-lua/activate.sh b/haproxy-lua/activate.sh index b158d09..472469e 100755 --- a/haproxy-lua/activate.sh +++ b/haproxy-lua/activate.sh @@ -29,40 +29,22 @@ fi # Store the commit on which our local changes are based, so that we know which commits need to be # turned into patches when we later run the `deactivate` script. HAPROXY_BASE_REF="$WEIR_HAPROXY_BASE_COMMIT" -if [[ "$WEIR_HAPROXY_BASE_COMMIT" == v* ]]; then - HAPROXY_ALT_BASE_REF="${WEIR_HAPROXY_BASE_COMMIT#v}" -else - HAPROXY_ALT_BASE_REF="v$WEIR_HAPROXY_BASE_COMMIT" -fi - -resolve_base_ref() { - if git -C "$HAPROXY_SOURCE_DIR" rev-parse --verify --quiet "$HAPROXY_BASE_REF^{commit}" >/dev/null; then - echo "$HAPROXY_BASE_REF" - return 0 - fi - if git -C "$HAPROXY_SOURCE_DIR" rev-parse --verify --quiet "$HAPROXY_ALT_BASE_REF^{commit}" >/dev/null; then - echo "$HAPROXY_ALT_BASE_REF" - return 0 - fi - return 1 -} -if ! HAPROXY_RESOLVED_BASE_REF=$(resolve_base_ref); then +if ! git -C "$HAPROXY_SOURCE_DIR" rev-parse --verify --quiet "$HAPROXY_BASE_REF^{commit}" >/dev/null; then SERIES_REPO_URL="https://git.haproxy.org/git/haproxy-$WEIR_HAPROXY_SERIES.git" ORIGIN_URL=$(git -C "$HAPROXY_SOURCE_DIR" config --get remote.origin.url || true) - echo "HAProxy base ref not found in '$ORIGIN_URL'. Fetching tags from '$SERIES_REPO_URL' and retrying..." + echo "HAProxy base ref '$HAPROXY_BASE_REF' not found in '$ORIGIN_URL'. Fetching tags from '$SERIES_REPO_URL'..." git -C "$HAPROXY_SOURCE_DIR" fetch --tags "$SERIES_REPO_URL" - if ! HAPROXY_RESOLVED_BASE_REF=$(resolve_base_ref); then - echo "Unable to resolve HAProxy base ref. Tried '$HAPROXY_BASE_REF' and '$HAPROXY_ALT_BASE_REF'." - echo "Checked cloned remote '$ORIGIN_URL' and fetched tags from '$SERIES_REPO_URL'." + if ! git -C "$HAPROXY_SOURCE_DIR" rev-parse --verify --quiet "$HAPROXY_BASE_REF^{commit}" >/dev/null; then + echo "Unable to resolve HAProxy base ref '$HAPROXY_BASE_REF'." echo "If this is a new release, update WEIR_HAPROXY_BASE_COMMIT to a ref that exists in upstream." exit 1 fi fi -git -C "$HAPROXY_SOURCE_DIR" checkout "$HAPROXY_RESOLVED_BASE_REF" -git -C "$HAPROXY_SOURCE_DIR" rev-parse "$HAPROXY_RESOLVED_BASE_REF^{commit}" > "$SCRIPT_DIR"/.haproxy-activated-commit +git -C "$HAPROXY_SOURCE_DIR" checkout "$HAPROXY_BASE_REF" +git -C "$HAPROXY_SOURCE_DIR" rev-parse "$HAPROXY_BASE_REF^{commit}" > "$SCRIPT_DIR"/.haproxy-activated-commit # Enable ** for directory expansion in globs, and allow zero matches to result in an empty list shopt -s globstar nullglob From bd524b2a3434026f1a5c2b821f88f7b2d9cd2069 Mon Sep 17 00:00:00 2001 From: Aby Okhovat Date: Mon, 18 May 2026 19:34:08 +0000 Subject: [PATCH 8/8] Add comment to activate.sh --- haproxy-lua/activate.sh | 3 +++ 1 file changed, 3 insertions(+) diff --git a/haproxy-lua/activate.sh b/haproxy-lua/activate.sh index 472469e..82ea9f9 100755 --- a/haproxy-lua/activate.sh +++ b/haproxy-lua/activate.sh @@ -30,12 +30,15 @@ fi # turned into patches when we later run the `deactivate` script. HAPROXY_BASE_REF="$WEIR_HAPROXY_BASE_COMMIT" +# Ensure the requested base ref exists locally before checkout. +# If missing, fetch tags from the upstream series repo and retry once. if ! git -C "$HAPROXY_SOURCE_DIR" rev-parse --verify --quiet "$HAPROXY_BASE_REF^{commit}" >/dev/null; then SERIES_REPO_URL="https://git.haproxy.org/git/haproxy-$WEIR_HAPROXY_SERIES.git" ORIGIN_URL=$(git -C "$HAPROXY_SOURCE_DIR" config --get remote.origin.url || true) echo "HAProxy base ref '$HAPROXY_BASE_REF' not found in '$ORIGIN_URL'. Fetching tags from '$SERIES_REPO_URL'..." git -C "$HAPROXY_SOURCE_DIR" fetch --tags "$SERIES_REPO_URL" + # Fail fast if the ref still does not resolve after tag refresh. if ! git -C "$HAPROXY_SOURCE_DIR" rev-parse --verify --quiet "$HAPROXY_BASE_REF^{commit}" >/dev/null; then echo "Unable to resolve HAProxy base ref '$HAPROXY_BASE_REF'." echo "If this is a new release, update WEIR_HAPROXY_BASE_COMMIT to a ref that exists in upstream."