Skip to content
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

Added configurable upstream connect timeout #4326

Merged
merged 6 commits into from
Feb 15, 2022

Conversation

tsaarni
Copy link
Member

@tsaarni tsaarni commented Feb 7, 2022

This change adds optional configurable timeout for upstream TCP connections. Currently Envoy is programmed with a hardcoded value of 2 seconds. With this change, user will be able to change this global timeout by setting a variable in the config file or ContourConfiguration.

Fixes #2264

Signed-off-by: Tero Saarni tero.saarni@est.tech

@tsaarni tsaarni requested a review from a team as a code owner February 7, 2022 14:32
@tsaarni tsaarni requested review from stevesloka and skriss and removed request for a team February 7, 2022 14:32
@tsaarni tsaarni added the release-note/small A small change that needs one line of explanation in the release notes. label Feb 7, 2022
Signed-off-by: Tero Saarni <tero.saarni@est.tech>
@codecov
Copy link

codecov bot commented Feb 7, 2022

Codecov Report

Merging #4326 (ade6c28) into main (15b2c6e) will increase coverage by 0.44%.
The diff coverage is 80.59%.

❗ Current head ade6c28 differs from pull request most recent head 5c7808e. Consider uploading reports for the commit 5c7808e to get more accurate results

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #4326      +/-   ##
==========================================
+ Coverage   77.84%   78.29%   +0.44%     
==========================================
  Files         112      112              
  Lines       10029    10052      +23     
==========================================
+ Hits         7807     7870      +63     
+ Misses       2043     2001      -42     
- Partials      179      181       +2     
Impacted Files Coverage Δ
cmd/contour/ingressstatus.go 34.78% <0.00%> (ø)
cmd/contour/serve.go 13.01% <16.66%> (+0.47%) ⬆️
internal/envoy/v3/cluster.go 98.63% <50.00%> (-1.37%) ⬇️
internal/debug/dot.go 54.54% <87.50%> (+54.54%) ⬆️
cmd/contour/servecontext.go 83.56% <100.00%> (+0.11%) ⬆️
internal/contourconfig/contourconfiguration.go 100.00% <100.00%> (ø)
internal/dag/cache.go 94.82% <100.00%> (+0.66%) ⬆️
internal/dag/dag.go 94.94% <100.00%> (ø)
internal/dag/extension_processor.go 95.18% <100.00%> (+0.05%) ⬆️
internal/dag/gatewayapi_processor.go 96.94% <100.00%> (+<0.01%) ⬆️
... and 11 more

@@ -463,6 +471,10 @@ func (t TimeoutParameters) Validate() error {
return fmt.Errorf("connection shutdown grace period %q: %w", t.ConnectionShutdownGracePeriod, err)
}

if err := v(t.ConnectTimeout); err != nil {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

using v() here will allow infinity as a valid timeout, which we probably don't want, as you mentioned elsewhere

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missed that, thanks @sunjayBhatia! Now fixed.

Signed-off-by: Tero Saarni <tero.saarni@est.tech>
Copy link
Member

@skriss skriss left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks reasonable to me, just a couple godoc nits

apis/projectcontour/v1alpha1/contourconfig.go Outdated Show resolved Hide resolved
pkg/config/parameters.go Outdated Show resolved Hide resolved
@sunjayBhatia sunjayBhatia self-requested a review February 9, 2022 20:47
Signed-off-by: Tero Saarni <tero.saarni@est.tech>
…nfig CRD to result in default timeout

Signed-off-by: Tero Saarni <tero.saarni@est.tech>
@tsaarni
Copy link
Member Author

tsaarni commented Feb 10, 2022

Looks reasonable to me, just a couple godoc nits

Thanks! I've fixed the field names.

I also realized that default 2s timeout was not taking place anymore with empty ContourConfiguration, which I fixed as well.

@sunjayBhatia
Copy link
Member

Looks reasonable to me, just a couple godoc nits

Thanks! I've fixed the field names.

I also realized that default 2s timeout was not taking place anymore with empty ContourConfiguration, which I fixed as well.

I guess similar to other discussions, do we want to have the default take place via kubebuilder as well?

"cluster with connect timeout set": {
cluster: &dag.Cluster{
Upstream: service(s1),
ConnectTimeout: 2 * time.Second,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: since the test merges the want and default cluster config, maybe use a different value to ensure theres no chance a mistake in implementation still makes this test pass

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch, changed to 10 seconds.

Copy link
Member

@sunjayBhatia sunjayBhatia left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just one small comment on a test but otherwise lgtm

Copy link
Member

@skriss skriss left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM pending Sunjay's comment

@youngnick
Copy link
Member

Let's bring this in without a kubebuilder default for now, and I'll come back to what we can do there next week.

Signed-off-by: Tero Saarni <tero.saarni@est.tech>
Signed-off-by: Tero Saarni <tero.saarni@est.tech>
@tsaarni
Copy link
Member Author

tsaarni commented Feb 14, 2022

In addition to fixing @sunjayBhatia's comment I've also added connect timeout to contourconfiguration_test.go for coverage improvement.

@tsaarni tsaarni merged commit aa134a2 into projectcontour:main Feb 15, 2022
tsaarni added a commit to Nordix/contour that referenced this pull request Apr 20, 2022
* Added configurable upstream connect timeout

Signed-off-by: Tero Saarni <tero.saarni@est.tech>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
release-note/small A small change that needs one line of explanation in the release notes.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Unable to change connect_timeout in Envoy config
4 participants