Skip to content

Add SO_KEEPALIVE option for upstream connections.#614

Closed
JonathanO wants to merge 6 commits intoenvoyproxy:masterfrom
JonathanO:add-tcp-keepalive-option
Closed

Add SO_KEEPALIVE option for upstream connections.#614
JonathanO wants to merge 6 commits intoenvoyproxy:masterfrom
JonathanO:add-tcp-keepalive-option

Conversation

@JonathanO
Copy link
Copy Markdown
Contributor

Config changes to support envoyproxy/envoy#3028

Signed-off-by: Jonathan Oddy jonathan.oddy@transferwise.com

Config changes to support envoyproxy/envoy#3028

Signed-off-by: Jonathan Oddy <jonathan.oddy@transferwise.com>
@JonathanO JonathanO force-pushed the add-tcp-keepalive-option branch from d32fefb to 9d38f06 Compare April 9, 2018 14:32
google.protobuf.BoolValue freebind = 2;

// If set then set SO_KEEPALIVE on the socket to enable TCP Keepalives.
TcpKeepalive tcp_keepalive = 3;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Is this tied to the prebind configuration? Or can it be set at any time (e.g. post bind, after listen(), etc)?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

My current implementation is only applicable to upstream connections, and is therefore prebind since ClientConnectionImpl only invokes PreBind.
Making it usable for inbound connections will be a bit more work, since I believe the options would need to be set on the newly accept()ed socket rather than the listen() socket, and there's no existing pattern for doing that.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I still have a uncomfortable feeling about this grouping. So far, BindConfig is all the socket address binding config, this is more of a general connection property. Can we make this a new ConnectionOptions message that belongs to Cluster?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

FWIW, I'm going to eventually add keepalive settings on listeners too. So having these in a separate message makes sense to me. But we could put this message into a ConnectionOptions.

Copy link
Copy Markdown
Member

@mattklein123 mattklein123 left a comment

Choose a reason for hiding this comment

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

LGTM other than some small nits and @htuch question.

* tracing: the sampling decision is now delegated to the tracers, allowing the tracer to decide when and if
to use it. For example, if the :ref:`x-b3-sampled <config_http_conn_man_headers_x-b3-sampled>` header
is supplied with the client request, its value will override any sampling decision made by the Envoy proxy.
* sockets: added `SO_KEEPALIVE` socket option for upstream connections via :ref:`cluster manager wide
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

nit: alpha order

message TcpKeepalive {
// Maximum number of keepalive probes to send without response before deciding
// the connection is dead. Default is to use the OS level configuration (unless
// overridden, Linux defaults to 9.)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

nit: extra " " after ,

Signed-off-by: Jonathan Oddy <jonathan.oddy@transferwise.com>
Allows a cluster to disable keepalive that was enabled by default on the
cluster manager.

Signed-off-by: Jonathan Oddy <jonathan.oddy@transferwise.com>
@JonathanO JonathanO force-pushed the add-tcp-keepalive-option branch from e20c195 to b60ba8a Compare April 10, 2018 12:43
JonathanO added a commit to JonathanO/envoy that referenced this pull request Apr 10, 2018
Adds support for configuring TCP Keepalives on upstream connections.
Resolves envoyproxy#3028

Requires envoyproxy/data-plane-api#614

Signed-off-by: Jonathan Oddy <jonathan.oddy@transferwise.com>
google.protobuf.UInt32Value keepalive_interval = 3;
// Flag to explicitly disable keepalive probes, allows overriding of settings
// inherited by a cluster from the cluster manager. Default is false.
google.protobuf.BoolValue disable = 4;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This should be just bool as it default false.

As per code review comments, this doesn't belong with BindConfig.
Rather than introduce ConnectionOptions I decided to split it into a
specific UpstreamConnectionOptions as I suspect that, other than
keepalive, there will be little commonality between listen and upstream
connection options in the future.

I didn't really know where to put the TcpKeepalive message though, so
left it in address.pb for now. It will be common to listen and upstream
connection options.

Changed disabled flag to bool type.

Signed-off-by: Jonathan Oddy <jonathan.oddy@transferwise.com>
Signed-off-by: Jonathan Oddy <jonathan.oddy@transferwise.com>
core.Address source_address = 1;
}

message UpstreamConnectionOptions {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM, but I'd rename the message to just ConnectionOptions, since we might want to reuse this elsewhere, e.g. health check connections etc.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I think the health checks will inherit these options from the cluster already in my implementation.
I didn't want to call it ConnectionOptions, as I suspect we'll want a similar, but not identical, message for accept()ed connections.
Perhaps ClusterConnectionOptions?


// Optional options for upstream connections.
// This may be overridden on a per-cluster basis by upstream_connection_options in the cds_config.
envoy.api.v2.UpstreamConnectionOptions upstream_connection_options = 5;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

It is preferable to omit this. Envoy doesn't in general do hierarchical config, in the sense of setting an option at a higher level and overriding later.

This has been handled inconsistently (for instance bind config). But unless there's a compelling reason, please remove this (and "bool disable = 4" from the TcpKeepalive message).

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

OK. I don't have a particularly good excuse for wanting this, and removing it will simplify the code a little, so I'll remove it.

Signed-off-by: Jonathan Oddy <jonathan.oddy@transferwise.com>
@htuch
Copy link
Copy Markdown
Member

htuch commented Apr 16, 2018

@JonathanO we're going to have to continue this in envoyproxy/envoy post envoyproxy/envoy#2934, which should land today. The upside is that this can be rolled into your existing PR there.

@htuch
Copy link
Copy Markdown
Member

htuch commented Apr 16, 2018

@htuch htuch closed this Apr 16, 2018
htuch pushed a commit to envoyproxy/envoy that referenced this pull request Apr 29, 2018
Adds TCP Keepalive support for upstream connections. This can be configured on the cluster manager level, and overridden on the cluster level.

Risk Level: Medium

Testing:
Unit tests have been added. It appears to run and work.

Docs Changes:
envoyproxy/data-plane-api#614

Fixes #3028

API Changes:
envoyproxy/data-plane-api#614

Signed-off-by: Jonathan Oddy <jonathan.oddy@transferwise.com>
mattklein123 pushed a commit that referenced this pull request Apr 29, 2018
Adds TCP Keepalive support for upstream connections. This can be configured on the cluster manager level, and overridden on the cluster level.

Risk Level: Medium

Testing:
Unit tests have been added. It appears to run and work.

Docs Changes:
#614

Fixes envoyproxy/envoy#3028

API Changes:
#614

Signed-off-by: Jonathan Oddy <jonathan.oddy@transferwise.com>

Mirrored from https://github.com/envoyproxy/envoy @ dd953f99945bb7c6b3251f71bffe252a5f6e9e62
ramaraochavali pushed a commit to ramaraochavali/envoy that referenced this pull request May 3, 2018
…#3042)

Adds TCP Keepalive support for upstream connections. This can be configured on the cluster manager level, and overridden on the cluster level.

Risk Level: Medium

Testing:
Unit tests have been added. It appears to run and work.

Docs Changes:
envoyproxy/data-plane-api#614

Fixes envoyproxy#3028

API Changes:
envoyproxy/data-plane-api#614

Signed-off-by: Jonathan Oddy <jonathan.oddy@transferwise.com>

Signed-off-by: Rama <rama.rao@salesforce.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants