]> git.ipfire.org Git - thirdparty/knot-resolver.git/commitdiff
datamodel: workers-max: constant default to have a consistent JSON schema docs-develop-data-ljcgmw/deployments/5087
authorAleš Mrázek <ales.mrazek@nic.cz>
Sat, 7 Sep 2024 00:32:32 +0000 (02:32 +0200)
committerAleš Mrázek <ales.mrazek@nic.cz>
Mon, 9 Sep 2024 12:28:32 +0000 (14:28 +0200)
doc/_static/config.schema.json
python/knot_resolver/datamodel/config_schema.py

index 96e5a26cf25c81afdb8214068fe999feff205bd1..989aaf62e9293695b640e00897c1ae32031ee1f4 100644 (file)
@@ -51,7 +51,7 @@
             "type": "integer",
             "minimum": 1,
             "description": "The maximum number of workers allowed. Cannot be changed in runtime.",
-            "default": 120
+            "default": 256
         },
         "management": {
             "description": "Configuration of management HTTP API.",
index 7d8b0b8d6dad642d42fa7e9dcf8eadc600aa7fec..fe18516b6a6d390c586079ecbbb389eb80996c79 100644 (file)
@@ -38,7 +38,7 @@ def _cpu_count() -> Optional[int]:
         return cpus
 
 
-def _default_max_worker_count() -> int:
+def _workers_max_count() -> int:
     c = _cpu_count()
     if c:
         return c * 10
@@ -111,7 +111,7 @@ class KresConfig(ConfigSchema):
         hostname: Optional[EscapedStr] = None
         rundir: WritableDir = lazy_default(WritableDir, str(RUN_DIR_DEFAULT))
         workers: Union[Literal["auto"], IntPositive] = IntPositive(1)
-        max_workers: IntPositive = IntPositive(_default_max_worker_count())
+        max_workers: IntPositive = IntPositive(WORKERS_MAX_DEFAULT)
         management: ManagementSchema = lazy_default(ManagementSchema, {"unix-socket": str(API_SOCK_PATH_DEFAULT)})
         webmgmt: Optional[WebmgmtSchema] = None
         options: OptionsSchema = OptionsSchema()
@@ -175,8 +175,11 @@ class KresConfig(ConfigSchema):
 
     def _validate(self) -> None:
         # enforce max-workers config
-        if int(self.workers) > int(self.max_workers):
-            raise ValueError(f"can't run with more workers then the configured maximum {self.max_workers}")
+        workers_max = _workers_max_count()
+        if int(self.workers) > workers_max:
+            raise ValueError(
+                f"can't run with more workers then the recommended maximum {workers_max} or hardcoded {WORKERS_MAX_DEFAULT}"
+            )
 
         # sanity check
         cpu_count = _cpu_count()