From 7aeb50cbae513bea5ef52a5422d5d3fbdac90f96 Mon Sep 17 00:00:00 2001 From: "juvenal.diaz" Date: Tue, 27 Oct 2026 09:29:15 -0600 Subject: [PATCH] fix: tolerate API execution polling through edge --- bootstrap/edge/templates/default.conf.tftpl | 2 +- scripts/jeannie-remote | 8 +++++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/bootstrap/edge/templates/default.conf.tftpl b/bootstrap/edge/templates/default.conf.tftpl index b9f86cc..862d2aa 100644 --- a/bootstrap/edge/templates/default.conf.tftpl +++ b/bootstrap/edge/templates/default.conf.tftpl @@ -12,7 +12,7 @@ access_log /var/log/nginx/crowdsec-access.log; error_log /var/log/nginx/crowdsec-error.log warn; limit_req_zone $binary_remote_addr zone=one:10m rate=10r/s; -limit_req_zone $binary_remote_addr zone=jeannie_api:10m rate=2r/s; +limit_req_zone $binary_remote_addr zone=jeannie_api:10m rate=5r/s; proxy_cache_path /var/cache/nginx levels=1:2 keys_zone=static_assets:10m max_size=100m inactive=24h; proxy_cache_path /var/cache/nginx_dynamic levels=1:2 keys_zone=dynamic_content:5m max_size=50m inactive=1h; diff --git a/scripts/jeannie-remote b/scripts/jeannie-remote index 1adeb81..27eab27 100755 --- a/scripts/jeannie-remote +++ b/scripts/jeannie-remote @@ -55,8 +55,13 @@ status, result = request("POST", "/v1/execute", {"command": command, "args": arg if status != 202: sys.exit(1) execution_id = result["id"] +poll_delay = 1.0 while True: status, result = request("GET", "/v1/executions/" + execution_id) + if status in (429, 503): + time.sleep(poll_delay) + poll_delay = min(poll_delay * 2, 5.0) + continue if status != 200: sys.exit(1) if result["status"] in ("succeeded", "failed"): @@ -64,5 +69,6 @@ while True: if output: print(output, end="" if output.endswith("\n") else "\n") sys.exit(int(result.get("exit_code", 0))) - time.sleep(0.5) + poll_delay = 1.0 + time.sleep(poll_delay) PY