Skip to content

Commit 6e2bafc

Browse files
committed
fix watching timeout bug
1 parent e42e13f commit 6e2bafc

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

kubesys/client.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -205,9 +205,9 @@ def watchResource(self, kind, namespace, watcherhandler, name=None, thread_name=
205205
url = self.analyzer.FullKindToApiPrefixDict[fullKind] + "/watch/"
206206
url += self.getNamespace(self.analyzer.FullKindToNamespaceDict[fullKind], namespace)
207207
if name:
208-
url += self.analyzer.FullKindToNameDict[fullKind] + "/" + name + "?watch=true&timeoutSeconds=315360000"
208+
url += self.analyzer.FullKindToNameDict[fullKind] + "/" + name
209209
else:
210-
url += self.analyzer.FullKindToNameDict[fullKind] + "?watch=true&timeoutSeconds=315360000"
210+
url += self.analyzer.FullKindToNameDict[fullKind]
211211
thread_t = threading.Thread(target=KubernetesClient.watching,
212212
args=(url, self.token, self.config, watcherhandler, kwargs,),
213213
name=thread_name, daemon=is_daemon)
@@ -237,9 +237,9 @@ def watchResourceBase(self, kind, namespace, handlerFunction, name=None, thread_
237237
url = self.analyzer.FullKindToApiPrefixDict[fullKind] + "/watch/"
238238
url += self.getNamespace(self.analyzer.FullKindToNamespaceDict[fullKind], namespace)
239239
if name:
240-
url += self.analyzer.FullKindToNameDict[fullKind] + "/" + name + "?watch=true&timeoutSeconds=315360000"
240+
url += self.analyzer.FullKindToNameDict[fullKind] + "/" + name
241241
else:
242-
url += self.analyzer.FullKindToNameDict[fullKind] + "?watch=true&timeoutSeconds=315360000"
242+
url += self.analyzer.FullKindToNameDict[fullKind]
243243

244244
thread_t = threading.Thread(target=KubernetesClient.watchingBase,
245245
args=(url, self.token, handlerFunction, kwargs,), name=thread_name,
@@ -260,7 +260,8 @@ def watchResourcesBase(self, kind, namespace, handlerFunction, thread_name=None,
260260

261261
@staticmethod
262262
def watching(url, token, config, watchHandler, kwargs):
263-
response=doCreateRequest(url=formatURL(url, getParams(kwargs)), token=token, method="GET", config=config,stream=True)
263+
# TODO
264+
response=doCreateRequest(url=formatURL(url, getParams(kwargs)) + "&watch=true&timeoutSeconds=315360000", token=token, method="GET", config=config,stream=True)
264265
for json_bytes in response.iter_lines():
265266
if len(json_bytes) < 1:
266267
continue
@@ -293,7 +294,8 @@ def watchingBase(url, token, handlerFunction, kwargs):
293294
"Accept-Encoding": "gzip, deflate, br",
294295
}
295296

296-
with requests.get(url=formatURL(url, getParams(kwargs)), headers=header, verify=False, stream=True) as response:
297+
# TODO
298+
with requests.get(url=formatURL(url, getParams(kwargs)) + "&watch=true&timeoutSeconds=315360000", headers=header, verify=False, stream=True) as response:
297299
for json_bytes in response.iter_lines():
298300
if len(json_bytes) < 1:
299301
continue

0 commit comments

Comments
 (0)