Skip to content
This repository has been archived by the owner on Sep 14, 2020. It is now read-only.

Commit

Permalink
Merge pull request #144 from nolar/pykube-timeouts
Browse files Browse the repository at this point in the history
Disable socket timeouts for internal request, especially for watching
  • Loading branch information
Sergey Vasilyev committed Jul 12, 2019
2 parents 700c7d1 + a72dbad commit 17c9871
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 4 deletions.
2 changes: 1 addition & 1 deletion kopf/clients/auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,5 +134,5 @@ def get_pykube_cfg() -> pykube.KubeConfig:

# TODO: add some caching, but keep kwargs in mind. Maybe add a key= for purpose/use-place?
def get_pykube_api(timeout=None) -> pykube.HTTPClient:
kwargs = dict(timeout=timeout) if timeout is not None else dict()
kwargs = dict(timeout=timeout)
return pykube.HTTPClient(get_pykube_cfg(), **kwargs)
9 changes: 7 additions & 2 deletions kopf/clients/fetching.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,14 @@ def watch_objs(*, resource, namespace=None, timeout=None, since=None):
* The resource is namespace-scoped AND operator is namespaced-restricted.
"""
api = auth.get_pykube_api(timeout=timeout)

params = {}
if timeout is not None:
params['timeoutSeconds'] = timeout

api = auth.get_pykube_api(timeout=None)
cls = classes._make_cls(resource=resource)
namespace = namespace if issubclass(cls, pykube.objects.NamespacedAPIObject) else None
lst = cls.objects(api, namespace=pykube.all if namespace is None else namespace)
src = lst.watch(since=since)
src = lst.watch(since=since, params=params)
return iter({'type': event.type, 'object': event.object.obj} for event in src)
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,6 @@
'click',
'iso8601',
'aiojobs',
'pykube-ng>=0.25',
'pykube-ng>=0.27',
],
)

0 comments on commit 17c9871

Please sign in to comment.