- 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
"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",
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
@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)
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,
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
return cpus
-def _workers_max_count() -> int:
+def workers_max_count() -> int:
c = _cpu_count()
if c:
return c * 10
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.
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()
hostname: EscapedStr
rundir: WritableDir
workers: IntPositive
- max_workers: IntPositive
management: ManagementSchema
options: OptionsSchema
network: NetworkSchema
)
# 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}"
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,
config.nsid,
config.hostname,
config.workers,
- config.max_workers,
config.options,
config.network,
config.forward,
# 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()