-
Notifications
You must be signed in to change notification settings - Fork 3.5k
Support _request_timeout in dynamic client watch() #2533
Description
Problem
When using the dynamic client’s watch() method:
api = self._client.resources.get(
api_version=self._api_version,
kind=self._kind
)
for event in api.watch(
timeout=server_timeout_seconds,
)
there is currently no way to configure a client-side request timeout (_request_timeout).
Current Workaround
To enforce a client-side timeout, we have to bypass Resource.watch() and directly use Watch().stream():
for raw_event in Watch().stream(
api.get,
serialize=False,
deserialize=False,
timeout_seconds=self._server_timeout_seconds,
_request_timeout=self._client_timeout_seconds,
)
Issue
The dynamic client’s watch() method internally relies on Watch().stream() but does not expose _request_timeout as a parameter: https://github.com/kubernetes-client/python/blob/master/kubernetes/base/dynamic/client.py#L203
This creates:
Inconsistent API ergonomics
Unnecessary duplication of logic for users needing client-side timeouts
Proposed Solution
Extend Resource.watch() to accept an optional _request_timeout parameter and pass it through to the underlying Watch().stream() call.
Example:
api.watch(
timeout=server_timeout_seconds,
_request_timeout=(connect_timeout, read_timeout),
)