To better facilitate error handling, throw a RunError if the stderr has been populated.
cgclassify currently prints warnings to stderr if a setting isn't in the allow or deny list; ignore these warnings for now. Also, non-containerized Github Actions runs complain about missing coverage files for cgget; ignore those errors. Signed-off-by: Tom Hromatka <tom.hroma...@oracle.com> --- ftests/cgroup.py | 29 ++++++++++++++++++++++------- ftests/run.py | 2 +- 2 files changed, 23 insertions(+), 8 deletions(-) diff --git a/ftests/cgroup.py b/ftests/cgroup.py index 6286547fe7fd..37dd64295456 100644 --- a/ftests/cgroup.py +++ b/ftests/cgroup.py @@ -24,7 +24,7 @@ from controller import Controller from enum import Enum import multiprocessing as mp import os -from run import Run +from run import Run, RunError import time import utils @@ -236,7 +236,13 @@ class Cgroup(object): if config.args.container: ret = config.container.run(cmd) else: - ret = Run.run(cmd) + try: + ret = Run.run(cmd) + except RunError as re: + if "profiling" in re.stderr: + ret = re.stdout + else: + raise re return ret @@ -365,14 +371,23 @@ class Cgroup(object): # ensure the deny list file exists if config.args.container: - config.container.run(['sudo', 'touch', '/etc/cgsnapshot_blacklist.conf']) + try: + config.container.run(['sudo', 'touch', '/etc/cgsnapshot_blacklist.conf']) + except RunError as re: + if re.ret == 0 and "unable to resolve host" in re.stderr: + pass else: Run.run(['sudo', 'touch', '/etc/cgsnapshot_blacklist.conf']) - if config.args.container: - res = config.container.run(cmd) - else: - res = Run.run(cmd) + try: + if config.args.container: + res = config.container.run(cmd) + else: + res = Run.run(cmd) + except RunError as re: + if re.ret == 0 and \ + "neither blacklisted nor whitelisted" in re.stderr: + res = re.stdout # convert the cgsnapshot stdout to a dict of cgroup objects return Cgroup.snapshot_to_dict(res) diff --git a/ftests/run.py b/ftests/run.py index 53b4f34c257d..ad8f07d2a6f2 100644 --- a/ftests/run.py +++ b/ftests/run.py @@ -53,7 +53,7 @@ class Run(object): "run:\n\tcommand = {}\n\tret = {}\n\tstdout = {}\n\tstderr = {}".format( ' '.join(command), ret, out, err)) - if ret != 0: + if ret != 0 or len(err) > 0: raise RunError("Command '{}' failed".format(''.join(command)), command, ret, out, err) -- 2.26.2 _______________________________________________ Libcg-devel mailing list Libcg-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/libcg-devel