From a72dbad4ffbe8d3501481c22f32cf503372d8047 Mon Sep 17 00:00:00 2001 From: Sergey Vasilyev Date: Thu, 11 Jul 2019 21:05:33 +0200 Subject: [PATCH] Use server-side timeouts for watching, disable socket timeouts --- kopf/clients/fetching.py | 9 +++++++-- setup.py | 2 +- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/kopf/clients/fetching.py b/kopf/clients/fetching.py index 57b6b313..7d2fb697 100644 --- a/kopf/clients/fetching.py +++ b/kopf/clients/fetching.py @@ -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) diff --git a/setup.py b/setup.py index 8aac822c..51cf1775 100644 --- a/setup.py +++ b/setup.py @@ -43,6 +43,6 @@ 'click', 'iso8601', 'aiojobs', - 'pykube-ng>=0.25', + 'pykube-ng>=0.27', ], )