Stop logging while polling pod status

This commit is contained in:
Ben 2021-09-17 00:07:25 +02:00
parent 62a1566ab0
commit 24b5a123e6
Signed by: ben
GPG key ID: 0F54A7ED232D3319
2 changed files with 7 additions and 1 deletions

View file

@ -2,7 +2,7 @@
<module type="PYTHON_MODULE" version="4"> <module type="PYTHON_MODULE" version="4">
<component name="NewModuleRootManager"> <component name="NewModuleRootManager">
<content url="file://$MODULE_DIR$" /> <content url="file://$MODULE_DIR$" />
<orderEntry type="inheritedJdk" /> <orderEntry type="jdk" jdkName="Python 3.9 (podlaunch)" jdkType="Python SDK" />
<orderEntry type="sourceFolder" forTests="false" /> <orderEntry type="sourceFolder" forTests="false" />
</component> </component>
</module> </module>

View file

@ -76,6 +76,10 @@ class PodKeeper:
print(f"Starting pod {self.podname} at {self.last_check}", file=sys.stderr, flush=True) print(f"Starting pod {self.podname} at {self.last_check}", file=sys.stderr, flush=True)
shlog.podman.play.kube(self.podyaml, *self.podnet_args) shlog.podman.play.kube(self.podyaml, *self.podnet_args)
try: try:
shlogger = logging.getLogger("sh.command")
oldlevel = shlogger.level
shlogger.setLevel(logging.ERROR)
if 'NOTIFY_SOCKET' in os.environ: if 'NOTIFY_SOCKET' in os.environ:
sdnotify("--ready", f"--pid={os.getpid()}", "--status=Monitoring pod...") sdnotify("--ready", f"--pid={os.getpid()}", "--status=Monitoring pod...")
@ -99,6 +103,8 @@ class PodKeeper:
if 'NOTIFY_SOCKET' in os.environ: if 'NOTIFY_SOCKET' in os.environ:
sdnotify("--status=Stopping pod") sdnotify("--status=Stopping pod")
logging.getLogger("sh.command").setLevel(oldlevel)
finally: finally:
self.stop_pod() self.stop_pod()