From: Aleš Mrázek Date: Tue, 16 Sep 2025 12:18:08 +0000 (+0200) Subject: manager: clean up supervisord and policy-loader config files X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=1bab521aec0bd5fa2c79f4a1650a44ff6f4dfd5f;p=thirdparty%2Fknot-resolver.git manager: clean up supervisord and policy-loader config files --- diff --git a/python/knot_resolver/controller/supervisord/__init__.py b/python/knot_resolver/controller/supervisord/__init__.py index aa85fc305..75ed3479d 100644 --- a/python/knot_resolver/controller/supervisord/__init__.py +++ b/python/knot_resolver/controller/supervisord/__init__.py @@ -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: diff --git a/python/knot_resolver/manager/manager.py b/python/knot_resolver/manager/manager.py index dcd14b537..66b59c71c 100644 --- a/python/knot_resolver/manager/manager.py +++ b/python/knot_resolver/manager/manager.py @@ -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.")