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

Allow Ability to Configure Upstream Keepalive #3222

Merged
merged 2 commits into from
Oct 12, 2018

Conversation

diazjf
Copy link

@diazjf diazjf commented Oct 11, 2018

Allows Upstream Keepalive values like keepalive_timeout and keepalive_requests to be configured via ConfigMap.

Fixes #3099

@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label Oct 11, 2018
@k8s-ci-robot k8s-ci-robot added the size/S Denotes a PR that changes 10-29 lines, ignoring generated files. label Oct 11, 2018
@diazjf
Copy link
Author

diazjf commented Oct 11, 2018

/hold

@k8s-ci-robot k8s-ci-robot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Oct 11, 2018
@diazjf
Copy link
Author

diazjf commented Oct 11, 2018

Need Documentation and Tests.

@diazjf diazjf force-pushed the add-timeouts-and-such branch from 45dcfce to 2d405aa Compare October 11, 2018 03:23
@k8s-ci-robot k8s-ci-robot added size/M Denotes a PR that changes 30-99 lines, ignoring generated files. and removed size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels Oct 11, 2018
@diazjf
Copy link
Author

diazjf commented Oct 11, 2018

Default without any changes:

upstream upstream_balancer {
                server 0.0.0.1; # placeholder
                
                balancer_by_lua_block {
                        balancer.balance()
                }
                
                keepalive 32;
                
                keepalive_timeout  60s;
                keepalive_requests 100;
        }

@diazjf diazjf force-pushed the add-timeouts-and-such branch from 9ad6a01 to 849fe53 Compare October 11, 2018 04:08
@diazjf
Copy link
Author

diazjf commented Oct 11, 2018

Adding to ConfigMap:

upstream-keepalive-requests: "200"
upstream-keepalive-timeout: "90"

Provides:

upstream upstream_balancer {
                server 0.0.0.1; # placeholder
                
                balancer_by_lua_block {
                        balancer.balance()
                }
                
                keepalive 32;
                
                keepalive_timeout  90s;
                keepalive_requests 200;
        }

@diazjf
Copy link
Author

diazjf commented Oct 11, 2018

/hold remove

@diazjf
Copy link
Author

diazjf commented Oct 11, 2018

/hold cancel

@k8s-ci-robot k8s-ci-robot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Oct 11, 2018
@diazjf
Copy link
Author

diazjf commented Oct 11, 2018

When providing the following values:

upstream-keepalive-requests: 200yeah
upstream-keepalive-timeout: 90s

the defaults are retained.

@diazjf
Copy link
Author

diazjf commented Oct 11, 2018

/assign @ElvinEfendi

@@ -99,6 +99,8 @@ The following table shows a configuration option's name, type, and the default v
|[variables-hash-bucket-size](#variables-hash-bucket-size)|int|128|
|[variables-hash-max-size](#variables-hash-max-size)|int|2048|
|[upstream-keepalive-connections](#upstream-keepalive-connections)|int|32|
|[upstream-keep-alive](#upstream-keep-alive)|int|60s|
Copy link
Member

Choose a reason for hiding this comment

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

Could you stick to the existing naming convention of keepalive rather than keep-alive? That'll also be consistent with Nginx's naming of respective directives.

Copy link
Member

Choose a reason for hiding this comment

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

|int|60s|

I think the default here should be 60 instead of 60s no? For example keep-alive setting accepts only integer, and when you provide something like 60s it logs an error and uses default value.

Copy link
Author

Choose a reason for hiding this comment

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

Nice catch! Forgot to change this part.

UpstreamKeepaliveConnections int `json:"upstream-keepalive-connections,omitempty"`

// Sets a timeout during which an idle keepalive connection to an upstream server will stay open.
// http://nginx.org/en/docs/http/ngx_http_upstream_module.html#keepalive_timeout
UpstreamKeepAliveTimeOut int `json:"upstream-keepalive-timeout,omitempty"`
Copy link
Member

Choose a reason for hiding this comment

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

please use Timeout instead of TimeOut, the latter is not consistent with the naming style in the rest of code base

Copy link
Member

Choose a reason for hiding this comment

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

same goes to KeepAlive -> Keepalive

Copy link
Author

Choose a reason for hiding this comment

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

Makes sense for consistency.

@@ -417,6 +417,9 @@ http {
{{ if (gt $cfg.UpstreamKeepaliveConnections 0) }}
keepalive {{ $cfg.UpstreamKeepaliveConnections }};
{{ end }}

keepalive_timeout {{ $cfg.UpstreamKeepAliveTimeOut }}s;
keepalive_requests {{ $cfg.UpstreamKeepAliveRequests }};
Copy link
Member

Choose a reason for hiding this comment

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

should this not be inside the if condition above?

Copy link
Author

Choose a reason for hiding this comment

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

It does make the configuration cleaner!

@diazjf diazjf force-pushed the add-timeouts-and-such branch from 0d9e38f to 91a9f2e Compare October 12, 2018 01:43
Allows Upstream Keepalive values like keepalive_timeout and
keepalive_requests to be configured via ConfigMap.

Fixes kubernetes#3099
@diazjf diazjf force-pushed the add-timeouts-and-such branch from 91a9f2e to 12955a4 Compare October 12, 2018 01:46
Removes unneeded ConfigMaps from the Development Environment which
are causing ingress-nginx pods to crash

Fixes kubernetes#3223
@ElvinEfendi
Copy link
Member

/lgtm
/approve

side note: it would be great to have an e2e test for configmap where we use all existing settings and assert they are reflected in Nginx config.

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Oct 12, 2018
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: diazjf, ElvinEfendi

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Oct 12, 2018
@k8s-ci-robot k8s-ci-robot merged commit 0baf62d into kubernetes:master Oct 12, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. lgtm "Looks good to me", indicates that a PR is ready to be merged. size/M Denotes a PR that changes 30-99 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants