Skip to content

Commit

Permalink
fix unspecified dynamic client watch timeout (#320)
Browse files Browse the repository at this point in the history
Currently, when a dynamic client watcher is used, timeout_seconds is
always passed to watcher.stream() from DynamicClient.watch(). Its value
is None when the timeout argument was not passed by the user.

The current check done on TimeoutError in the Watch.watch() method when
awaiting from self.resp.content.readline() prevents to reopen the
request in this case because it behaves differently if timeout_seconds
was set to None or if timeout_seconds was not passed to the function.

Do not pass the timeout_seconds argument in DynamicClient.watch() if
timeout was not specified by the user.

Signed-off-by: Olivier Matz <olivier.matz@6wind.com>
  • Loading branch information
olivier-matz-6wind authored Jul 23, 2024
1 parent 03f4dd8 commit b7ec53c
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion kubernetes_asyncio/dynamic/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -214,14 +214,18 @@ async def watch(resource, namespace=None, name=None, label_selector=None, field_
if name:
field_selector = f"metadata.name={name}"

kwargs = {}
if timeout is not None:
kwargs['timeout_seconds'] = timeout

async for event in watcher.stream(
resource.get,
namespace=namespace,
field_selector=field_selector,
label_selector=label_selector,
resource_version=resource_version,
serialize=False,
timeout_seconds=timeout
**kwargs
):
event['object'] = ResourceInstance(resource, event['object'])
yield event
Expand Down

0 comments on commit b7ec53c

Please sign in to comment.