From e3dfc29747fca1ecd65331f148fbb78013519995 Mon Sep 17 00:00:00 2001 From: Otniel van Handel Date: Thu, 26 Sep 2019 11:11:31 +0300 Subject: [PATCH] RED_33496 decode bytes to strings in log collector (#74) --- log_collector.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/log_collector.py b/log_collector.py index b57efa6..5f8846c 100755 --- a/log_collector.py +++ b/log_collector.py @@ -152,7 +152,7 @@ def collect_api_resources(): resources_out[resource] = run_kubectl_get(resource) logger.info(" + {}".format(resource)) - for entry, out in resources_out.iteritems(): + for entry, out in resources_out.items(): with open(os.path.join(output_dir, "{}.yaml".format(entry)), "w+") as fp: fp.write(out) @@ -177,7 +177,7 @@ def collect_pods_logs(): p = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT) while True: # read one line a time - we do not want to read large files to memory - line = p.stdout.readline() + line = p.stdout.readline().decode('utf-8') if line: fp.write(line) else: @@ -270,9 +270,9 @@ def run_shell_command(cmd): stderr=subprocess.STDOUT) except subprocess.CalledProcessError as ex: logger.warning("Failed in shell command: {}, output: {}".format(cmd, ex.output)) - return ex.returncode, ex.output + return ex.returncode, ex.output.decode('utf-8') - return 0, output + return 0, output.decode('utf-8') def run_kubectl_get(resource_type):