Skip to content

Commit

Permalink
Fix streaming results from k8s API
Browse files Browse the repository at this point in the history
The stream method by default decodes the payload. This convers JSON
payloads to python representation which can't be parsed as JSON again.

Avoiding the conversion requires that we call the buffering and reading
functions on our own.

Upstream bug report: kubernetes-client/python#1032
  • Loading branch information
rtreffer committed Feb 5, 2024
1 parent c15ab38 commit 6bc6fa8
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/backends/kubernetes/kubernetes_backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,8 @@ def exec_run(self, tank_index: int, service: ServiceType, cmd: str, user: str =
stdin=False,
stdout=True,
tty=False,
# Avoid preloading the content to keep JSON intact
_preload_content=False,
)
# TODO: stream result is just a string, so there is no error code to check
# ideally, we use a method where we can check for an error code, otherwise we will
Expand All @@ -158,6 +160,8 @@ def exec_run(self, tank_index: int, service: ServiceType, cmd: str, user: str =
# raise Exception(
# f"Command failed with exit code {result.exit_code}: {result.output.decode('utf-8')}"
# )
result.run_forever()
result = result.read_all()
return result

def get_bitcoin_debug_log(self, tank_index: int):
Expand Down

0 comments on commit 6bc6fa8

Please sign in to comment.