-
Notifications
You must be signed in to change notification settings - Fork 4.5k
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
serviceconfig: Return errors instead of skipping invalid retry policy config #7905
Conversation
service_config.go
Outdated
@@ -278,8 +278,7 @@ func convertRetryPolicy(jrp *jsonRetryPolicy, maxAttempts int) (p *internalservi | |||
jrp.MaxBackoff <= 0 || | |||
jrp.BackoffMultiplier <= 0 || | |||
len(jrp.RetryableStatusCodes) == 0 { | |||
logger.Warningf("grpc: ignoring retry policy %v due to illegal configuration", jrp) | |||
return nil, nil | |||
return nil, fmt.Errorf("invalid retry policy (%v): ", jrp) |
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.
I know this is existing code, but this seems to violate the style guide and is clearly hard to read given that the return statement is indented at the same width corresponding to the above conditional. See: go/go-style/decisions#conditional-formatting
Could we just move all the conditions into a single line?
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.
Also, should we use pretty.JSON
or a different formatting directive like %+v
or %#v
?
service_config_test.go
Outdated
scjs: `{ | ||
"methodConfig": [{ | ||
"name": [{"service": "foo"}], | ||
"retryPolicy": { | ||
"maxAttempts": 2, | ||
"initialBackoff": "2s", | ||
"maxBackoff": "10s", | ||
"backoffMultiplier": 2, | ||
"retryableStatusCodes": ["UNAVAILABLE"] | ||
} | ||
}] | ||
}`, |
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 we have this indented like how it is in other subtests.
service_config_test.go
Outdated
"retryableStatusCodes": ["UNAVAILABLE"] | ||
} | ||
}] | ||
}`, wantErr: true, |
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.
Nit: Here and elsewhere, can we have wantErr
on a separate line so that it is more readily visible.
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #7905 +/- ##
=======================================
Coverage 82.07% 82.07%
=======================================
Files 377 377
Lines 38179 38180 +1
=======================================
+ Hits 31335 31336 +1
- Misses 5545 5547 +2
+ Partials 1299 1297 -2
|
grpc/grpc-go#7905 requires that the number of retres to greater than 1. This is part of google.golang.org/[email protected] and this update makes tests to fail. Signed-off-by: Anastasios Papagiannis <[email protected]>
grpc/grpc-go#7905 requires that the number of retres to greater than 1. This is part of google.golang.org/[email protected] and this update makes tests to fail. Signed-off-by: Anastasios Papagiannis <[email protected]>
The grpc update to v1.70.0 and especially [1] requires retries to be > 1 in order to have a valid retry policy. As we already do +1 later, let's set the default to 1. [1] grpc/grpc-go#7905 Suggested-by: Anastasios Papagiannis <[email protected]> Signed-off-by: Jiri Olsa <[email protected]>
The grpc update to v1.70.0 and especially [1] requires retries to be > 1 in order to have a valid retry policy. As we already do +1 later, let's set the default to 1. [1] grpc/grpc-go#7905 Suggested-by: Anastasios Papagiannis <[email protected]> Signed-off-by: Jiri Olsa <[email protected]>
According to A21 and A6, an invalid retry policy should result in full service config rejection instead of just skipping the policy. This is a behavior change but also a bug fix.
RELEASE NOTES: