]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: acme: schedule retries with a timer
authorWilliam Lallemand <wlallemand@haproxy.com>
Fri, 11 Apr 2025 22:47:33 +0000 (00:47 +0200)
committerWilliam Lallemand <wlallemand@haproxy.com>
Fri, 11 Apr 2025 23:39:03 +0000 (01:39 +0200)
Schedule the retries with a 3s exponential timer. This is a temporary
mesure as the client should follow the Retry-After field for
rate-limiting for every request (https://datatracker.ietf.org/doc/html/rfc8555#section-6.6)

src/acme.c

index df4b199cb4cadab0688e3e0aaa5e9200a9c9c82e..0c80fcf765e026fe504f1faf03f807d160cadcc1 100644 (file)
@@ -1659,7 +1659,7 @@ struct task *acme_process(struct task *task, void *context, unsigned int state)
 
        ctx->http_state = http_st;
        ctx->state = st;
-
+       task->expire = TICK_ETERNITY;
        return task;
 
 retry:
@@ -1668,8 +1668,14 @@ retry:
 
        ctx->retries--;
        if (ctx->retries > 0) {
-               ha_notice("acme: %s, retrying (%d/%d)...\n", errmsg ? errmsg : "", ACME_RETRY-ctx->retries, ACME_RETRY);
-               task_wakeup(task, TASK_WOKEN_MSG);
+               int delay = 1;
+               int i;
+
+               for (i = 0; i < ACME_RETRY - ctx->retries; i++)
+                       delay *= 3000;
+               ha_notice("acme: %s, retrying in %dms (%d/%d)...\n", errmsg ? errmsg : "", delay, ACME_RETRY-ctx->retries, ACME_RETRY);
+               task->expire = tick_add(now_ms, delay);
+
        } else {
                ha_notice("acme: %s, aborting. (%d/%d)\n", errmsg ? errmsg : "", ACME_RETRY-ctx->retries, ACME_RETRY);
                goto end;