feat: Support automatic retries for runner removal #252
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Context
We have noticed that occasionally, the Stop Runner job fails with a vague "HttpError". Possible reasons might be a brief network outage, the runner was already removed, or even a GitHub outage (which lately has been pretty common sadly). More than just a failed job, this can lead to several orphaned runners that are never cleaned up.
Proposed Solution
To increase the robustness of the Stop Runner job, this PR introduces some retry logic with exponential backoff to the runner removal step.
Additionally, if we get a 404 back that means the runner was likely already removed, so we can exit happily instead of failing.
Bonus: Instead of just printing "HttpError" which is not super helpful, we are also now logging the exact HTTP status code & message when it does truly fail.