]> git.ipfire.org Git - thirdparty/knot-resolver.git/commitdiff
manager: clean up supervisord and policy-loader config files
authorAleš Mrázek <ales.mrazek@nic.cz>
Tue, 16 Sep 2025 12:18:08 +0000 (14:18 +0200)
committerVladimír Čunát <vladimir.cunat@nic.cz>
Wed, 15 Oct 2025 14:18:09 +0000 (16:18 +0200)
python/knot_resolver/controller/supervisord/__init__.py
python/knot_resolver/manager/manager.py

index aa85fc305a81fc54ed53aa0e98fe5fc49fd09208..75ed3479d00b6174354246a94877da319b390ccb 100644 (file)
@@ -73,10 +73,9 @@ def _stop_supervisord(config: KresConfig) -> None:
             # something wrong happened, let's be loud about it
             raise
 
-    # We could remove the configuration, but there is actually no specific need to do so.
-    # If we leave it behind, someone might find it and use it to start us from scratch again,
-    # which is perfectly fine.
-    # supervisord_config_file(config).unlink()
+    # It is always better to clean up.
+    # This way, we can be sure that we are starting with a newly generated configuration.
+    supervisord_config_file(config).unlink()
 
 
 async def _is_supervisord_available() -> bool:
index 3ec94ea714009b279e4a1f60a7be3e0d44854849..89752a0a4bd7dda45c82146b476bf08e867da84a 100644 (file)
@@ -344,6 +344,12 @@ class KresManager:  # pylint: disable=too-many-instance-attributes
                 while not self._is_policy_loader_exited():
                     await asyncio.sleep(1)
 
+                # Clean up policy-loader configuration.
+                # If we don't do this, we may start with
+                # an old configuration and fail to detect a bug.
+                if self._policy_loader:
+                    await self._policy_loader.cleanup()
+
         except (SubprocessError, SubprocessControllerError) as e:
             logger.error(f"Failed to load policy rules: {e}")
             return Result.err("kresd 'policy-loader' process failed to start. Config might be invalid.")