-
Notifications
You must be signed in to change notification settings - Fork 68
fix(flagd): configurable retry backoff after each sync cycle error (#756) #806
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
Open
alexandraoberaigner
wants to merge
8
commits into
open-feature:main
Choose a base branch
from
open-feature-forking:fix/retry-backoff
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+130
−24
Open
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
90d8dcf
fix: return fatal on certain error codes during first stream cycle
alexandraoberaigner 9ab3191
update testbed, remove PR-split leftovers
alexandraoberaigner 5e3660b
fix fatal codes default parsing
alexandraoberaigner b5478f6
fix: return fatal on certain error codes during first stream cycle
alexandraoberaigner f3c2394
chore: make backoff configurable in grpc retry policy, have consisten…
alexandraoberaigner dc1cf05
fix e2e tests: backoff after sending error event
alexandraoberaigner 0edd671
use timer instead of sleep to allow context cancellation
alexandraoberaigner e19a15a
fix: add comment for more explaination (pr suggestion)
alexandraoberaigner File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -27,6 +27,8 @@ const ( | |
| defaultHost = "localhost" | ||
| defaultResolver = rpc | ||
| defaultGracePeriod = 5 | ||
| defaultRetryBackoffMs = 1000 | ||
| defaultRetryBackoffMaxMs = 120000 | ||
| defaultFatalStatusCodes = "" | ||
|
|
||
| rpc ResolverType = "rpc" | ||
|
|
@@ -47,6 +49,8 @@ const ( | |
| flagdOfflinePathEnvironmentVariableName = "FLAGD_OFFLINE_FLAG_SOURCE_PATH" | ||
| flagdTargetUriEnvironmentVariableName = "FLAGD_TARGET_URI" | ||
| flagdGracePeriodVariableName = "FLAGD_RETRY_GRACE_PERIOD" | ||
| flagdRetryBackoffMsVariableName = "FLAGD_RETRY_BACKOFF_MS" | ||
| flagdRetryBackoffMaxMsVariableName = "FLAGD_RETRY_BACKOFF_MAX_MS" | ||
| flagdFatalStatusCodesVariableName = "FLAGD_FATAL_STATUS_CODES" | ||
| ) | ||
|
|
||
|
|
@@ -69,6 +73,8 @@ type ProviderConfiguration struct { | |
| CustomSyncProviderUri string | ||
| GrpcDialOptionsOverride []grpc.DialOption | ||
| RetryGracePeriod int | ||
| RetryBackoffMs int | ||
| RetryBackoffMaxMs int | ||
| FatalStatusCodes []string | ||
|
|
||
| log logr.Logger | ||
|
|
@@ -84,6 +90,8 @@ func newDefaultConfiguration(log logr.Logger) *ProviderConfiguration { | |
| Resolver: defaultResolver, | ||
| Tls: defaultTLS, | ||
| RetryGracePeriod: defaultGracePeriod, | ||
| RetryBackoffMs: defaultRetryBackoffMs, | ||
| RetryBackoffMaxMs: defaultRetryBackoffMaxMs, | ||
| } | ||
|
|
||
| p.updateFromEnvVar() | ||
|
|
@@ -212,12 +220,10 @@ func (cfg *ProviderConfiguration) updateFromEnvVar() { | |
| if targetUri := os.Getenv(flagdTargetUriEnvironmentVariableName); targetUri != "" { | ||
| cfg.TargetUri = targetUri | ||
| } | ||
| if gracePeriod := os.Getenv(flagdGracePeriodVariableName); gracePeriod != "" { | ||
| if seconds, err := strconv.Atoi(gracePeriod); err == nil { | ||
| cfg.RetryGracePeriod = seconds | ||
| cfg.RetryGracePeriod = getIntFromEnvVarOrDefault(flagdGracePeriodVariableName, defaultGracePeriod, cfg.log) | ||
| } | ||
| } | ||
|
|
||
| cfg.RetryGracePeriod = getIntFromEnvVarOrDefault(flagdGracePeriodVariableName, defaultGracePeriod, cfg.log) | ||
| cfg.RetryBackoffMs = getIntFromEnvVarOrDefault(flagdRetryBackoffMsVariableName, defaultRetryBackoffMs, cfg.log) | ||
| cfg.RetryBackoffMaxMs = getIntFromEnvVarOrDefault(flagdRetryBackoffMaxMsVariableName, defaultRetryBackoffMaxMs, cfg.log) | ||
|
|
||
| var fatalStatusCodes string | ||
| if envVal := os.Getenv(flagdFatalStatusCodesVariableName); envVal != "" { | ||
|
|
@@ -431,6 +437,20 @@ func WithRetryGracePeriod(gracePeriod int) ProviderOption { | |
| } | ||
| } | ||
|
|
||
| // WithRetryBackoffMs sets the initial backoff duration (in milliseconds) for retrying failed connections | ||
| func WithRetryBackoffMs(retryBackoffMs int) ProviderOption { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. A parameter that represents a duration should be of type |
||
| return func(p *ProviderConfiguration) { | ||
| p.RetryBackoffMs = retryBackoffMs | ||
| } | ||
| } | ||
|
|
||
| // WithRetryBackoffMaxMs sets the maximum backoff duration (in milliseconds) for retrying failed connections | ||
| func WithRetryBackoffMaxMs(retryBackoffMaxMs int) ProviderOption { | ||
| return func(p *ProviderConfiguration) { | ||
| p.RetryBackoffMaxMs = retryBackoffMaxMs | ||
| } | ||
| } | ||
|
|
||
| // WithFatalStatusCodes allows to set a list of gRPC status codes, which will cause streams to give up | ||
| // and put the provider in a PROVIDER_FATAL state | ||
| func WithFatalStatusCodes(fatalStatusCodes []string) ProviderOption { | ||
|
|
||
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
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
62 changes: 62 additions & 0 deletions
62
providers/flagd/pkg/service/in_process/grpc_config_test.go
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
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
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
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
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
Oops, something went wrong.
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.
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.
Use time.ParseDuration to parse durations.