]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
ceph-crash: fix stderr handling
authorTim Serong <tserong@suse.com>
Wed, 2 Nov 2022 03:23:20 +0000 (14:23 +1100)
committerTim Serong <tserong@suse.com>
Wed, 9 Nov 2022 04:19:27 +0000 (15:19 +1100)
Popen.communicate() returns a tuple (stdout, stderr), and stderr
will be of type bytes, hence the need to decode it before checking
if it's an empty string or not.

Fixes: a77b47eeeb5770eeefcf4619ab2105ee7a6a003e
Signed-off-by: Tim Serong <tserong@suse.com>
(cherry picked from commit 45915540559126a652f8d9d105723584cfc63439)

src/ceph-crash.in

index 916f0664a9456679350187e5b2a1bcc2ac500360..453efb7aa10d04df6b038ae1eb94ae7df3e9228c 100755 (executable)
@@ -50,7 +50,8 @@ def post_crash(path):
             stderr=subprocess.PIPE,
         )
         f = open(os.path.join(path, 'meta'), 'rb')
-        stderr = pr.communicate(input=f.read())
+        (_, stderr) = pr.communicate(input=f.read())
+        stderr = stderr.decode()
         rc = pr.wait()
         f.close()
         if rc != 0 or stderr != "":