]> git.ipfire.org Git - thirdparty/knot-resolver.git/commitdiff
subprocess manament: remove configuration files of kresd's even when not stopped...
authorVasek Sraier <git@vakabus.cz>
Thu, 31 Mar 2022 12:31:46 +0000 (14:31 +0200)
committerAleš Mrázek <ales.mrazek@nic.cz>
Fri, 8 Apr 2022 14:17:54 +0000 (16:17 +0200)
manager/knot_resolver_manager/kres_manager.py
manager/knot_resolver_manager/kresd_controller/interface.py

index c479db09e4a955677df968b63ff6dac48475c2c0..b444fa9969e08516a89cae7aa299fc21ad0e8a85 100644 (file)
@@ -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...")
index 3aa08f6efc28f70a7abf15a619dde035e170c134..796704237a5de5423373cbf0cb3ed44f74a57fc4 100644 (file)
@@ -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: