]> git.ipfire.org Git - thirdparty/knot-resolver.git/commitdiff
datamodel: removed workers-max option
authorAleš Mrázek <ales.mrazek@nic.cz>
Tue, 25 Mar 2025 13:04:32 +0000 (14:04 +0100)
committerAleš Mrázek <ales.mrazek@nic.cz>
Fri, 31 Oct 2025 14:11:38 +0000 (15:11 +0100)
NEWS
doc/_static/config.schema.json
python/knot_resolver/controller/supervisord/__init__.py
python/knot_resolver/controller/supervisord/config_file.py
python/knot_resolver/datamodel/config_schema.py
python/knot_resolver/manager/manager.py

diff --git a/NEWS b/NEWS
index 8906c84d341c60f859de289ba0a1afb0ae40b4e6..1dc6e2a5e40df5a48d2c527995f7c6725364a68d 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -6,6 +6,7 @@ Incompatible changes
 - Removed options from declarative configuration model (YAML).  
   These are mostly experimental and debugging/testing options that are not useful for general users (remain in Lua):
   - /logging/debugging
+  - /max-workers
   - /webmgmt
 
 
index a39f95785e8ce6a54d06e9b66b2f5c631072b5d7..996089d8aa01fa535a4513279c1dc5a7112ea1d4 100644 (file)
             "description": "The number of running kresd (Knot Resolver daemon) workers. If set to 'auto', it is equal to number of CPUs available.",
             "default": 1
         },
-        "max-workers": {
-            "type": "integer",
-            "minimum": 1,
-            "description": "The maximum number of workers allowed. Cannot be changed in runtime.",
-            "default": 256
-        },
         "management": {
             "description": "Configuration of management HTTP API.",
             "type": "object",
index 75ed3479d00b6174354246a94877da319b390ccb..216186c50d8d9c01c41ecf16823e27c146c60a03 100644 (file)
@@ -15,7 +15,7 @@ from knot_resolver.controller.interface import (
     SubprocessType,
 )
 from knot_resolver.controller.supervisord.config_file import SupervisordKresID, write_config_file
-from knot_resolver.datamodel.config_schema import KresConfig
+from knot_resolver.datamodel.config_schema import KresConfig, workers_max_count
 from knot_resolver.manager.constants import supervisord_config_file, supervisord_pid_file, supervisord_sock_file
 from knot_resolver.utils import which
 from knot_resolver.utils.async_utils import call, readfile
@@ -203,7 +203,7 @@ class SupervisordSubprocess(Subprocess):
     @async_in_a_thread
     def _start(self) -> None:
         # +1 for canary process (same as in config_file.py)
-        assert int(self.id) <= int(self._config.max_workers) + 1, "trying to spawn more than allowed limit of workers"
+        assert int(self.id) <= int(workers_max_count()) + 1, "trying to spawn more than allowed limit of workers"
         try:
             supervisord = _create_fast_proxy(self._config)
             supervisord.startProcess(self.name)
index a825b62332cebd8945324e59e6dc2bd3afe9e721..e0ec67701e8f67c18a5dc88be1ff49f5642f12e7 100644 (file)
@@ -8,7 +8,7 @@ from jinja2 import Template
 
 from knot_resolver.constants import KRES_CACHE_GC_EXECUTABLE, KRESD_EXECUTABLE
 from knot_resolver.controller.interface import KresID, SubprocessType
-from knot_resolver.datamodel.config_schema import KresConfig
+from knot_resolver.datamodel.config_schema import KresConfig, workers_max_count
 from knot_resolver.datamodel.logging_schema import LogTargetEnum
 from knot_resolver.manager.constants import (
     kres_cache_dir,
@@ -115,7 +115,7 @@ class ProcessTypeConfig:
             workdir=cwd,
             command=f"{KRESD_EXECUTABLE} -c {kresd_config_file_supervisord_pattern(config)} -n",
             environment='SYSTEMD_INSTANCE="%(process_num)d",X-SUPERVISORD-TYPE=notify',
-            max_procs=int(config.max_workers) + 1,  # +1 for the canary process
+            max_procs=int(workers_max_count()) + 1,  # +1 for the canary process
         )
 
     @staticmethod
index 68b313b81bee44788592ac3e71b4250e98422394..911c800de81f7294ca1e1bf20e6cc8247da14898 100644 (file)
@@ -41,7 +41,7 @@ def _cpu_count() -> Optional[int]:
         return cpus
 
 
-def _workers_max_count() -> int:
+def workers_max_count() -> int:
     c = _cpu_count()
     if c:
         return c * 10
@@ -93,7 +93,6 @@ class KresConfig(ConfigSchema):
         hostname: Internal DNS resolver hostname. Default is machine hostname.
         rundir: Directory where the resolver can create files and which will be it's cwd.
         workers: The number of running kresd (Knot Resolver daemon) workers. If set to 'auto', it is equal to number of CPUs available.
-        max_workers: The maximum number of workers allowed. Cannot be changed in runtime.
         management: Configuration of management HTTP API.
         options: Fine-tuning global parameters of DNS resolver operation.
         network: Network connections and protocols configuration.
@@ -116,7 +115,6 @@ class KresConfig(ConfigSchema):
         hostname: Optional[EscapedStr] = None
         rundir: WritableDir = lazy_default(WritableDir, str(RUN_DIR))
         workers: Union[Literal["auto"], IntPositive] = IntPositive(1)
-        max_workers: IntPositive = IntPositive(WORKERS_MAX)
         management: ManagementSchema = lazy_default(ManagementSchema, {"unix-socket": str(API_SOCK_FILE)})
         options: OptionsSchema = OptionsSchema()
         network: NetworkSchema = NetworkSchema()
@@ -139,7 +137,6 @@ class KresConfig(ConfigSchema):
     hostname: EscapedStr
     rundir: WritableDir
     workers: IntPositive
-    max_workers: IntPositive
     management: ManagementSchema
     options: OptionsSchema
     network: NetworkSchema
@@ -192,7 +189,7 @@ class KresConfig(ConfigSchema):
             )
 
         # enforce max-workers config
