-
Notifications
You must be signed in to change notification settings - Fork 66
fix(flagd): do not retry for certain status codes (#756) #783
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
base: feat/flagd-inprocess-eventing-and-grace-period
Are you sure you want to change the base?
Conversation
Summary of ChangesHello @alexandraoberaigner, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request significantly refines the Highlights
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code Review
This pull request introduces a mechanism to prevent retries for certain gRPC status codes in the flagd provider, enhancing error handling and resource utilization. The changes include adding a set of non-retryable status codes, a helper function to initialize this set, and logic to check for these codes during sync cycles. The code changes look good and address the issue of unnecessary retries for non-recoverable errors.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@guidobrei and I fixed a very similar thing in Java recently: open-feature/java-sdk-contrib#1590 (there's some other stuff as well but it's not related). The key things are:
- this change to follow gRPC's recommendations and reduce the amount of retryable codes (we only had this many because were were using the retry backoff to slow down the loop
- this change to prevent tight loops when the retry policy doesn't take effect
I think it would be better do implement the same here and transition to a FATAL state (and even add this to the flagd spec).
Signed-off-by: Alexandra Oberaigner <[email protected]>
778197d to
10e72b9
Compare
I implemented your suggestions @toddbaert. Please let me know if you spot anything else 🙏 |
… non-retry error handling (open-feature#756) Signed-off-by: Alexandra Oberaigner <[email protected]>
4457536 to
71745fc
Compare
| "retryPolicy": { | ||
| "MaxAttempts": 3, | ||
| "InitialBackoff": "1s", | ||
| "MaxBackoff": "5s", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the java impl, we set this to the maxBackoff param: https://github.com/open-feature/java-sdk-contrib/pull/1590/files#diff-bbef645a236a67bc95a5f8aa30fa5a528c6b2d45b4f4137b4f4b1074af197f26R57
See: https://flagd.dev/providers/rust/?h=backoff#configuration-options
That way, there's consistency between the gRPC RPC-level retries and our stream cycle.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It may be easier to put this in a small util function in another file along with the nonRetryableCodes var if you do.
| } | ||
|
|
||
| // Backoff before retrying | ||
| time.Sleep(time.Duration(g.RetryGracePeriod)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you use the FLAGD_RETRY_BACKOFF_MAX_MS param here instead, like we did in Java? I think it's a more sensible setting to use here.
This PR
This pull request enhances the gRPC synchronization logic in the
flagdprovider by introducing a mechanism to identify and handle non-retryable gRPC status codes. This ensures that certain errors (like authentication failures) are not retried unnecessarily, improving error handling and resource usage.Related Issues
improves #744 to fix #756
Notes
Error handling improvements:
PermissionDenied,Unauthenticated) and logic to prevent retries when these errors occur during sync cycles. [1] [2]initNonRetryableStatusCodesSetto parse and initialize the set of non-retryable codes at startup. [1] [2]How to test