-
Notifications
You must be signed in to change notification settings - Fork 365
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
feat(translator): Implement BTP Timeout API #2454
Conversation
Codecov ReportAttention:
Additional details and impacted files@@ Coverage Diff @@
## main #2454 +/- ##
==========================================
- Coverage 64.70% 64.61% -0.09%
==========================================
Files 116 116
Lines 17613 17797 +184
==========================================
+ Hits 11396 11500 +104
- Misses 5486 5560 +74
- Partials 731 737 +6 ☔ View full report in Codecov by Sentry. |
|
||
} | ||
|
||
func SetBackendTrafficPolicyTranslationErrorCondition(policy *egv1a1.BackendTrafficPolicy, field, errMsg string) { |
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 use lower case here to make the func private - setBackend....
internal/ir/xds.go
Outdated
@@ -391,6 +391,8 @@ type HTTPRoute struct { | |||
ExtensionRefs []*UnstructuredRef `json:"extensionRefs,omitempty" yaml:"extensionRefs,omitempty"` | |||
// Circuit Breaker Settings | |||
CircuitBreaker *CircuitBreaker `json:"circuitBreaker,omitempty" yaml:"circuitBreaker,omitempty"` | |||
// Connection timeout Settings | |||
BackendTimeout *Timeout `json:"backendTimeout,omitempty" yaml:"backendTimeout,omitempty"` |
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.
prefer if this was renamed to Timeout
and we moved the existing Timeout
field into it and renamed it to RequestTimeout
under HTTP
internal/xds/translator/cluster.go
Outdated
if hasCommonHTTPOptions { | ||
protocolOptions.CommonHttpProtocolOptions = &corev3.HttpProtocolOptions{ | ||
IdleTimeout: durationpb.New(args.timeout.HTTP.ConnectionIdleTimeout.Duration), | ||
MaxConnectionDuration: durationpb.New(args.timeout.HTTP.MaxConnectionDuration.Duration), |
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.
these two duration should be checked (whether is nil ptr) before assign values toIdleTimeout
and MaxConnectionDuration
, nor it will raise a nil pointer panic.
http:
- name: "first-listener"
#...
routes:
- name: "first-route"
backendTimeout:
tcp:
connectTimeout: "31s"
http:
connectionIdleTimeout: "32s"
#maxConnectionDuration: "33s" # paniced
#...
8485b19
to
ab06b32
Compare
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, thanks
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.
This implementation LGTM, thanks!
A minor comment on the name of Timeout
structure in the API: we may want to change it to BackendTimeout
because the TCP ConnectTimeout
can't be reused for the future client-side Timeouts.
// BackendTimeout defines configuration for timeouts related to the backend.
type BackendTimeout struct {
// Timeout settings for TCP.
//
// +optional
TCP *TCPTimeout `json:"tcp,omitempty"`
// Timeout settings for HTTP.
//
// +optional
HTTP *HTTPTimeout `json:"http,omitempty"`
}
Can we translate this to transport socket timeout for downstream connections? If so, it can be reused... |
@@ -227,12 +227,20 @@ func (t *Translator) processHTTPRouteRules(httpRoute *HTTPRouteContext, parentRe | |||
|
|||
func processTimeout(irRoute *ir.HTTPRoute, rule gwapiv1.HTTPRouteRule) { | |||
if rule.Timeouts != nil { | |||
var rto *ir.Timeout | |||
|
|||
if irRoute.Timeout != nil { |
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: policy is computed/translated post route translation, so we can assume its empty here
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 wanted to this to be safe in case there's a re-arrangement of the computation order. If you feel that we can make this assumption, i'll update the implementation accordingly.
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.
sure, if thats the case, can you also add a comment here, so the next dev can understand why this done this way similar to the comment you have in policy around request timeout
d, err := time.ParseDuration(string(*pto.TCP.ConnectTimeout)) | ||
if err != nil { | ||
setBackendTrafficPolicyTranslationErrorCondition(policy, "TCP Timeout", fmt.Sprintf("invalid ConnectTimeout value %s", *pto.TCP.ConnectTimeout)) | ||
return nil |
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.
we should log error in status and continue processing instead of returning early here
d, err := time.ParseDuration(string(*pto.HTTP.ConnectionIdleTimeout)) | ||
if err != nil { | ||
setBackendTrafficPolicyTranslationErrorCondition(policy, "HTTP Timeout", fmt.Sprintf("invalid ConnectionIdleTimeout value %s", *pto.HTTP.ConnectionIdleTimeout)) | ||
return nil |
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.
same as above
d, err := time.ParseDuration(string(*pto.HTTP.MaxConnectionDuration)) | ||
if err != nil { | ||
setBackendTrafficPolicyTranslationErrorCondition(policy, "HTTP Timeout", fmt.Sprintf("invalid MaxConnectionDuration value %s", *pto.HTTP.MaxConnectionDuration)) | ||
return nil |
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.
same as above
@@ -14,4 +14,3 @@ | |||
name: first-route | |||
route: | |||
cluster: first-route-dest |
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.
what happened here, why did 5s get deleted ?
@@ -10,7 +10,8 @@ http: | |||
routes: | |||
- name: "first-route" | |||
hostname: "*" | |||
timeout: 5s | |||
timeout: | |||
requestTimeout: 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.
test is broken, probably needs below config
timeout:
http:
requestTimeout: 5s
Not sure about it, they look similar but not exactly the same. Are there any other possible different settings between client and backend timeouts? |
the go struct name can be changed anytime w/o breaking YAML API compatibility so no strong comments for now from my side |
ab06b32
to
f556086
Compare
Regarding E2E test for this feature: echo server does support a
One way to verify timeout settings with an e2e test is to trigger some upstream connections, wait for timeouts to occur and then check the relevant envoy cluster metrics. I propose to handle the e2e test in a dedicated issue. |
sure @guydc lets raise seperate GH issues for e2e and docs and tackle those in different PRs |
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 thanks !
Signed-off-by: Guy Daich <[email protected]>
f556086
to
ed5ca57
Compare
/retest |
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 thanks !
What this PR does / why we need it:
Implement the BackendTrafficPolicy Timeout API
Which issue(s) this PR fixes:
Fixes #2401