From e993d80e091ca62312332f5d87a6c5329e03ca27 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Ale=C5=A1=20Mr=C3=A1zek?= Date: Thu, 2 Oct 2025 11:21:07 +0200 Subject: [PATCH] datamodel: workers: check for macOS platform --- python/knot_resolver/datamodel/config_schema.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/python/knot_resolver/datamodel/config_schema.py b/python/knot_resolver/datamodel/config_schema.py index 2cc2680c9..d795188ba 100644 --- a/python/knot_resolver/datamodel/config_schema.py +++ b/python/knot_resolver/datamodel/config_schema.py @@ -1,5 +1,6 @@ import logging import os +import platform import socket from typing import Any, Dict, List, Literal, Optional, Tuple, Union @@ -163,14 +164,26 @@ class KresConfig(ConfigSchema): return obj.hostname def _workers(self, obj: Raw) -> Any: + is_macos = bool(platform.system() == "Darwin") + macos_msg = ( + "On macOS, you cannot run more than one worker because SO_REUSEPORT socket option support is absent." + ) + if obj.workers == "auto": count = _cpu_count() + if is_macos: + logger.info(f"Running on macOS, 'workers' configuration automatically set to 1. {macos_msg}") + count = 1 + if count: return IntPositive(count) raise ValueError( "The number of available CPUs to automatically set the number of running 'kresd' workers could not be determined." "The number of workers can be configured manually in 'workers' option." ) + if is_macos and (int(obj.workers) > 1): + raise ValueError(macos_msg) + return obj.workers def _dnssec(self, obj: Raw) -> Any: -- 2.47.3