feat: HAPROXY_NBTHREAD per-host thread-count knob (global nbthread, only when set)
HAProxy Manager Build and Push / Build-and-Push (push) Successful in 22m41s
HAProxy Manager Build and Push / Build-and-Push (push) Successful in 22m41s
2026-11-19 sdbees: with nbthread 4 a thread spun on a server lock held by a TLS health-check thread stalled in a page fault under memory pressure -> watchdog abort of the whole edge. nbthread 1 removes the failure class. HAPROXY_NBTHREAD (container env, integer 1-64) renders `nbthread N` in the global section ONLY when set. Unset/invalid = not rendered: every other host's config is byte-identical to before (verified against main's template, with and without Coraza). Invalid values are ignored with a warning, never rendered. Tests: scripts/test-nbthread-knob.py (parse, render, unset byte-identity vs the template minus the block, no cpu-map/thread-groups), run in the image build; real haproxy -c of nbthread 1 (+SPOE+QUIC) and of a bad value in validate-rendered-config.py. VERSION 2026.11.8 (with the arm64 base guard). Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0185ukXi4YX5FxJGqhi6qab6
This commit is contained in:
1 parent
56404f4777
commit
8ab6fdcef0
7 files changed
+130
-2
No files matched your search
@@ -3153,6 +3153,21 @@ def get_or_create_cluster_secret():
|
||||
logger.error("Failed to get/create cluster-secret: %s", e)
|
||||
return ''
|
||||
|
||||
|
||||
def parse_nbthread(raw):
|
||||
"""HAPROXY_NBTHREAD -> int 1..64, or None (= do not render `nbthread`).
|
||||
|
||||
Fail-safe: anything that is not a plain positive integer in range is
|
||||
IGNORED with a warning, never rendered, so a typo in a host file cannot
|
||||
produce an invalid haproxy.cfg (which would be a total edge outage)."""
|
||||
raw = (raw or '').strip()
|
||||
if not raw:
|
||||
return None
|
||||
if not (raw.isascii() and raw.isdigit()) or not 1 <= int(raw) <= 64:
|
||||
logger.warning(f"Ignoring HAPROXY_NBTHREAD={raw!r}: expected an integer 1-64")
|
||||
return None
|
||||
return int(raw)
|
||||
|
||||
def generate_config():
|
||||
try:
|
||||
conn = sqlite3.connect(DB_FILE)
|
||||
@@ -3246,10 +3261,15 @@ def generate_config():
|
||||
splash_raw = os.environ.get('HAPROXY_DEFAULT_SPLASH', '').strip().lower()
|
||||
default_splash = splash_raw not in ('0', 'false', 'no', 'off')
|
||||
|
||||
# Optional per-host thread count (global `nbthread`). Unset/invalid =
|
||||
# not rendered = HAProxy's automatic choice, byte-identical config.
|
||||
nbthread = parse_nbthread(os.environ.get('HAPROXY_NBTHREAD'))
|
||||
|
||||
# Add Haproxy Default Headers
|
||||
default_headers = template_env.get_template('hap_header.tpl').render(
|
||||
cluster_secret = get_or_create_cluster_secret(),
|
||||
syslog_target = syslog_target,
|
||||
nbthread = nbthread,
|
||||
coraza_spoe_backend = coraza_spoe_backend,
|
||||
)
|
||||
config_parts.append(default_headers)
|
||||
|
||||
Reference in new issue
Block a user