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 support for keep alive timeouts #513

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open

added support for keep alive timeouts #513

wants to merge 4 commits into from

Conversation

khchau7
Copy link

@khchau7 khchau7 commented Aug 12, 2021

See #512: Fix in response to watch pods timing out and not recognizing any new notices after about 30 minutes of no new watch events.

@khchau7 khchau7 changed the title added support for keep alive timeouts #512 added support for keep alive timeouts Aug 12, 2021
@@ -11,6 +11,7 @@ def initialize(uri, http_options, formatter:)
@http_client = nil
@http_options = http_options
@http_options[:http_max_redirects] ||= Kubeclient::Client::DEFAULT_HTTP_MAX_REDIRECTS
@http_options[:keep_alive_timeout] = 60

Choose a reason for hiding this comment

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

this should be like this, this way you can set the value if its being set otherwise it will be default.

@http_options[:keep_alive_timeout] || = Kubeclient::Client::DEFAULT_KEEP_ALIVE_TIMEOUT

Choose a reason for hiding this comment

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

keep_alive_timeout only set if its passed in otherwise this shouldnt set to keep no changes to existing behavior.

@ganga1980
Copy link

Hi, @cben, can you please review this PR and helping on merging this PR as @khchau7 blocked on this for her project?

@@ -53,6 +53,7 @@ class Client

DEFAULT_HTTP_PROXY_URI = nil
DEFAULT_HTTP_MAX_REDIRECTS = 10
DEFAULT_KEEP_ALIVE_TIMEOUT = 60
Copy link
Collaborator

Choose a reason for hiding this comment

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

The default of http gem seems to be 5 seconds: https://github.com/httprb/http/blob/v4.4.1/lib/http/options.rb#L63

I open to setting it higher by default if that's good for k8s watch connections.
This effectively controls how long we keep the watch open when server has no updates, right?
Do you know what's the default in Go or other k8s clients?

OTOH if we're not sure what's best value, we can set it 5 here to keep existing behavior, this PR will let users experiment...

@cben
Copy link
Collaborator

cben commented Aug 17, 2021

Is this really controlling what #512 describes?
https://github.com/httprb/http/blob/v4.4.1/lib/http/connection.rb#L184-L188
https://github.com/httprb/http/blob/v4.4.1/lib/http/client.rb#L113-L116
seems it affects Ruby-level logic closing connection on inactivity, not TCP-level keepalive?

Generally, I'm not against exposing more options 👍. We can merge this first and let people experiment with optimal settings.
Note however that sooner or later, we'd like to replace http with faraday: #488 — does this setting have a parallel in faraday?
If raising the timeout helps but the problem is specific to http gem, then perhaps we should just set it higher but not expose as new knob.

If you believe this is correct approach, please add a mention of the new option in README and add a CHANGELOG entry (in "Unreleased" section, which is currently horribly incomplete).

@@ -287,6 +287,7 @@ def define_entity_methods
# This method used to take resource_version as a param, so
# this conversion is to keep backwards compatibility
options = { resource_version: options } unless options.is_a?(Hash)
options[timeoutSeconds] = 380 # 6 mins 20 seconds
Copy link
Collaborator

Choose a reason for hiding this comment

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

Did you mean :timeoutSeconds ?
This will override any passed-in timeout. I'm assuming you're just experimenting for now, but this can't be merged.

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.

3 participants