diff --git a/CHANGELOG.md b/CHANGELOG.md index 7ecb99c..0ee69df 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,7 @@ ### Enhancements - Add basic rate limiting retries to the FlyBackend to abide by Fly's rate limits of 1 request per second, with 3 requests per second burst. +- Add basic retries for `no capacity` errors in the FlyBackend ## 0.5.0 (2024-09-11) diff --git a/lib/flame/fly_backend.ex b/lib/flame/fly_backend.ex index 7bb4a8d..fe7af00 100644 --- a/lib/flame/fly_backend.ex +++ b/lib/flame/fly_backend.ex @@ -364,7 +364,11 @@ defmodule FLAME.FlyBackend do {:ok, {{_, 200, _}, _, response_body}} -> JSON.decode!(response_body) - {:ok, {{_, 429, _}, _, _response_body}} when remaining_tries > 0 -> + # 429 Too Many Requests (rate limited) + # 412 Precondition Failed (can't find capacity) + # 409 Conflict (the flyd tried ending up not having capacity) + # 422 Unprocessable Entity (could not find capcity for volume workloads) + {:ok, {{_, status, _}, _, _response_body}} when status in [429, 412, 409, 422] and remaining_tries > 0 -> Process.sleep(1000) http_post!(url, remaining_tries - 1, opts)