From 471db0c4bd486386d92d9b848f3def1c8cae572a Mon Sep 17 00:00:00 2001 From: Alik Send Date: Fri, 1 Nov 2019 15:56:18 +0200 Subject: [PATCH] Get error from kubernetes response --- contents/common.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/contents/common.py b/contents/common.py index 135df31..1994f71 100644 --- a/contents/common.py +++ b/contents/common.py @@ -443,7 +443,16 @@ def run_interactive_command(name, namespace, container, command): print("%s" % resp.read_stdout()) if resp.peek_stderr(): log.error("%s" % resp.read_stderr()) - error = True + + ERROR_CHANNEL = 3 + err = api.api_client.last_response.read_channel(ERROR_CHANNEL) + err = yaml.safe_load(err) + if err['status'] != "Success": + log.error('Failed to run command') + log.error('Reason: ' + err['reason']) + log.error('Message: ' + err['message']) + log.error('Details: ' + ';'.join(map(lambda x: json.dumps(x), err['details']['causes']))) + error = True return (resp,error)