From f51b2777ca7f1029cf1a33cc1b10526583463208 Mon Sep 17 00:00:00 2001 From: Piyush Chandwadkar Date: Mon, 20 Mar 2023 17:50:43 +0530 Subject: [PATCH] gpssh: removing b and \r getting added to command output Issue: This issue applies to 7x only. Gpssh command output contained byte string and \r characters. RCA: When gpssh reads output from pexpect.before, it's in byte format. Need to convert this output into the string format. Also, there are carriage return characters (\r) that need to be removed. Fix: When the output is returned from gpssh, made sure that we are converting bytes to string. To remove \r characters, striping the lines. Sample output before the fix: $ gpssh -h sdw1 hostname [sdw1] b'sdw1\r' After the fix: $ gpssh -h sdw1 hostname [sdw1] sdw1 --- gpMgmt/bin/gppylib/util/ssh_utils.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/gpMgmt/bin/gppylib/util/ssh_utils.py b/gpMgmt/bin/gppylib/util/ssh_utils.py index f194d8b2d02..bab39ef6ef2 100644 --- a/gpMgmt/bin/gppylib/util/ssh_utils.py +++ b/gpMgmt/bin/gppylib/util/ssh_utils.py @@ -283,8 +283,9 @@ def executeCommand(self, command): for s in self.pxssh_list: # Split the output into an array of lines so that we can add text to the beginning of - # each line - output = s.before.split(b'\n') + # each line. Decoding string as we are getting bytecode string in s.before + # Removing \r characters in each line by strip + output = [x.strip() for x in s.before.decode().split('\n')] output = output[1:-1] commandoutput.append(output)