Skip to content

Commit

Permalink
gpssh: removing b and \r getting added to command output
Browse files Browse the repository at this point in the history
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
  • Loading branch information
piyushc01 authored and my-ship-it committed Jan 29, 2024
1 parent aed1899 commit 5d47e27
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions gpMgmt/bin/gppylib/util/ssh_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 5d47e27

Please sign in to comment.