]> git.ipfire.org Git - thirdparty/knot-resolver.git/commitdiff
kresctl: migrate: added migration for /monitoring/* config
authorAleš Mrázek <ales.mrazek@nic.cz>
Mon, 19 May 2025 14:03:24 +0000 (16:03 +0200)
committerAleš Mrázek <ales.mrazek@nic.cz>
Tue, 5 Aug 2025 09:23:05 +0000 (11:23 +0200)
etc/config/config.migrate.yaml
python/knot_resolver/client/commands/migrate.py

index c7c933e260fdae9c9eb2271891a8f18c0051225f..a289e0171ac86884a6122653ab3eafb85a4b8734 100644 (file)
@@ -27,6 +27,11 @@ logging:
     assertion-abort: false
     assertion-fork: 5m
 
+monitoring:
+  # graphite: false
+  graphite:
+    host: 127.0.0.1
+
 network:
   tls:
     auto-discovery: true
@@ -38,4 +43,4 @@ webmgmt:
 max-workers: 64
 
 rate-limiting:
-  rate-limit: 100
\ No newline at end of file
+  rate-limit: 100
index 06e377ae55aa2f7ecf02e2af94684e6d9fb568e4..364325916773a03dba72fc5b662c396009d9caf2 100644 (file)
@@ -4,6 +4,7 @@ import sys
 from typing import Any, Dict, List, Optional, Tuple, Type
 
 from knot_resolver.client.command import Command, CommandArgs, CompWords, comp_get_words, register_command
+from knot_resolver.constants import VERSION
 from knot_resolver.utils.modeling.exceptions import DataParsingError
 from knot_resolver.utils.modeling.parsing import DataFormat, try_to_parse
 
@@ -18,7 +19,7 @@ def _remove(config: Dict[str, Any], path: str) -> Optional[Any]:
             current = current[key]
         else:
             return None
-    if isinstance (current, dict) and last in current:
+    if isinstance(current, dict) and last in current:
         val = copy.copy(current[last])
         del current[last]
         print(f"removed {path}")
@@ -98,7 +99,7 @@ class MigrateCommand(Command):
     def completion(args: List[str], parser: argparse.ArgumentParser) -> CompWords:
         return comp_get_words(args, parser)
 
-    def run(self, args: CommandArgs) -> None:
+    def run(self, args: CommandArgs) -> None:  # noqa: PLR0912, PLR0915
         with open(self.input_file, "r") as f:
             data = f.read()
 
@@ -140,6 +141,16 @@ class MigrateCommand(Command):
         _rename(new, "/dnssec/trust-anchor-sentinel", "/dnssec/sentinel")
         _rename(new, "/dnssec/trust-anchor-signal-query", "/dnssec/signal-query")
         _rename(new, "/logging/dnssec-bogus", "/dnssec/log-bogus")
+        _rename(new, "/monitoring/enabled", "/monitoring/metrics")
+        monitoring_key = "monitoring"
+        if monitoring_key in new:
+            graphite_key = "graphite"
+            if graphite_key in new[monitoring_key]:
+                graphite = new[monitoring_key][graphite_key]
+                if graphite is False:
+                    _add(new, "/monitoring/graphite/enabled", False)
+                else:
+                    _add(new, "/monitoring/graphite/enabled", True)
         _rename(new, "/network/tls/files-watchdog", "/network/tls/watchdog")
         rate_limiting_key = "rate-limiting"
         if rate_limiting_key in new:
@@ -153,6 +164,6 @@ class MigrateCommand(Command):
             with open(self.output_file, "w") as f:
                 f.write(dumped)
         else:
-            print("\nNew migrated configuration:")
+            print(f"\nNew migrated configuration (v{VERSION}):")
             print("---")
             print(dumped)