From 5ca2c5fe48c16d04c2e3663eaf27a30406ba35b2 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Ale=C5=A1=20Mr=C3=A1zek?= Date: Mon, 2 Jun 2025 13:47:13 +0200 Subject: [PATCH] python: datamodel: **/enabled configuration renamed to **/enable --- NEWS | 10 +++---- doc/_static/config.schema.json | 28 +++++++++---------- doc/user/config-defer.rst | 2 +- doc/user/config-dns64.rst | 4 +-- doc/user/config-dnssec.rst | 4 +-- doc/user/config-monitoring-stats.rst | 6 ++-- doc/user/config-rate-limiting.rst | 2 +- etc/config/config.test-defer.yaml | 2 +- .../knot_resolver/client/commands/migrate.py | 16 +++++------ .../knot_resolver/datamodel/cache_schema.py | 4 +-- .../knot_resolver/datamodel/defer_schema.py | 4 +-- .../knot_resolver/datamodel/dns64_schema.py | 4 +-- .../knot_resolver/datamodel/dnssec_schema.py | 4 +-- .../datamodel/monitoring_schema.py | 4 +-- .../datamodel/rate_limiting_schema.py | 6 ++-- .../datamodel/templates/defer.lua.j2 | 2 +- .../datamodel/templates/dns64.lua.j2 | 2 +- .../datamodel/templates/dnssec.lua.j2 | 2 +- .../datamodel/templates/rate_limiting.lua.j2 | 2 +- python/knot_resolver/manager/manager.py | 4 +-- .../manager/metrics/prometheus.py | 8 +++--- tests/manager/datamodel/test_config_schema.py | 12 ++++---- 22 files changed, 66 insertions(+), 66 deletions(-) diff --git a/NEWS b/NEWS index a2ab49098..3c5efe89e 100644 --- a/NEWS +++ b/NEWS @@ -19,18 +19,18 @@ Incompatible changes - /network/tls/auto-discovery - /webmgmt - Renamed/moved options in the declarative configuration model (YAML). - - /cache/garbage-collector -> /cache/garbage-collector/enabled - - /dns64: true|false -> /dns64/enabled: true|false + - /cache/garbage-collector -> /cache/garbage-collector/enable + - /dns64: true|false -> /dns64/enable: true|false - /dns64/rev-ttl -> /dns64/reverse-ttl - - /dnssec: true|false -> /dnssec/enabled: true|false + - /dnssec: true|false -> /dnssec/enable: true|false - /dnssec/keep-removed -> /dnssec/trust-anchors-keep-removed - /dnssec/trust-anchor-sentinel -> /dnssec/sentinel - /dnssec/trust-anchor-signal-query -> /dnssec/signal-query - /logging/dnssec-bogus -> /dnssec/log-bogus - /monitoring/enabled -> /monitoring/metrics - - /monitoring/graphite -> /monitoring/graphite/enabled + - /monitoring/graphite -> /monitoring/graphite/enable - /network/tls/files-watchdog -> /network/tls/watchdog - - /rate-limiting -> /rate-limiting/enabled + - /rate-limiting -> /rate-limiting/enable Knot Resolver 6.0.15 (2025-07-17) diff --git a/doc/_static/config.schema.json b/doc/_static/config.schema.json index 85ae6a365..82d5217d5 100644 --- a/doc/_static/config.schema.json +++ b/doc/_static/config.schema.json @@ -1039,7 +1039,7 @@ "description": "Use the garbage collector (kres-cache-gc) to periodically clear cache.", "type": "object", "properties": { - "enabled": { + "enable": { "type": "boolean", "description": "Enable/disable cache garbage collector.", "default": true @@ -1101,7 +1101,7 @@ } }, "default": { - "enabled": true, + "enable": true, "interval": "1s", "threshold": 80, "release": 10, @@ -1210,7 +1210,7 @@ "storage": "/var/cache/knot-resolver", "size_max": "100M", "garbage_collector": { - "enabled": true, + "enable": true, "interval": "1s", "threshold": 80, "release": 10, @@ -1235,7 +1235,7 @@ "description": "DNSSEC configuration.", "type": "object", "properties": { - "enabled": { + "enable": { "type": "boolean", "description": "Enable/disable DNSSEC.", "default": true @@ -1309,7 +1309,7 @@ } }, "default": { - "enabled": true, + "enable": true, "log_bogus": false, "sentinel": true, "signal_query": true, @@ -1323,7 +1323,7 @@ "description": "DNS64 (RFC 6147) configuration.", "type": "object", "properties": { - "enabled": { + "enable": { "type": "boolean", "description": "Enable/disable DNS64.", "default": false @@ -1355,7 +1355,7 @@ } }, "default": { - "enabled": false, + "enable": false, "prefix": "64:ff9b::/96", "reverse_ttl": null, "exclude_subnets": null @@ -1523,7 +1523,7 @@ "graphite": { "type": "object", "properties": { - "enabled": { + "enable": { "type": "boolean", "default": false }, @@ -1567,7 +1567,7 @@ }, "description": "optionally configures where should graphite metrics be sent to", "default": { - "enabled": false, + "enable": false, "host": null, "port": 2003, "prefix": "", @@ -1579,7 +1579,7 @@ "default": { "metrics": "lazy", "graphite": { - "enabled": false, + "enable": false, "host": null, "port": 2003, "prefix": "", @@ -1592,7 +1592,7 @@ "description": "Configuration of rate limiting.", "type": "object", "properties": { - "enabled": { + "enable": { "type": "boolean", "description": "Enable/disable rate limiting", "default": false @@ -1638,7 +1638,7 @@ } }, "default": { - "enabled": false, + "enable": false, "rate_limit": null, "instant_limit": 50, "capacity": 524288, @@ -1651,7 +1651,7 @@ "description": "Configuration of request prioritization (defer).", "type": "object", "properties": { - "enabled": { + "enable": { "type": "boolean", "description": "Use request prioritization.", "default": false @@ -1664,7 +1664,7 @@ } }, "default": { - "enabled": false, + "enable": false, "log_period": "0s" } }, diff --git a/doc/user/config-defer.rst b/doc/user/config-defer.rst index 4d26ee403..bd0a30cff 100644 --- a/doc/user/config-defer.rst +++ b/doc/user/config-defer.rst @@ -23,7 +23,7 @@ The limits can be adjusted for different packet origins using :option:`price-fac The data of all deferred queries may occupy 64 MiB of memory per :ref:`worker `. -.. option:: defer/enabled: true|false +.. option:: defer/enable: true|false :default: false diff --git a/doc/user/config-dns64.rst b/doc/user/config-dns64.rst index 6e87518cf..5d36ca720 100644 --- a/doc/user/config-dns64.rst +++ b/doc/user/config-dns64.rst @@ -15,14 +15,14 @@ By default, the well-known prefix ``64:ff9b::/96`` is used. .. code-block:: yaml dns64: - enabled: true + enable: true It is also possible to configure own prefix. .. code-block:: yaml dns64: - enabled: true + enable: true prefix: 2001:db8::aabb:0:0/96 .. warning:: diff --git a/doc/user/config-dnssec.rst b/doc/user/config-dnssec.rst index f3cd45f60..7b05578be 100644 --- a/doc/user/config-dnssec.rst +++ b/doc/user/config-dnssec.rst @@ -21,7 +21,7 @@ system by doing so, add the following snippet to your configuration file. # turns off DNSSEC validation dnssec: - enabled: false + enable: false The resolver supports DNSSEC including :rfc:`5011` automated DNSSEC TA updates and :rfc:`7646` negative trust anchors. Depending on your distribution, DNSSEC @@ -37,7 +37,7 @@ Following :option:`dnssec >` section allows to modify DNSSEC c DNSSEC configuration options. - .. option:: enabled: true|false + .. option:: enable: true|false :default: true diff --git a/doc/user/config-monitoring-stats.rst b/doc/user/config-monitoring-stats.rst index e5c41f443..d5782f529 100644 --- a/doc/user/config-monitoring-stats.rst +++ b/doc/user/config-monitoring-stats.rst @@ -11,7 +11,7 @@ and server internals, and offers them as a key-value storage. .. code-block:: yaml monitoring: - enabled: always + enable: always These metrics can be either exported to :ref:`config-monitoring-graphite` or exposed as :ref:`config-monitoring-prometheus`. @@ -62,14 +62,14 @@ Example configuration: monitoring: graphite: - enabled: true + enable: true host: 127.0.0.1 # graphite server address port: 200 # optional graphite server port (2003 is default) interval: 5s # optional publish interval (5s is default) .. option:: monitoring/graphite: - .. option:: enabled: true|false + .. option:: enable: true|false :default: false diff --git a/doc/user/config-rate-limiting.rst b/doc/user/config-rate-limiting.rst index d455c4a40..18c5578f8 100644 --- a/doc/user/config-rate-limiting.rst +++ b/doc/user/config-rate-limiting.rst @@ -21,7 +21,7 @@ that's common in other DNS servers. The limits can be adjusted for different packet origins using :option:`price-factor ` in :ref:`views `. -.. option:: rate-limiting/enabled: true|false +.. option:: rate-limiting/enable: true|false :default: false diff --git a/etc/config/config.test-defer.yaml b/etc/config/config.test-defer.yaml index f1dd8a568..3b463e308 100644 --- a/etc/config/config.test-defer.yaml +++ b/etc/config/config.test-defer.yaml @@ -1,3 +1,3 @@ defer: - enabled: true + enable: true log-period: 1s diff --git a/python/knot_resolver/client/commands/migrate.py b/python/knot_resolver/client/commands/migrate.py index bad7d3097..2b11f83d1 100644 --- a/python/knot_resolver/client/commands/migrate.py +++ b/python/knot_resolver/client/commands/migrate.py @@ -129,20 +129,20 @@ class MigrateCommand(Command): if gc_key in new[cache_key]: gc = new[cache_key][gc_key] if gc is False: - _add(new, "/cache/garbage-collector/enabled", False) + _add(new, "/cache/garbage-collector/enable", False) else: - _add(new, "/cache/garbage-collector/enabled", True) + _add(new, "/cache/garbage-collector/enable", True) dns64_key = "dns64" if dns64_key in new: if new[dns64_key] is False: - _add(new, "/dns64/enabled", False, rewrite=True) + _add(new, "/dns64/enable", False, rewrite=True) else: - _add(new, "/dns64/enabled", True, rewrite=True) + _add(new, "/dns64/enable", True, rewrite=True) _rename(new, "/dns64/rev-ttl", "/dns64/reverse-ttl") dnssec_key = "dnssec" if dnssec_key in new: if new[dnssec_key] is False: - _add(new, "/dnssec/enabled", False, rewrite=True) + _add(new, "/dnssec/enable", False, rewrite=True) else: # by default the DNSSEC is enabled pass @@ -157,13 +157,13 @@ class MigrateCommand(Command): if graphite_key in new[monitoring_key]: graphite = new[monitoring_key][graphite_key] if graphite is False: - _add(new, "/monitoring/graphite/enabled", False) + _add(new, "/monitoring/graphite/enable", False) else: - _add(new, "/monitoring/graphite/enabled", True) + _add(new, "/monitoring/graphite/enable", True) _rename(new, "/network/tls/files-watchdog", "/network/tls/watchdog") rate_limiting_key = "rate-limiting" if rate_limiting_key in new: - _add(new, "/rate-limiting/enabled", True) + _add(new, "/rate-limiting/enable", True) # remove empty dicts new = {k: v for k, v in new.items() if v} diff --git a/python/knot_resolver/datamodel/cache_schema.py b/python/knot_resolver/datamodel/cache_schema.py index 630728207..a4d525c6c 100644 --- a/python/knot_resolver/datamodel/cache_schema.py +++ b/python/knot_resolver/datamodel/cache_schema.py @@ -62,7 +62,7 @@ class GarbageCollectorSchema(ConfigSchema): Configuration options of the cache garbage collector (kres-cache-gc). --- - enabled: Enable/disable cache garbage collector. + enable: Enable/disable cache garbage collector. interval: Time interval how often the garbage collector will be run. threshold: Cache usage in percent that triggers the garbage collector. release: Percent of used cache to be freed by the garbage collector. @@ -74,7 +74,7 @@ class GarbageCollectorSchema(ConfigSchema): dry_run: Run the garbage collector in dry-run mode. """ - enabled: bool = True + enable: bool = True interval: TimeUnit = TimeUnit("1s") threshold: Percent = Percent(80) release: Percent = Percent(10) diff --git a/python/knot_resolver/datamodel/defer_schema.py b/python/knot_resolver/datamodel/defer_schema.py index 81546a075..abe5f0b0d 100644 --- a/python/knot_resolver/datamodel/defer_schema.py +++ b/python/knot_resolver/datamodel/defer_schema.py @@ -7,9 +7,9 @@ class DeferSchema(ConfigSchema): Configuration of request prioritization (defer). --- - enabled: Use request prioritization. + enable: Use request prioritization. log_period: Minimal time between two log messages, or '0s' to disable. """ - enabled: bool = False + enable: bool = False log_period: TimeUnit = TimeUnit("0s") diff --git a/python/knot_resolver/datamodel/dns64_schema.py b/python/knot_resolver/datamodel/dns64_schema.py index 130ad9722..f742c64eb 100644 --- a/python/knot_resolver/datamodel/dns64_schema.py +++ b/python/knot_resolver/datamodel/dns64_schema.py @@ -9,13 +9,13 @@ class Dns64Schema(ConfigSchema): DNS64 (RFC 6147) configuration. --- - enabled: Enable/disable DNS64. + enable: Enable/disable DNS64. prefix: IPv6 prefix to be used for synthesizing AAAA records. reverse_ttl: TTL in CNAME generated in the reverse 'ip6.arpa.' subtree. exclude_subnets: IPv6 subnets that are disallowed in answer. """ - enabled: bool = False + enable: bool = False prefix: IPv6Network96 = IPv6Network96("64:ff9b::/96") reverse_ttl: Optional[TimeUnit] = None exclude_subnets: Optional[List[IPv6Network]] = None diff --git a/python/knot_resolver/datamodel/dnssec_schema.py b/python/knot_resolver/datamodel/dnssec_schema.py index 4044a0b8e..50f5dcaa0 100644 --- a/python/knot_resolver/datamodel/dnssec_schema.py +++ b/python/knot_resolver/datamodel/dnssec_schema.py @@ -23,7 +23,7 @@ class DnssecSchema(ConfigSchema): DNSSEC configuration. --- - enabled: Enable/disable DNSSEC. + enable: Enable/disable DNSSEC. log_bogus: Enable logging for each DNSSEC validation failure if '/logging/level' is set to at least 'notice'. sentinel: Allows users of DNSSEC validating resolver to detect which root keys are configured in resolver's chain of trust. (RFC 8509) signal_query: Signaling Trust Anchor Knowledge in DNSSEC Using Key Tag Query, according to (RFC 8145#section-5). @@ -34,7 +34,7 @@ class DnssecSchema(ConfigSchema): negative_trust_anchors: List of domain names representing negative trust-anchors. (RFC 7646) """ - enabled: bool = True + enable: bool = True log_bogus: bool = False sentinel: bool = True signal_query: bool = True diff --git a/python/knot_resolver/datamodel/monitoring_schema.py b/python/knot_resolver/datamodel/monitoring_schema.py index 9308e3338..31dc6a0f2 100644 --- a/python/knot_resolver/datamodel/monitoring_schema.py +++ b/python/knot_resolver/datamodel/monitoring_schema.py @@ -5,7 +5,7 @@ from knot_resolver.utils.modeling import ConfigSchema class GraphiteSchema(ConfigSchema): - enabled: bool = False + enable: bool = False host: Union[None, IPAddress, DomainName] = None port: PortNumber = PortNumber(2003) prefix: EscapedStr = EscapedStr("") @@ -13,7 +13,7 @@ class GraphiteSchema(ConfigSchema): tcp: bool = False def _validate(self) -> None: - if self.enabled and not self.host: + if self.enable and not self.host: raise ValueError("'host' option must be configured to enable graphite bridge") diff --git a/python/knot_resolver/datamodel/rate_limiting_schema.py b/python/knot_resolver/datamodel/rate_limiting_schema.py index 3a8116dab..846a95c03 100644 --- a/python/knot_resolver/datamodel/rate_limiting_schema.py +++ b/python/knot_resolver/datamodel/rate_limiting_schema.py @@ -13,7 +13,7 @@ class RateLimitingSchema(ConfigSchema): Configuration of rate limiting. --- - enabled: Enable/disable rate limiting + enable: Enable/disable rate limiting rate_limit: Maximal number of allowed queries per second from a single host. instant_limit: Maximal number of allowed queries at a single point in time from a single host. capacity: Expected maximal number of blocked networks/hosts at the same time. @@ -22,7 +22,7 @@ class RateLimitingSchema(ConfigSchema): dry_run: Perform only classification and logging but no restrictions. """ - enabled: bool = False + enable: bool = False rate_limit: Optional[IntPositive] = None instant_limit: IntPositive = IntPositive(50) capacity: IntPositive = IntPositive(524288) @@ -31,7 +31,7 @@ class RateLimitingSchema(ConfigSchema): dry_run: bool = False def _validate(self) -> None: - if self.enabled and not self.rate_limit: + if self.enable and not self.rate_limit: raise ValueError("'rate-limit' has to be configured to enable rate limiting") max_instant_limit = int(2**32 // 768 - 1) diff --git a/python/knot_resolver/datamodel/templates/defer.lua.j2 b/python/knot_resolver/datamodel/templates/defer.lua.j2 index 5dacff75f..9961435bc 100644 --- a/python/knot_resolver/datamodel/templates/defer.lua.j2 +++ b/python/knot_resolver/datamodel/templates/defer.lua.j2 @@ -1,6 +1,6 @@ {% from 'macros/common_macros.lua.j2' import boolean %} -{% if cfg.defer.enabled and disable_defer is not defined -%} +{% if cfg.defer.enable and disable_defer is not defined -%} assert(C.defer_init( '{{ cfg.rundir }}/defer', {{ cfg.defer.log_period.millis() }}, diff --git a/python/knot_resolver/datamodel/templates/dns64.lua.j2 b/python/knot_resolver/datamodel/templates/dns64.lua.j2 index f23093464..98a49703d 100644 --- a/python/knot_resolver/datamodel/templates/dns64.lua.j2 +++ b/python/knot_resolver/datamodel/templates/dns64.lua.j2 @@ -1,6 +1,6 @@ {% from 'macros/common_macros.lua.j2' import string_table %} -{% if cfg.dns64.enabled %} +{% if cfg.dns64.enable %} -- Enable DNS64 by loading module modules.load('dns64') diff --git a/python/knot_resolver/datamodel/templates/dnssec.lua.j2 b/python/knot_resolver/datamodel/templates/dnssec.lua.j2 index 1fbaf4d2b..e3a3efdf7 100644 --- a/python/knot_resolver/datamodel/templates/dnssec.lua.j2 +++ b/python/knot_resolver/datamodel/templates/dnssec.lua.j2 @@ -1,6 +1,6 @@ {% from 'macros/common_macros.lua.j2' import boolean %} -{% if cfg.dnssec.enabled %} +{% if cfg.dnssec.enable %} -- dnssec.logging-bogus {% if cfg.dnssec.log_bogus %} diff --git a/python/knot_resolver/datamodel/templates/rate_limiting.lua.j2 b/python/knot_resolver/datamodel/templates/rate_limiting.lua.j2 index 0b6bd8142..be24f627e 100644 --- a/python/knot_resolver/datamodel/templates/rate_limiting.lua.j2 +++ b/python/knot_resolver/datamodel/templates/rate_limiting.lua.j2 @@ -1,6 +1,6 @@ {% from 'macros/common_macros.lua.j2' import boolean %} -{% if cfg.rate_limiting.enabled %} +{% if cfg.rate_limiting.enable %} assert( C.ratelimiting_init( '{{ cfg.rundir }}/ratelimiting', diff --git a/python/knot_resolver/manager/manager.py b/python/knot_resolver/manager/manager.py index 3acdd3d4c..5eff54b40 100644 --- a/python/knot_resolver/manager/manager.py +++ b/python/knot_resolver/manager/manager.py @@ -291,8 +291,8 @@ class KresManager: # pylint: disable=too-many-instance-attributes await self._rolling_restart(config) await self._ensure_number_of_children(config, int(config.workers)) - if self._is_gc_running() != config.cache.garbage_collector.enabled: - if config.cache.garbage_collector.enabled: + if self._is_gc_running() != config.cache.garbage_collector.enable: + if config.cache.garbage_collector.enable: logger.debug("Starting cache GC") await self._start_gc(config) else: diff --git a/python/knot_resolver/manager/metrics/prometheus.py b/python/knot_resolver/manager/metrics/prometheus.py index 659e110cd..e18018686 100644 --- a/python/knot_resolver/manager/metrics/prometheus.py +++ b/python/knot_resolver/manager/metrics/prometheus.py @@ -400,7 +400,7 @@ if PROMETHEUS_LIB: Starts graphite bridge if required """ global _graphite_bridge - if config.monitoring.graphite.enabled and _graphite_bridge is None: + if config.monitoring.graphite.enable and _graphite_bridge is None: logger.info( "Starting Graphite metrics exporter for [%s]:%d", str(config.monitoring.graphite.host), @@ -414,14 +414,14 @@ if PROMETHEUS_LIB: ) async def _deny_turning_off_graphite_bridge(old_config: KresConfig, new_config: KresConfig) -> Result[None, str]: - if old_config.monitoring.graphite.enabled and not new_config.monitoring.graphite.enabled: + if old_config.monitoring.graphite.enable and not new_config.monitoring.graphite.enable: return Result.err( "You can't turn off graphite monitoring dynamically. If you really want this feature, please let the developers know." ) if ( - old_config.monitoring.graphite.enabled - and new_config.monitoring.graphite.enabled + old_config.monitoring.graphite.enable + and new_config.monitoring.graphite.enable and old_config.monitoring.graphite != new_config.monitoring.graphite ): return Result.err("Changing graphite exporter configuration in runtime is not allowed.") diff --git a/tests/manager/datamodel/test_config_schema.py b/tests/manager/datamodel/test_config_schema.py index 9ad424c15..4e9dfbc0b 100644 --- a/tests/manager/datamodel/test_config_schema.py +++ b/tests/manager/datamodel/test_config_schema.py @@ -50,20 +50,20 @@ def test_config_defaults(): config = KresConfig() # DNS64 default - assert config.dns64.enabled == False + assert config.dns64.enable == False def test_dnssec_false(): - config = KresConfig({"dnssec": {"enabled": False}}) + config = KresConfig({"dnssec": {"enable": False}}) - assert config.dnssec.enabled == False + assert config.dnssec.enable == False def test_dnssec_default_true(): config = KresConfig() # DNSSEC defaults - assert config.dnssec.enabled == True + assert config.dnssec.enable == True assert config.dnssec.sentinel == True assert config.dnssec.signal_query == True assert int(config.dnssec.trust_anchors_keep_removed) == 0 @@ -73,9 +73,9 @@ def test_dnssec_default_true(): def test_dns64_prefix_default(): - config = KresConfig({"dns64": {"enabled": True}}) + config = KresConfig({"dns64": {"enable": True}}) - assert config.dns64.enabled == True + assert config.dns64.enable == True assert str(config.dns64.prefix) == "64:ff9b::/96" -- 2.47.2