zonedb-load: fix zone loading which were included by conf-set include

This commit is contained in:
Daniel Salzman 2025-10-08 18:06:00 +02:00
parent 6ae4d2cfef
commit 7bb86cbe19
3 changed files with 45 additions and 7 deletions

View file

@ -483,6 +483,26 @@ static knot_zonedb_t *create_zonedb_commit(conf_t *conf, server_t *server)
return NULL;
}
assert(conf->io.flags & CONF_IO_FACTIVE);
bool include = conf->io.flags & CONF_IO_FDIFF_ZONES;
// Insert possibly added zones by conf-set include.
if (include) {
for (conf_iter_t it = conf_iter(conf, C_ZONE); it.code == KNOT_EOK;
conf_iter_next(conf, &it)) {
conf_val_t id = conf_iter_id(conf, &it);
const knot_dname_t *name = conf_dname(&id);
zone_t *zone = knot_zonedb_find(db_new, name);
if (zone == NULL) { // Create an included zone.
zone = get_zone(conf, name, server, NULL);
if (zone == NULL) {
continue;
}
knot_zonedb_insert(db_new, zone);
}
}
}
if (conf->io.zones != NULL) {
trie_it_t *trie_it = trie_it_begin(conf->io.zones);
for (; !trie_it_finished(trie_it); trie_it_next(trie_it)) {

View file

@ -30,6 +30,12 @@ ctl = libknot.control.KnotCtl()
t.start()
knot.use_confdb = True
knot.gen_confile()
knot.ctl("conf-import %s" % knot.confile, availability=False)
knot.stop()
knot.start()
ctl.connect(os.path.join(knot.dir, "knot.sock"))
ctl.send_block(cmd="conf-begin")
@ -37,9 +43,11 @@ resp = ctl.receive_block()
ctl.send_block(cmd="conf-set", section="include", data=added_file)
resp = ctl.receive_block()
# Cannot commit as it reloads the server without this include!
ctl.send_block(cmd="conf-get", section="zone")
ctl.send_block(cmd="conf-commit")
resp = ctl.receive_block()
ctl.send_block(cmd="conf-read", section="zone")
resp = ctl.receive_block()
isset(ZONE1 in resp['zone'], ZONE1)
@ -47,15 +55,20 @@ isset(ZONE2 in resp['zone'], ZONE2)
isset(ZONE3 in resp['zone'], ZONE3)
isset(ZONE4 in resp['zone'], ZONE4)
ctl.send_block(cmd="conf-commit")
resp = ctl.receive_block()
ctl.send_block(cmd="conf-read", section="server")
resp = ctl.receive_block()
isset('tcp-max-clients' in resp['server'], "server section item not set")
isset('5' in resp['server']['tcp-max-clients'], "server section item value not set")
ctl.send_block(cmd="zone-status")
resp = ctl.receive_block()
isset(ZONE1 in resp, ZONE1)
isset(ZONE2 in resp, ZONE2)
isset(ZONE3 in resp, ZONE3)
isset(ZONE4 in resp, ZONE4)
ctl.send(libknot.control.KnotCtlType.END)
ctl.close()

View file

@ -158,6 +158,7 @@ class Server(object):
self.start_params = None
self.ctl_params = None
self.ctl_params_append = None # The last parameter wins.
self.use_confdb = False
self.data_dir = None
@ -2048,8 +2049,12 @@ class Knot(Server):
s.item_str("quic", "debug")
s.end()
self.start_params = ["-c", self.confile]
self.ctl_params = ["-c", self.confile, "-t", "15"]
if self.use_confdb:
conf_params = ["-C", os.path.join(self.dir, "confdb")]
else:
conf_params = ["-c", self.confile]
self.start_params = conf_params
self.ctl_params = conf_params + ["-t", "15"]
if self.ctl_params_append != None:
self.ctl_params += self.ctl_params_append