-        workers_max = _workers_max_count()
+        workers_max = workers_max_count()
         if int(self.workers) > workers_max:
             raise ValueError(
                 f"can't run with more workers than the recommended maximum {workers_max} or hardcoded {WORKERS_MAX}"
index 55fb125541683ced3cb2af05de8ca08714e64749..4b5d04210b92ce2da74bca8993dea49962b5a9fe 100644 (file)
@@ -52,17 +52,6 @@ class _FixCounter:
         return self._counter >= FIX_COUNTER_ATTEMPTS_MAX
 
 
-async def _deny_max_worker_changes(
-    config_old: KresConfig, config_new: KresConfig, force: bool = False
-) -> Result[None, str]:
-    if config_old.max_workers != config_new.max_workers:
-        return Result.err(
-            "Changing 'max-workers', the maximum number of workers allowed to run, is not allowed at runtime."
-        )
-
-    return Result.ok(None)
-
-
 async def _subprocess_desc(subprocess: Subprocess) -> object:
     return {
         "type": subprocess.type.name,
@@ -131,7 +120,6 @@ class KresManager:  # pylint: disable=too-many-instance-attributes
                 config.nsid,
                 config.hostname,
                 config.workers,
-                config.max_workers,
                 config.options,
                 config.network,
                 config.forward,
@@ -162,9 +150,6 @@ class KresManager:  # pylint: disable=too-many-instance-attributes
         # register callback that reloads files (TLS cert files) if selected configuration has not been changed
         await config_store.register_on_change_callback(only_on_no_changes_update(config_nodes)(files_reload))
 
-        # register controller config change listeners
-        await config_store.register_verifier(_deny_max_worker_changes)
-
     async def _spawn_new_worker(self, config: KresConfig) -> None:
         subprocess = await self._controller.create_subprocess(config, SubprocessType.KRESD)
         await subprocess.start()