]> 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)
committerAleš Mrázek <ales.mrazek@nic.cz>
Tue, 30 Sep 2025 13:12:10 +0000 (15:12 +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 dcd14b537859d1a62007876328c6ad227955cb67..66b59c71cf1802cfe1fc05e73e76a899f680a3cc 100644 (file)
@@ -341,6 +341,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.")