Skip to content

Commit

Permalink
Merge pull request kubernetes-client#272 from AurelienGasser/fix-retu…
Browse files Browse the repository at this point in the history
…rncode-idempotent

fix: WSClient.returncode not idempotent
  • Loading branch information
k8s-ci-robot authored Dec 14, 2021
2 parents 06191d3 + 79e066a commit f0fa950
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions stream/ws_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ def __init__(self, configuration, url, headers, capture_all):
self._all = _IgnoredIO()
self.sock = create_websocket(configuration, url, headers)
self._connected = True
self._returncode = None

def peek_channel(self, channel, timeout=0):
"""Peek a channel and return part of the input,
Expand Down Expand Up @@ -228,12 +229,14 @@ def returncode(self):
if self.is_open():
return None
else:
err = self.read_channel(ERROR_CHANNEL)
err = yaml.safe_load(err)
if err['status'] == "Success":
return 0
return int(err['details']['causes'][0]['message'])

if self._returncode is None:
err = self.read_channel(ERROR_CHANNEL)
err = yaml.safe_load(err)
if err['status'] == "Success":
self._returncode = 0
else:
self._returncode = int(err['details']['causes'][0]['message'])
return self._returncode

def close(self, **kwargs):
"""
Expand Down

0 comments on commit f0fa950

Please sign in to comment.