From: Vasek Sraier Date: Thu, 31 Mar 2022 12:31:46 +0000 (+0200) Subject: subprocess manament: remove configuration files of kresd's even when not stopped... X-Git-Tag: v6.0.0a1~38^2~1 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=bf026adf9f0d294630ee6dcac7fa2b64a3c120f4;p=thirdparty%2Fknot-resolver.git subprocess manament: remove configuration files of kresd's even when not stopped directly --- diff --git a/manager/knot_resolver_manager/kres_manager.py b/manager/knot_resolver_manager/kres_manager.py index c479db09e..b444fa996 100644 --- a/manager/knot_resolver_manager/kres_manager.py +++ b/manager/knot_resolver_manager/kres_manager.py @@ -218,6 +218,8 @@ class KresManager: # pylint: disable=too-many-instance-attributes # we could stop all the children one by one right now # we won't do that and we leave that up to the subprocess controller to do that while it is shutting down await self._controller.shutdown_controller() + # now, when everything is stopped, let's clean up all the remains + await asyncio.gather(*[w.cleanup() for w in self._workers]) async def forced_shutdown(self) -> None: logger.warning("Collecting all remaining workers...") diff --git a/manager/knot_resolver_manager/kresd_controller/interface.py b/manager/knot_resolver_manager/kresd_controller/interface.py index 3aa08f6ef..796704237 100644 --- a/manager/knot_resolver_manager/kresd_controller/interface.py +++ b/manager/knot_resolver_manager/kresd_controller/interface.py @@ -133,6 +133,13 @@ class Subprocess: if self._metrics_registered: unregister_resolver_metrics_for(self) await self._stop() + await self.cleanup() + + async def cleanup(self) -> None: + """ + Remove temporary files and all traces of this instance running. It is NOT SAFE to call this while + the kresd is running, because it will break automatic restarts (at the very least). + """ kresd_config_file(self._config, self.id).unlink() def __eq__(self, o: object) -> bool: