From 24b5a123e63f16a24dc7e0c7d690d8e93b18a55d Mon Sep 17 00:00:00 2001 From: Benedikt Ziemons Date: Fri, 17 Sep 2021 00:07:25 +0200 Subject: [PATCH] Stop logging while polling pod status --- .idea/podlaunch.iml | 2 +- main.py | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/.idea/podlaunch.iml b/.idea/podlaunch.iml index d0876a7..969bacc 100644 --- a/.idea/podlaunch.iml +++ b/.idea/podlaunch.iml @@ -2,7 +2,7 @@ - + \ No newline at end of file diff --git a/main.py b/main.py index 87f54f3..b55ca7b 100644 --- a/main.py +++ b/main.py @@ -76,6 +76,10 @@ class PodKeeper: print(f"Starting pod {self.podname} at {self.last_check}", file=sys.stderr, flush=True) shlog.podman.play.kube(self.podyaml, *self.podnet_args) try: + shlogger = logging.getLogger("sh.command") + oldlevel = shlogger.level + shlogger.setLevel(logging.ERROR) + if 'NOTIFY_SOCKET' in os.environ: sdnotify("--ready", f"--pid={os.getpid()}", "--status=Monitoring pod...") @@ -99,6 +103,8 @@ class PodKeeper: if 'NOTIFY_SOCKET' in os.environ: sdnotify("--status=Stopping pod") + + logging.getLogger("sh.command").setLevel(oldlevel) finally: self.stop_pod()