Skip to content

bugfix: ApiResponseRatelimitCounter response header handling#1070

Open
rosskirkpat wants to merge 1 commit into
mainfrom
rk/bugfix-rate-limit-headers
Open

bugfix: ApiResponseRatelimitCounter response header handling#1070
rosskirkpat wants to merge 1 commit into
mainfrom
rk/bugfix-rate-limit-headers

Conversation

@rosskirkpat
Copy link
Copy Markdown
Contributor

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 the ApiResponseRatelimitCounter method not checking if the X-Ratelimit-Remaining and X-Ratelimit-Reset headers 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:

  • squashed commits
  • includes documentation
  • adds unit tests
  • adds or updates e2e tests

Signed-off-by: Ross Kirkpatrick <rkirkpat@akamai.com>
@rosskirkpat rosskirkpat self-assigned this May 1, 2026
@rosskirkpat rosskirkpat changed the title fix ApiResponseRatelimitCounter bug bugfix: ApiResponseRatelimitCounter response header handling May 1, 2026
@codecov
Copy link
Copy Markdown

codecov Bot commented May 1, 2026

Codecov Report

❌ Patch coverage is 48.14815% with 14 lines in your changes missing coverage. Please review.
✅ Project coverage is 69.03%. Comparing base (59420ee) to head (0ce2b04).

Files with missing lines Patch % Lines
util/ratelimits.go 48.14% 8 Missing and 6 partials ⚠️
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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

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.

1 participant