-
Notifications
You must be signed in to change notification settings - Fork 703
internal: Allow retry policy, num retries to be zero #4117
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
Conversation
Codecov Report
@@ Coverage Diff @@
## main #4117 +/- ##
==========================================
+ Coverage 74.63% 74.66% +0.03%
==========================================
Files 112 112
Lines 9709 9722 +13
==========================================
+ Hits 7246 7259 +13
Misses 2307 2307
Partials 156 156
|
apis/projectcontour/v1/httpproxy.go
Outdated
| // +optional | ||
| // +kubebuilder:validation:Minimum=0 | ||
| NumRetries int64 `json:"count"` | ||
| NumRetries *int64 `json:"count"` |
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.
My only concern here is that this is a breaking change from a Go perspective, since the type is changing, even though it's backwards compatible from a YAML perspective. I don't think we've been 100% explicit on whether something like this is allowed or not, currently looking for any Kubernetes guidance on this..
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.
Yeah I don't know if it's a big deal or not. The meaning of the variable isn't changing.
The alternatives would be to bump the api version, or add a new field like countZero: true or something would be confusing.
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.
Another option, we could do something silly for now like make -1 mean "no retries" and leave 0 as "use Envoy default" (e.g. 1), and then clean it up in the v2 API.
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.
Or we could do some kubebuilder defaulting tricks: default to adding a retryPolicy to every HTTPProxy with a count of 1, and then change the behavior when retryPolicy.count = 0 to actually pass 0 to Envoy. This should keep the default behavior as 1 retry, while allowing an explicit 0 to be specified.
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.
Let me play with the kubebuilder route and see if that route would work.
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 guess one problem with the kubebuilder approach is pre-existing HTTPProxies would not get the default populated, so their behavior would end up changing. It would only apply to new HTTPProxies.
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.
Yeah. hmm. Maybe the -1 route is the most straight forward and we can disable from setting the value to zero in kubebuilder validation.
9535e4e to
fd0d3e2
Compare
Since the current field for NumRetries is not a pointer, Contour doesn't have a good way to understand if the field is unspecified, or set to zero. To keep the v1 API contract, Contour will allow this field to be set to -1 which means the numRetries should be zero. If unspecified or set to zero, then the Envoy default of 1 is used. Signed-off-by: Steve Sloka <[email protected]>
fd0d3e2 to
dc3e79e
Compare
Signed-off-by: Steve Sloka <[email protected]>
| - `retryPolicy`: A retry will be attempted if the server returns an error code in the 5xx range, or if the server takes more than `retryPolicy.perTryTimeout` to process a request. | ||
|
|
||
| - `retryPolicy.count` specifies the maximum number of retries allowed. This parameter is optional and defaults to 1. | ||
| - `retryPolicy.count` specifies the maximum number of retries allowed. This parameter is optional and defaults to 1. Set to -1 to disable. If set to 0, the Envoy default of 1 is used. |
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.
given we say "defaults to 1" might also be instructive to users to set the kubebuilder default to 1 so they see it in their YAML as well if not set? regardless with how we've implemented you do end up with a default of 1
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 think this makes sense, would make things a bit more obvious for the default case.
sunjayBhatia
left a comment
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.
just some small nits, only slightly bigger change could be to add the kubebuilder default to 1 so we don't end up with new resources with retries count=0, but the -1 seems like it works otherwise since disabling retries was what people wanted
in Contour's Config CRD we should maybe make an issue to make the relevant field a pointer (to unsigned int 👀 ) early so we don't have to deal with this again!
Signed-off-by: Steve Sloka <[email protected]>
Signed-off-by: Steve Sloka <[email protected]>
Signed-off-by: Steve Sloka <[email protected]>
skriss
left a comment
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.
LGTM, I think this is a reasonable way to approach given API compatibility constraints.
| - `retryPolicy`: A retry will be attempted if the server returns an error code in the 5xx range, or if the server takes more than `retryPolicy.perTryTimeout` to process a request. | ||
|
|
||
| - `retryPolicy.count` specifies the maximum number of retries allowed. This parameter is optional and defaults to 1. | ||
| - `retryPolicy.count` specifies the maximum number of retries allowed. This parameter is optional and defaults to 1. Set to -1 to disable. If set to 0, the Envoy default of 1 is used. |
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 think this makes sense, would make things a bit more obvious for the default case.
…4117) Since the current field for NumRetries is not a pointer, Contour doesn't have a good way to understand if the field is unspecified, or set to zero. To keep the v1 API contract, Contour will allow this field to be set to -1 which means the numRetries should be zero. If unspecified or set to zero, then the Envoy default of 1 is used. Signed-off-by: Steve Sloka <[email protected]>
…4117) (#4135) Since the current field for NumRetries is not a pointer, Contour doesn't have a good way to understand if the field is unspecified, or set to zero. To keep the v1 API contract, Contour will allow this field to be set to -1 which means the numRetries should be zero. If unspecified or set to zero, then the Envoy default of 1 is used. Signed-off-by: Steve Sloka <[email protected]>
Since the current field for NumRetries is not a pointer, Contour doesn't have a good way to understand if the field is unspecified, or set to zero. To keep the v1 API contract, Contour will allow this field to be set to -1 which means the numRetries should be zero. If unspecified or set to zero, then the Envoy default of 1 is used. Signed-off-by: Steve Sloka <[email protected]>
…4117) Since the current field for NumRetries is not a pointer, Contour doesn't have a good way to understand if the field is unspecified, or set to zero. To keep the v1 API contract, Contour will allow this field to be set to -1 which means the numRetries should be zero. If unspecified or set to zero, then the Envoy default of 1 is used. Signed-off-by: Steve Sloka <[email protected]>
#4174) * internal: Allow retry policy, num retries to be zero (#4117) Since the current field for NumRetries is not a pointer, Contour doesn't have a good way to understand if the field is unspecified, or set to zero. To keep the v1 API contract, Contour will allow this field to be set to -1 which means the numRetries should be zero. If unspecified or set to zero, then the Envoy default of 1 is used. Signed-off-by: Steve Sloka <[email protected]> Co-authored-by: Nick Young <[email protected]>
The field, NumRetries (e.g. count), in the RetryPolicy allows for a zero to be
specified, however Contour's internal logic would see that as "undefined"
and set it back to the Envoy default of 1.
This checks for the existance of the variable and uses the value specified,
otherwise defaults to 1 matching Envoy.
Signed-off-by: Steve Sloka [email protected]