]> git.ipfire.org Git - thirdparty/libcgroup.git/commitdiff
cgroup.py: Fix exception handling in init_cgrules()
authorTom Hromatka <tom.hromatka@oracle.com>
Tue, 22 Feb 2022 23:08:43 +0000 (16:08 -0700)
committerTom Hromatka <tom.hromatka@oracle.com>
Tue, 22 Feb 2022 23:08:43 +0000 (16:08 -0700)
When /etc/cgconfig.d/ exists, a UnicodeDecodeError is
thrown because the Unicode error string cannot be
properly decoded by Run.run().  Catch this error as it's
not an error in this case.

Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
ftests/cgroup.py

index 041d7132fafe463577ac67c5418a4b73092c89b5..25d691418721c2f16dbf64694c76d1f2d4783fe5 100644 (file)
@@ -608,14 +608,9 @@ class Cgroup(object):
                 config.container.run(cmd, shell_bool=True)
             else:
                 Run.run(cmd, shell_bool=True)
-        except RunError as re:
-            # check the errno to ensure the directory exists rather
-            # than receiving a different error
-            if re.ret == 1 and \
-               'File exists' in re.stderr:
-                pass
-            else:
-                raise re
+        except UnicodeDecodeError as ude:
+            # A unicode error is thrown when the directory already exists
+            pass
 
         cmd2 = list()