]> git.ipfire.org Git - thirdparty/knot-resolver.git/commitdiff
manager: datamodel: supervisor section removed
authorAleš Mrázek <ales.mrazek@nic.cz>
Mon, 4 Jul 2022 16:24:58 +0000 (18:24 +0200)
committerAleš Mrázek <ales.mrazek@nic.cz>
Mon, 4 Jul 2022 16:24:58 +0000 (18:24 +0200)
- watchdog moved to top-level

manager/knot_resolver_manager/datamodel/config_schema.py
manager/knot_resolver_manager/datamodel/supervisor_schema.py [deleted file]
manager/knot_resolver_manager/datamodel/templates/config.lua.j2
manager/knot_resolver_manager/datamodel/templates/supervisor.lua.j2 [deleted file]
manager/knot_resolver_manager/datamodel/templates/watchdog.lua.j2 [new file with mode: 0644]
manager/knot_resolver_manager/datamodel/watchdog_schema.py [new file with mode: 0644]
manager/knot_resolver_manager/server.py
manager/tests/unit/datamodel/test_supervisor_schema.py [deleted file]

index 838b496098621150a94e7ef820e2a195d1378fcc..360a41568ca074aff1228d98dbf75cc055f930fe 100644 (file)
@@ -23,9 +23,9 @@ from knot_resolver_manager.datamodel.rpz_schema import RPZSchema
 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
@@ -92,9 +92,9 @@ class KresConfig(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)
@@ -118,9 +118,9 @@ class KresConfig(SchemaNode):
         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()
@@ -147,7 +147,7 @@ class KresConfig(SchemaNode):
     max_workers: IntPositive
     management: ManagementSchema
     webmgmt: Optional[WebmgmtSchema]
-    supervisor: SupervisorSchema
+    watchdog: Union[bool, WatchDogSchema]
     options: OptionsSchema
     network: NetworkSchema
     static_hints: StaticHintsSchema
diff --git a/manager/knot_resolver_manager/datamodel/supervisor_schema.py b/manager/knot_resolver_manager/datamodel/supervisor_schema.py
deleted file mode 100644 (file)
index 05b4a66..0000000
+++ /dev/null
@@ -1,38 +0,0 @@
-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")
index d18c7a9993511d0fc408bdb455ca86ebe2018391..53abea9b902136360b66186efe740d00aacc5382 100644 (file)
@@ -12,8 +12,8 @@ nsid.name('{{ cfg.nsid }}_' .. worker.id)
 -- LOGGING section ----------------------------------
 {% include "logging.lua.j2" %}
 
--- SUPERVISOR section -------------------------------
-{% include "supervisor.lua.j2" %}
+-- WATCHDOG section -------------------------------
+{% include "watchdog.lua.j2" %}
 
 -- WEBMGMT section ----------------------------------
 {% include "webmgmt.lua.j2" %}
diff --git a/manager/knot_resolver_manager/datamodel/templates/supervisor.lua.j2 b/manager/knot_resolver_manager/datamodel/templates/supervisor.lua.j2
deleted file mode 100644 (file)
index 3d352ec..0000000
+++ /dev/null
@@ -1,9 +0,0 @@
-{% 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
diff --git a/manager/knot_resolver_manager/datamodel/templates/watchdog.lua.j2 b/manager/knot_resolver_manager/datamodel/templates/watchdog.lua.j2
new file mode 100644 (file)
index 0000000..1288b3d
--- /dev/null
@@ -0,0 +1,9 @@
+{% 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
diff --git a/manager/knot_resolver_manager/datamodel/watchdog_schema.py b/manager/knot_resolver_manager/datamodel/watchdog_schema.py
new file mode 100644 (file)
index 0000000..99d4a4e
--- /dev/null
@@ -0,0 +1,15 @@
+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
index 2381db846da95a686f41fa1a1103f48c2af44ad0..68bf4271c90fd9a963bda838596971e0d7809a33 100644 (file)
@@ -23,8 +23,6 @@ from knot_resolver_manager.constants import DEFAULT_MANAGER_CONFIG_FILE, PID_FIL
 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
@@ -313,14 +311,10 @@ async def _init_manager(config_store: ConfigStore, server: Server) -> KresManage
     """
     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
diff --git a/manager/tests/unit/datamodel/test_supervisor_schema.py b/manager/tests/unit/datamodel/test_supervisor_schema.py
deleted file mode 100644 (file)
index 4cc78d5..0000000
+++ /dev/null
@@ -1,9 +0,0 @@
-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"}})