Skip to content

Commit 9588fa8

Browse files
committed
datamodel: renamed defer section to prioritization
- renamed /defer/log-period -> /defer/logging-period
1 parent cea4022 commit 9588fa8

File tree

10 files changed

+46
-41
lines changed

10 files changed

+46
-41
lines changed

NEWS

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ Incompatible changes
2323
- /webmgmt
2424
- /workers-max
2525
- Renamed/moved options in the declarative configuration model (YAML).
26+
- /defer/* -> /prioritization/*
27+
- /defer/log-period -> /defer/logging-period
2628
- /network/tls/files-watchdog -> /network/tls/watchdog
2729
- /dns64: true -> /dns64/enabled: true
2830
- /dns64/rev-ttl -> /dns64/reverse-ttl

doc/_static/config.schema.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1610,16 +1610,16 @@
16101610
},
16111611
"default": null
16121612
},
1613-
"defer": {
1613+
"prioritization": {
16141614
"description": "Configuration of request prioritization (defer).",
16151615
"type": "object",
16161616
"properties": {
16171617
"enabled": {
16181618
"type": "boolean",
1619-
"description": "Use request prioritization.",
1619+
"description": "Enable/disable request prioritization.",
16201620
"default": false
16211621
},
1622-
"log-period": {
1622+
"logging-period": {
16231623
"type": "string",
16241624
"pattern": "^(\\d+)(us|ms|s|m|h|d)$",
16251625
"description": "Minimal time between two log messages, or '0s' to disable.",
@@ -1628,7 +1628,7 @@
16281628
},
16291629
"default": {
16301630
"enabled": false,
1631-
"log_period": "0s"
1631+
"logging_period": "0s"
16321632
}
16331633
},
16341634
"lua": {

python/knot_resolver/datamodel/config_schema.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55

66
from knot_resolver.constants import API_SOCK_FILE, RUN_DIR, VERSION
77
from knot_resolver.datamodel.cache_schema import CacheSchema
8-
from knot_resolver.datamodel.defer_schema import DeferSchema
98
from knot_resolver.datamodel.dns64_schema import Dns64Schema
109
from knot_resolver.datamodel.dnssec_schema import DnssecSchema
1110
from knot_resolver.datamodel.forward_schema import ForwardSchema
@@ -17,6 +16,7 @@
1716
from knot_resolver.datamodel.monitoring_schema import MonitoringSchema
1817
from knot_resolver.datamodel.network_schema import NetworkSchema
1918
from knot_resolver.datamodel.options_schema import OptionsSchema
19+
from knot_resolver.datamodel.prioritization_schema import PrioritizationSchema
2020
from knot_resolver.datamodel.rate_limiting_schema import RateLimitingSchema
2121
from knot_resolver.datamodel.templates import POLICY_CONFIG_TEMPLATE, WORKER_CONFIG_TEMPLATE
2222
from knot_resolver.datamodel.types import EscapedStr, IntPositive, WritableDir
@@ -106,7 +106,7 @@ class Raw(ConfigSchema):
106106
monitoring: Metrics exposisition configuration (Prometheus, Graphite)
107107
lua: Custom Lua configuration.
108108
rate_limiting: Configuration of rate limiting.
109-
defer: Configuration of request prioritization (defer).
109+
prioritization: Configuration of request prioritization (defer).
110110
"""
111111

112112
version: int = 1
@@ -126,7 +126,7 @@ class Raw(ConfigSchema):
126126
logging: LoggingSchema = LoggingSchema()
127127
monitoring: MonitoringSchema = MonitoringSchema()
128128
rate_limiting: Optional[RateLimitingSchema] = None
129-
defer: DeferSchema = DeferSchema()
129+
prioritization: PrioritizationSchema = PrioritizationSchema()
130130
lua: LuaSchema = LuaSchema()
131131

132132
_LAYER = Raw
@@ -147,7 +147,7 @@ class Raw(ConfigSchema):
147147
logging: LoggingSchema
148148
monitoring: MonitoringSchema
149149
rate_limiting: Optional[RateLimitingSchema]
150-
defer: DeferSchema
150+
prioritization: PrioritizationSchema
151151
lua: LuaSchema
152152

153153
def _hostname(self, obj: Raw) -> Any:

python/knot_resolver/datamodel/defer_schema.py

Lines changed: 0 additions & 15 deletions
This file was deleted.
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
from knot_resolver.datamodel.types import TimeUnit
2+
from knot_resolver.utils.modeling import ConfigSchema
3+
4+
5+
class PrioritizationSchema(ConfigSchema):
6+
"""
7+
Configuration of request prioritization (defer).
8+
9+
---
10+
enabled: Enable/disable request prioritization.
11+
logging_period: Minimal time between two log messages, or '0s' to disable.
12+
"""
13+
14+
enabled: bool = False
15+
logging_period: TimeUnit = TimeUnit("0s")

python/knot_resolver/datamodel/templates/defer.lua.j2

Lines changed: 0 additions & 10 deletions
This file was deleted.

python/knot_resolver/datamodel/templates/policy-config.lua.j2

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,10 @@ cache.open({{ cfg.cache.size_max.bytes() }}, 'lmdb://{{ cfg.cache.storage }}')
3535
-- FORWARD section ----------------------------------
3636
{% include "forward.lua.j2" %}
3737

38-
-- DEFER section ------------------------------------
38+
-- PRIORITIZATION section ------------------------------------
3939
-- Force-disable defer to avoid the default defer config.
40-
{% set disable_defer = true %}
41-
{% include "defer.lua.j2" %}
40+
{% set disable_prioritization = true %}
41+
{% include "prioritization.lua.j2" %}
4242

4343
{% endif %}
4444

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{% if cfg.prioritization.enabled and not disable_prioritization %}
2+
-- Enable and configure request prioritization (defer)
3+
assert(
4+
C.defer_init(
5+
'{{ cfg.rundir }}/defer',
6+
{{ cfg.prioritization.logging_period.millis() }},
7+
{{ cfg.workers }}
8+
) == 0
9+
)
10+
{% else %}
11+
-- Disable request prioritization (defer)
12+
assert(C.defer_init(nil, 0, 0) == 0)
13+
{% endif %}

python/knot_resolver/datamodel/templates/worker-config.lua.j2

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,8 @@ nsid.name('{{ cfg.nsid }}' .. worker.id)
4343
-- RATE-LIMITING section ------------------------------------
4444
{% include "rate_limiting.lua.j2" %}
4545

46-
-- DEFER section ------------------------------------
47-
{% include "defer.lua.j2" %}
46+
-- PRIORITIZATION section ------------------------------------
47+
{% include "prioritization.lua.j2" %}
4848

4949
{% endif %}
5050

python/knot_resolver/manager/manager.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -128,9 +128,9 @@ def config_nodes(config: KresConfig) -> List[Any]:
128128
config.dns64,
129129
config.logging,
130130
config.monitoring,
131-
config.lua,
132131
config.rate_limiting,
133-
config.defer,
132+
config.prioritization,
133+
config.lua,
134134
]
135135

136136
# register and immediately call a verifier that validates config with 'canary' kresd process
@@ -225,7 +225,7 @@ async def validate_config(self, _old: KresConfig, new: KresConfig) -> Result[Non
225225
os.unlink(str(_old.rundir) + "/ratelimiting")
226226
except FileNotFoundError:
227227
pass
228-
if _old.workers != new.workers or _old.defer != new.defer:
228+
if _old.workers != new.workers or _old.prioritization != new.prioritization:
229229
logger.debug("Unlinking shared defer memory")
230230
try:
231231
os.unlink(str(_old.rundir) + "/defer")

0 commit comments

Comments
 (0)