Skip to content

Commit

Permalink
Retry requests on APIForbiddenError
Browse files Browse the repository at this point in the history
During k8s upgrade it may return APIForbiddenError, add this as valid
exception for retry request.
  • Loading branch information
jumpojoy committed Oct 30, 2024
1 parent a69dae0 commit b9e20e0
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion kopf/_cogs/clients/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,8 @@ async def request(
)
await errors.check_response(response) # but do not parse it!

except (aiohttp.ClientConnectionError, errors.APIServerError, asyncio.TimeoutError) as e:
# NOTE(vsaienko): during k8s upgrade API might throw 403 forbiden. Use retries for this exception as well.
except (aiohttp.ClientConnectionError, errors.APIServerError, asyncio.TimeoutError, errors.APIForbiddenError) as e:
if backoff is None: # i.e. the last or the only attempt.
logger.error(f"Request attempt {idx} failed; escalating: {what} -> {e!r}")
raise
Expand Down

0 comments on commit b9e20e0

Please sign in to comment.