from knot_resolver_manager.datamodel.slice_schema import SliceSchema
from knot_resolver_manager.datamodel.static_hints_schema import StaticHintsSchema
from knot_resolver_manager.datamodel.stub_zone_schema import StubZoneSchema
-from knot_resolver_manager.datamodel.supervisor_schema import SupervisorSchema
from knot_resolver_manager.datamodel.types.types import IDPattern, IntPositive, UncheckedPath
from knot_resolver_manager.datamodel.view_schema import ViewSchema
+from knot_resolver_manager.datamodel.watchdog_schema import WatchDogSchema
from knot_resolver_manager.datamodel.webmgmt_schema import WebmgmtSchema
from knot_resolver_manager.exceptions import DataException
from knot_resolver_manager.utils import SchemaNode
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.
+ watchdog: Disable supervisord's watchdog, enable with defaults or set new configuration.
management: Configuration of management HTTP API.
webmgmt: Configuration of legacy web management endpoint.
- supervisor: Proceses supervisor configuration.
options: Fine-tuning global parameters of DNS resolver operation.
network: Network connections and protocols configuration.
static_hints: Static hints for forward records (A/AAAA) and reverse records (PTR)
rundir: UncheckedPath = UncheckedPath(".")
workers: Union[Literal["auto"], IntPositive] = IntPositive(1)
max_workers: IntPositive = IntPositive(MAX_WORKERS)
+ watchdog: Union[bool, WatchDogSchema] = True
management: ManagementSchema = ManagementSchema({"unix-socket": "./manager.sock"})
webmgmt: Optional[WebmgmtSchema] = None
- supervisor: SupervisorSchema = SupervisorSchema()
options: OptionsSchema = OptionsSchema()
network: NetworkSchema = NetworkSchema()
static_hints: StaticHintsSchema = StaticHintsSchema()
max_workers: IntPositive
management: ManagementSchema
webmgmt: Optional[WebmgmtSchema]
- supervisor: SupervisorSchema
+ watchdog: Union[bool, WatchDogSchema]
options: OptionsSchema
network: NetworkSchema
static_hints: StaticHintsSchema
+++ /dev/null
-from typing import Union
-
-from typing_extensions import Literal
-
-from knot_resolver_manager.datamodel.types import DNSRecordTypeEnum, DomainName
-from knot_resolver_manager.utils import SchemaNode
-
-BackendEnum = Literal["auto", "systemd", "systemd-session", "supervisord"]
-
-
-class WatchDogSchema(SchemaNode):
- """
- Configuration of systemd watchdog.
-
- ---
- qname: Name to internaly query for.
- qtype: DNS type to internaly query for.
- """
-
- qname: DomainName
- qtype: DNSRecordTypeEnum
-
-
-class SupervisorSchema(SchemaNode):
- """
- Configuration of processes supervisor.
-
- ---
- backend: Forces the manager to use a specific service supervisor.
- watchdog: Disable systemd watchdog, enable with defaults or set new configuration. Can only be used with 'systemd' backend.
- """
-
- backend: BackendEnum = "auto"
- watchdog: Union[bool, WatchDogSchema] = True
-
- def _validate(self) -> None:
- if self.watchdog and self.backend not in ["auto", "systemd", "systemd-session"]:
- raise ValueError("'watchdog' can only be configured for 'systemd' backend")
-- LOGGING section ----------------------------------
{% include "logging.lua.j2" %}
--- SUPERVISOR section -------------------------------
-{% include "supervisor.lua.j2" %}
+-- WATCHDOG section -------------------------------
+{% include "watchdog.lua.j2" %}
-- WEBMGMT section ----------------------------------
{% include "webmgmt.lua.j2" %}
+++ /dev/null
-{% if cfg.supervisor.watchdog -%}
--- supervisor.watchdog
-modules.load('watchdog')
-{% if cfg.supervisor.watchdog.qname and cfg.supervisor.watchdog.qtype -%}
-watchdog.config({ qname = '{{ cfg.supervisor.watchdog.qname.punycode() }}', qtype = kres.type.{{ cfg.supervisor.watchdog.qtype }} })
-{%- endif %}
-{% else %}
-modules.unload('watchdog')
-{%- endif %}
\ No newline at end of file
--- /dev/null
+{% if cfg.watchdog -%}
+-- watchdog
+modules.load('watchdog')
+{% if cfg.watchdog.qname and cfg.watchdog.qtype -%}
+watchdog.config({ qname = '{{ cfg.watchdog.qname.punycode() }}', qtype = kres.type.{{ cfg.watchdog.qtype }} })
+{%- endif %}
+{% else %}
+modules.unload('watchdog')
+{%- endif %}
\ No newline at end of file
--- /dev/null
+from knot_resolver_manager.datamodel.types import DNSRecordTypeEnum, DomainName
+from knot_resolver_manager.utils import SchemaNode
+
+
+class WatchDogSchema(SchemaNode):
+ """
+ Configuration of supervisord's watchdog which tests whether the started worker is working correctly.
+
+ ---
+ qname: Name to internaly query for.
+ qtype: DNS type to internaly query for.
+ """
+
+ qname: DomainName
+ qtype: DNSRecordTypeEnum
from knot_resolver_manager.datamodel.config_schema import KresConfig
from knot_resolver_manager.datamodel.management_schema import ManagementSchema
from knot_resolver_manager.exceptions import DataException, KresManagerException, SchemaException
-from knot_resolver_manager.kresd_controller import get_controller_by_name
-from knot_resolver_manager.kresd_controller.interface import SubprocessController
from knot_resolver_manager.utils.async_utils import readfile
from knot_resolver_manager.utils.functional import Result
from knot_resolver_manager.utils.parsing import ParsedTree, parse, parse_yaml
"""
Called asynchronously when the application initializes.
"""
- # if configured, create a subprocess controller manually
- controller: Optional[SubprocessController] = None
- if config_store.get().supervisor.backend != "auto":
- controller = await get_controller_by_name(config_store.get(), config_store.get().supervisor.backend)
# Create KresManager. This will perform autodetection of available service managers and
# select the most appropriate to use (or use the one configured directly)
- manager = await KresManager.create(controller, config_store, server.trigger_shutdown)
+ manager = await KresManager.create(None, config_store, server.trigger_shutdown)
logger.info("Initial configuration applied. Process manager initialized...")
return manager
+++ /dev/null
-import pytest
-
-from knot_resolver_manager.datamodel.supervisor_schema import SupervisorSchema
-from knot_resolver_manager.exceptions import KresManagerException
-
-
-def test_watchdog_backend_invalid():
- with pytest.raises(KresManagerException):
- SupervisorSchema({"backend": "supervisord", "watchdog": {"qname": "nic.cz.", "qtype": "A"}})