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

extend standard retry with 429 http status code #2223

Merged
merged 4 commits into from
Jun 2, 2024
Merged

Conversation

orouz
Copy link
Collaborator

@orouz orouz commented May 21, 2024

Summary of your changes

this PR:

  1. adds a Standard Retryer
    • it seems that initializing AWS config via libbeat's InitializeAWSConfig function ends up returning an aws.Config with Retryer as nil, so without adding it we're not opting-in to the default retry mechanism
  2. adds 429 as an additional, retryable HTTP status code.

Implementation notes

the first commit of this PR can be considered an alternative, standalone implementation of doing the same thing the 2nd commit does. the difference between the two, is that the 2nd commit removes the ConfigProvider in favor of a plain function to encapsulate AWS config initialization (via libbeat) + adding a retryer. to do so, some code was removed and now all AWS config initializations call the same function, and the only consumer of the now-deleted AWS config provider (EKS) sets the region manually (which is what the provider did)

all in all - the 2nd commit's diff is bigger, but i think it does some nice cleanup too. although, we could go with the 1st if preferable.

Related Issues

Checklist

  • I have added tests that prove my fix is effective or that my feature works

@mergify mergify bot assigned orouz May 21, 2024
Copy link

mergify bot commented May 21, 2024

This pull request does not have a backport label. Could you fix it @orouz? 🙏
To fixup this pull request, you need to add the backport labels for the needed
branches, such as:

  • backport-v./d./d./d is the label to automatically backport to the 8./d branch. /d is the digit
    NOTE: backport-skip has been added to this pull request.

Copy link

github-actions bot commented May 21, 2024

📊 Allure Report - 💚 No failures were reported.

Result Count
🟥 Failed 0
🟩 Passed 359
⬜ Skipped 33

Comment on lines +34 to +41
awsConfig.Retryer = func() aws.Retryer {
return retry.NewStandard(func(o *retry.StandardOptions) {
o.Retryables = append(o.Retryables, retry.RetryableHTTPStatusCode{
Codes: map[int]struct{}{
http.StatusTooManyRequests: {},
},
})
})
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is essentialy the same as some AWS client does manually

}
awsConfig.Region = metadata.Region
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

all our AWS config initializations are done via libbeat. the only extra thing the config provider did was set the region. it was only used by EKS, which now sets the region itself

awsIdentityProvider: mockAwsIdentityProvider(errors.New("some error")),
clientProvider: mockKubeClient(nil),
awsMetadataProvider: mockMetadataProvider(errors.New("not this error")), // ignored
awsMetadataProvider: mockMetadataProvider(nil),
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this needs to not err because EKS now sets the region itself via the metadata provider

@orouz orouz marked this pull request as ready for review May 23, 2024 13:12
@orouz orouz requested a review from a team as a code owner May 23, 2024 13:12
@orouz orouz requested review from orestisfl and removed request for orestisfl May 23, 2024 13:12
@orouz orouz merged commit 26a2bb4 into elastic:main Jun 2, 2024
24 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Account for rate limiting in AWS fetchers
2 participants