Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Re-authenticate if the session is closed by a concurrent request #1031

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

nolar
Copy link
Owner

@nolar nolar commented Jun 11, 2023

Several concurrent requests can step on each others toes while catching HTTP 401s: one of them will catch 401 and cause the re-auth normally (by invalidating the APIContext via the Vault), while others will be left with the closed session and will not be able even to try executing their retried requests to get that 401. Instead, they will get a generic RuntimeError("Session is closed") from aiohttp.

The concurrent requests are highly likely if the API returned some other errors previously, so that the requests went into the back-off sleep for a few seconds before retrying.

A proper fix would be to retry with a new session, but we currently have no mechanisms to replace the session in a context object (safely). Hence, escalate and try again with new credentials (loosing the retry counter as a side effect).

TODO: Requires tests to simulate the situation — if the hypothesis is correct.

Presumably fixes #980.

@nolar nolar force-pushed the session-closed-in-reauth branch from fc76eaa to 1efbcf7 Compare June 11, 2023 16:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Watchers on Custom Resources throw RuntimeError("Session is closed") and permanently die
1 participant