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

Add configurable timeouts to TransportServer #1346

Merged
merged 14 commits into from
Feb 9, 2021
Merged

Conversation

LorcanMcVeigh
Copy link
Contributor

Proposed changes

This PR adds support for proxy_connect_timeout, proxy_timeout, proxy_next_upstream, proxy_next_upstream_timeout and proxy_next_upstream_tries directives for TransportServers.

Checklist

Before creating a PR, run through this checklist and mark each as complete.

  • I have read the CONTRIBUTING doc
  • I have added tests that prove my fix is effective or that my feature works
  • I have checked that all unit tests pass after adding my changes
  • I have updated necessary documentation
  • I have rebased my branch onto master
  • I will ensure my PR is targeting the master branch and pulling from my branch from my own fork

docs-web/configuration/transportserver-resource.md Outdated Show resolved Hide resolved
docs-web/configuration/transportserver-resource.md Outdated Show resolved Hide resolved
docs-web/configuration/transportserver-resource.md Outdated Show resolved Hide resolved
pkg/apis/configuration/validation/transportserver_test.go Outdated Show resolved Hide resolved
pkg/apis/configuration/v1alpha1/types.go Outdated Show resolved Hide resolved
pkg/apis/configuration/v1alpha1/types.go Outdated Show resolved Hide resolved
pkg/apis/configuration/validation/transportserver.go Outdated Show resolved Hide resolved
pkg/apis/configuration/validation/transportserver.go Outdated Show resolved Hide resolved
@Dean-Coakley Dean-Coakley added the enhancement Pull requests for new features/feature enhancements label Feb 4, 2021
Copy link
Contributor

@pleshakov pleshakov left a comment

Choose a reason for hiding this comment

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

Hi @LorcanMcVeigh Please see my feedback

pkg/apis/configuration/v1alpha1/types.go Outdated Show resolved Hide resolved
parameters: &v1alpha1.SessionParameters{
Timeout: "60s",
},
msg: "",
Copy link
Contributor

Choose a reason for hiding this comment

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

valid timeout?

internal/configs/transportserver.go Show resolved Hide resolved
if nextUpstream {
nextUpstreamTries = transportServerEx.TransportServer.Spec.UpstreamParameters.NextUpstreamTries

if transportServerEx.TransportServer.Spec.UpstreamParameters.NextUpstreamTimeout != "" {
Copy link
Contributor

Choose a reason for hiding this comment

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

for cases when we check if a field is not empty (multiple places in this file), I suggest we use generateString from internal/configs/virtualserver.go:1325

nextUpstreamTimeout = generateString(TransportServer.Spec.UpstreamParameters.NextUpstreamTimeout, "0")

Because the function will be used both in virtualserver.go and here, better to put it in a new file, something like generation_helpers.go (and generation_helpers_test.go for unit tests).

Choose a reason for hiding this comment

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

Could be called something like stringWithDefaultValue().

docs-web/configuration/transportserver-resource.md Outdated Show resolved Hide resolved
docs-web/configuration/transportserver-resource.md Outdated Show resolved Hide resolved
docs-web/configuration/transportserver-resource.md Outdated Show resolved Hide resolved
LorcanMcVeigh and others added 3 commits February 8, 2021 11:41
Co-authored-by: Michael Pleshakov <pleshakov@users.noreply.github.com>
Copy link
Contributor

@Dean-Coakley Dean-Coakley left a comment

Choose a reason for hiding this comment

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

Re: #1346 (comment)
Makes sense to give the test case a name "Valid timeout", etc

LGTM overall.

}

connectTimeout = generateString(transportServerEx.TransportServer.Spec.UpstreamParameters.ConnectTimeout, "0")
Copy link
Contributor

Choose a reason for hiding this comment

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

here we have two default values for connectTimeout :

  1. "" - if transportServerEx.TransportServer.Spec.UpstreamParameters is nil
  2. "0" - if transportServerEx.TransportServer.Spec.UpstreamParameters isn't nil but TransportServer.Spec.UpstreamParameters.ConnectTimeout is "".

It looks like that because of that, you added addition ifs in the template:

   {{ if $s.ProxyConnectTimeout }}
    proxy_connect_timeout {{ $s.ProxyConnectTimeout }};
    {{ end }}

As you can see, having two default values makes things more complicated. Additionally, there is a bug - because the second default value "0" should be "60s".

Instead, we can have something like this:

	var connectTimeoutFieldVal string 
	if transportServerEx.TransportServer.Spec.UpstreamParameters != nil {
		connectTimeoutFieldVal = transportServerEx.TransportServer.Spec.UpstreamParameters.ConnectTimeout	
	}
	
	connectTimeout = generateString(connectTimeoutFieldVal, "60s") 

and in the template:

  proxy_connect_timeout {{ $s.ProxyConnectTimeout }};

That will be similar to what we have in VS:

		ProxyConnectTimeout:      generateString(upstream.ProxyConnectTimeout, cfgParams.ProxyConnectTimeout),

template:

        proxy_connect_timeout {{ $l.ProxyConnectTimeout }};

Could you also apply this approach to proxyTimeout ?

pkg/apis/configuration/validation/transportserver_test.go Outdated Show resolved Hide resolved
Copy link

@mikestephen mikestephen left a comment

Choose a reason for hiding this comment

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

Looks good Lorcan.

LorcanMcVeigh and others added 2 commits February 9, 2021 15:01
Co-authored-by: Michael Pleshakov <pleshakov@users.noreply.github.com>
@LorcanMcVeigh LorcanMcVeigh merged commit c1ca166 into master Feb 9, 2021
@LorcanMcVeigh LorcanMcVeigh deleted the ts-timeout-config branch February 9, 2021 23:03
@pleshakov pleshakov changed the title Add configurable timeouts to transportServer Add configurable timeouts to TransportServer Mar 16, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Pull requests for new features/feature enhancements
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants