bugfix: ApiResponseRatelimitCounter response header handling#1070
Open
rosskirkpat wants to merge 1 commit into
Open
bugfix: ApiResponseRatelimitCounter response header handling#1070rosskirkpat wants to merge 1 commit into
rosskirkpat wants to merge 1 commit into
Conversation
Signed-off-by: Ross Kirkpatrick <rkirkpat@akamai.com>
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #1070 +/- ##
==========================================
- Coverage 69.15% 69.03% -0.12%
==========================================
Files 71 71
Lines 6543 6563 +20
==========================================
+ Hits 4525 4531 +6
- Misses 1724 1732 +8
- Partials 294 300 +6 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
What this PR does / why we need it:
Fixes an edge case bug in handling POST /linode/instances linodego calls where the Linode is successfully created and the api response is missing header(s). This causes the request to fail, with
ERROR LinodeMachineReconciler Failed to create Linode machine instance. This is due to theApiResponseRatelimitCountermethod not checking if theX-Ratelimit-RemainingandX-Ratelimit-Resetheaders have a non-empty value, which causes the strconv call to fail:"[002] strconv.Atoi: parsing \"\": invalid syntax".This PR modifies the logic to not return an error and instead to log the error in the case of one or both of the headers not being present in the response. I added default values for each of the headers.
Per https://techdocs.akamai.com/linode-api/reference/rate-limits#specific-operation-rate-limits
Creating Linodes has a dedicated rate limit of 20 requests per 15 seconds.X-Ratelimit-Remaining: 19 (max of 20 per 15 seconds, minus the one just created)X-Ratelimit-Reset: 15 (seconds)Which issue(s) this PR fixes (optional, in
fixes #<issue number>(, fixes #<issue_number>, ...)format, will close the issue(s) when PR gets merged):Fixes #
Special notes for your reviewer:
TODOs: