Fix check_output return on Debian

Upgrade script 68 fails running on Debian with a TypeError:
TypeError: a bytes-like object is required, not 'str'

This issue is due to check_output returning different types
on python2 (string) and python3 (byte string).

This commit converts the returned byte string to a string.

Test Plan
PASS: run upgrade-activate successfully

Story: 2009303
Task: 47134

Change-Id: Ie1c5fd5ad445d9ee507d6ce6561ddb735f3c4578
Signed-off-by: Heitor Matsui <heitorvieira.matsui@windriver.com>
This commit is contained in:
Heitor Matsui 2023-01-12 17:59:12 -03:00
parent e4bd099dd4
commit 3cf87ede6b

View File

@ -43,7 +43,7 @@ def add_pod_security_admission_controller_labels():
cmd = ["kubectl", "--kubeconfig=/etc/kubernetes/admin.conf",
"get", "namespaces", "-o=name"]
namespaces_output = subprocess.check_output(cmd)
namespaces_output = subprocess.check_output(cmd).decode("utf-8")
except Exception as exc:
LOG.error('Command failed:\n %s' % (cmd))