Skip to content

Commit

Permalink
feat: add timeout_seconds option to Kubeclient::Client#watch_entities
Browse files Browse the repository at this point in the history
  • Loading branch information
jperville committed Nov 22, 2023
1 parent 054bff2 commit b25df1d
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 6 deletions.
9 changes: 8 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,14 @@ client = Kubeclient::Client.new(

### Timeouts

Watching configures the socket to never time out (however, sooner or later all watches terminate).
Watching configures the socket to never time out by default (however, sooner or later all watches terminate).

Even if watches never time out (on the client side), it is possible to force watches to have a maximum duration (on the server side):
```ruby
client.watch_pods(timeout_seconds: 120, namespace: 'myns') do |notice|
...
end
```

One-off actions like `.get_*`, `.delete_*` have a configurable timeout:
```ruby
Expand Down
12 changes: 7 additions & 5 deletions lib/kubeclient.rb
Original file line number Diff line number Diff line change
Expand Up @@ -77,10 +77,11 @@ class Client
}.freeze

WATCH_ARGUMENTS = {
'labelSelector' => :label_selector,
'fieldSelector' => :field_selector,
'resourceVersion' => :resource_version,
'allowWatchBookmarks' => :allow_watch_bookmarks
'labelSelector' => :label_selector,
'fieldSelector' => :field_selector,
'resourceVersion' => :resource_version,
'allowWatchBookmarks' => :allow_watch_bookmarks,
'timeoutSeconds' => :timeout_seconds
}.freeze

attr_reader :api_endpoint
Expand Down Expand Up @@ -408,6 +409,7 @@ def faraday_client
# :label_selector (string) - a selector to restrict the list of returned objects by labels.
# :field_selector (string) - a selector to restrict the list of returned objects by fields.
# :resource_version (string) - shows changes that occur after passed version of a resource.
# :timeout_seconds (integer) - limits the duration of the call
# :as (:raw|:ros) - defaults to :ros
# :raw - return the raw response body as a string
# :ros - return a collection of RecursiveOpenStruct objects
Expand Down Expand Up @@ -493,7 +495,7 @@ def delete_entity(resource_name, name, namespace = nil, delete_options: {})
# :resource_version (string) - sets a limit on the resource versions that can be served
# :resource_version_match (string) - determines how the resource_version constraint
# will be applied
# :timeout_seconds (integer) - limits the duraiton of the call
# :timeout_seconds (integer) - limits the duration of the call
# :continue (string) - a token used to retrieve the next chunk of entities
# :as (:raw|:ros) - defaults to :ros
# :raw - return the raw response body as a string
Expand Down

0 comments on commit b25df1d

Please sign in to comment.