-
Notifications
You must be signed in to change notification settings - Fork 3.3k
add documentation for the server & client side timeout #1467
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
Merged
roycaihw
merged 1 commit into
kubernetes-client:master
from
Priyankasaggu11929:documet-server-and-client-side-timeout
Jul 15, 2021
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
|
||
**This documentation briefly provides information about the `server side` & `client side` connection timeout settings, in the watch request handler.** | ||
|
||
--- | ||
|
||
There are two inputs available in the client, that could be used to set connection timeouts: | ||
|
||
- `timeout_seconds` | ||
- `_request_timeout` | ||
|
||
--- | ||
|
||
#### Sever-side timeout (`kwargs['timeout_seconds'] = n`) | ||
|
||
- The value of the argument `timeout_seconds`, **n**, (which is time duration in seconds) is consumed at the server side. It is included in the request URL to the server. | ||
|
||
*For eg.* ~ `https://localhost:6443/api/v1/namespaces/default/pods?labelSelector=app%3Ddemo&timeoutSeconds=100&watch=True` | ||
|
||
- In case, if the `timeout_seconds` value is set, the value `n` would determine the server-side connection timeout duration. | ||
|
||
*For eg.* ~ if `kwargs['timeout_seconds'] = 3600`, then the server-side connection timeout will be equal to 1 hour. | ||
|
||
This timeout duration is determined by the expression ~ `timeout = time.Duration(3600) * time.seconds`, *i.e.* `timeout = 1 hour` | ||
|
||
***Refer:*** | ||
- *[https://github.com/kubernetes/apiserver/blob/release-1.20/pkg/endpoints/handlers/get.go#L254](https://github.com/kubernetes/apiserver/blob/release-1.20/pkg/endpoints/handlers/get.go#L254)* | ||
|
||
- In case, if the `timeout_seconds` value is not set, then the connection timeout will be a randomized value (in seconds) between `minRequestTimeout` and 2*`minRequestTimeout`, to spread out the load. | ||
|
||
It is determined using the expression ~ `timeout = time.Duration(float64(minRequestTimeout) * (rand.Float64() + 1.0))` | ||
|
||
Where `minRequestTimeout` indicates the minimum number of seconds a handler must keep a request open before timing it out. | ||
|
||
The default value of `minRequestTimeout` is 1800 seconds. | ||
|
||
***Refer:*** | ||
- *[https://github.com/kubernetes/apiserver/blob/release-1.20/pkg/endpoints/handlers/get.go#L257](https://github.com/kubernetes/apiserver/blob/release-1.20/pkg/endpoints/handlers/get.go#L257)* | ||
- *[https://github.com/kubernetes/kubernetes/blob/release-1.20/staging/src/k8s.io/apiserver/pkg/server/config.go#L320](https://github.com/kubernetes/kubernetes/blob/release-1.20/staging/src/k8s.io/apiserver/pkg/server/config.go#L320)* | ||
|
||
- In case of a network outage, the server side timeout value will have no effect & the client will hang indefinitely without raising any exception. Note, that this is the case provided when there is no other client-side timeout (i.e., `_request_timeout`) value specified. | ||
|
||
(*See the section below for information on `client side timeout`*) | ||
|
||
- It is recommended to set this timeout value to a higher number such as 3600 seconds (1 hour). | ||
|
||
--- | ||
|
||
#### Client-side timeout (`kwargs['_request_timeout'] = n`) | ||
|
||
- The value of the argument `_request_timeout`, **n** (which is time duration in seconds) is set to the socket used for the connection. | ||
|
||
- In case, if the `_request_timeout` value is set, this argument can accept 2 types of input values ~ | ||
- float, | ||
- a tuple (with a length of 2) | ||
|
||
***Refer*** | ||
- *[https://github.com/kubernetes-client/python/blob/v17.17.0/kubernetes/client/api_client.py#L336-L339](https://github.com/kubernetes-client/python/blob/v17.17.0/kubernetes/client/api_client.py#L336-L339)* | ||
|
||
- In case of network outage, leading to dropping all packets with no RST/FIN, the timeout value (in seconds) determined by the `request_timeout` argument, would be the time duration for how long the client will wait before dropping the connection. | ||
|
||
- When the timeout happens, an exception will be raised, for eg. ~ | ||
|
||
`urllib3.exceptions.ReadTimeoutError: HTTPSConnectionPool(host='localhost', port=6443): Read timed out.` | ||
|
||
- In case, if the `_request_timeout` value is not set, then the default value is **`None`** & socket will have no timeout. | ||
|
||
***Refer:*** | ||
- *[https://docs.python.org/3/library/socket.html#socket.getdefaulttimeout](https://docs.python.org/3/library/socket.html#socket.getdefaulttimeout)* | ||
|
||
- It is recommended to set this timeout value to a lower number (for eg. ~ maybe 60 seconds). | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.