Skip to content

Commit

Permalink
PESDLC-1319 Updated debug logging based on RC
Browse files Browse the repository at this point in the history
  • Loading branch information
savex committed May 8, 2024
1 parent 771abda commit d617faa
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions tests/rptest/clients/kubectl.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,12 +142,12 @@ def logger(self) -> Logger:
def _local_cmd(self, cmd: list[str], timeout=900):
"""Run the given command locally and return the stdout as bytes.
Logs stdout and stderr on failure.
cmd: list[str]: command to run
throws CalledProcessError on non-zero exit code
thwows
thwows
returns: stdout as string if not empty, else stderr
"""
def _prepare_output(sout: str, serr: str) -> str:
Expand All @@ -174,9 +174,6 @@ def _prepare_output(sout: str, serr: str) -> str:
s_out, s_err = process.communicate()
raise subprocess.TimeoutExpired(cmd, timeout, s_out, s_err)

# Log all collected strings, including JSONs collected
self.logger.debug(_prepare_output(s_out, s_err))

# TODO: Handle s_err output
# It will be hard to detect errors as a lot of apps and utils
# just uses stderr as normal output. For example, tsh (teleport tunnel)
Expand All @@ -187,6 +184,9 @@ def _prepare_output(sout: str, serr: str) -> str:
f"{_prepare_output(s_out, s_err)}")
raise subprocess.CalledProcessError(process.returncode, cmd, s_out,
s_err)
else:
# Log all collected strings, including JSONs collected
self.logger.debug(_prepare_output(s_out, s_err))

# Most of the time stdout will hold valuable data
# In rare occasions when return code is 0, and and stderr is not empty
Expand Down

0 comments on commit d617faa

Please sign in to comment.