Browse Source

Fix openshift_logging on Python3

Popen returns a byte object on Python 3 so it will fail when being
compared to a string. Since we ever only use it as a string we simply
cast it right after creation.

When converting to a string I decided to use the `replace` error handler
which will replace invalid UTF bytes with `?` instead of raising an
exception. Another option would be to use `ignore` but that could cause
confusion further down as the string would not really be a proper UTF
string.

Closes #4163
Christoffer Reijer 6 years ago
parent
commit
6686147f40
1 changed files with 1 additions and 0 deletions
  1. 1 0
      roles/openshift_logging/library/openshift_logging_facts.py

+ 1 - 0
roles/openshift_logging/library/openshift_logging_facts.py

@@ -76,6 +76,7 @@ class OCBaseCommand(object):
         try:
             process = Popen(cmd, stdout=PIPE, stderr=PIPE)   # noqa: F405
             out, err = process.communicate(cmd)
+            err = err.decode(encoding='utf8', errors='replace')
             if len(err) > 0:
                 if 'not found' in err:
                     return {'items': []}