Commit 58eef461 authored by Daniel Salzman's avatar Daniel Salzman

Merge branch 'flush_on_load' into 'master'

flush to zonefile if zf_sync==0 && zone updated on load event

See merge request !845
parents 147f1123 f9e76c02
......@@ -444,12 +444,6 @@ static int zone_txn_commit(zone_t *zone, ctl_args_t *args)
free(zone->control_update);
zone->control_update = NULL;
/* Sync zonefile immediately if configured. */
val = conf_zone_get(conf(), C_ZONEFILE_SYNC, zone->name);
if (conf_int(&val) == 0) {
zone_events_schedule_now(zone, ZONE_EVENT_FLUSH);
}
zone_events_schedule_now(zone, ZONE_EVENT_NOTIFY);
return KNOT_EOK;
......
......@@ -40,8 +40,6 @@ void event_dnssec_reschedule(conf_t *conf, zone_t *zone,
return;
}
conf_val_t val = conf_zone_get(conf, C_ZONEFILE_SYNC, zone->name);
log_dnssec_next(zone->name, (time_t)refresh_at);
if (refresh->plan_ds_query) {
......@@ -57,8 +55,7 @@ void event_dnssec_reschedule(conf_t *conf, zone_t *zone,
ZONE_EVENT_DNSSEC, (time_t)refresh_at,
ZONE_EVENT_PARENT_DS_Q, refresh->plan_ds_query ? now : ignore,
ZONE_EVENT_NSEC3RESALT, refresh->next_nsec3resalt ? refresh->next_nsec3resalt : ignore,
ZONE_EVENT_NOTIFY, zone_changed ? now : ignore,
ZONE_EVENT_FLUSH, zone_changed && conf_int(&val) == 0 ? now : ignore
ZONE_EVENT_NOTIFY, zone_changed ? now : ignore
);
}
......
......@@ -1132,12 +1132,6 @@ int event_refresh(conf_t *conf, zone_t *zone)
replan_from_timers(conf, zone);
if (updated) {
zone_events_schedule_at(zone, ZONE_EVENT_NOTIFY, time(NULL) + 1);
conf_val_t val = conf_zone_get(conf, C_ZONEFILE_SYNC, zone->name);
int64_t sync_timeout = conf_int(&val);
if (sync_timeout == 0) {
zone_events_schedule_now(zone, ZONE_EVENT_FLUSH);
}
}
if (!bootstrap) {
......
......@@ -105,7 +105,7 @@ void replan_from_timers(conf_t *conf, zone_t *zone)
expire = zone->timers.last_refresh + zone->timers.soa_expire;
}
time_t flush = TIME_CANCEL;
time_t flush = TIME_IGNORE;
if (!zone_is_slave(conf, zone) || can_expire(zone)) {
conf_val_t val = conf_zone_get(conf, C_ZONEFILE_SYNC, zone->name);
int64_t sync_timeout = conf_int(&val);
......
......@@ -183,12 +183,6 @@ static int process_normal(conf_t *conf, zone_t *zone, list_t *requests)
return ret;
}
/* Sync zonefile immediately if configured. */
val = conf_zone_get(conf, C_ZONEFILE_SYNC, zone->name);
if (conf_int(&val) == 0) {
zone_events_schedule_now(zone, ZONE_EVENT_FLUSH);
}
return KNOT_EOK;
}
......
......@@ -698,6 +698,12 @@ int zone_update_commit(conf_t *conf, zone_update_t *update)
update->a_ctx = NULL;
update->new_cont = NULL;
/* Sync zonefile immediately if configured. */
val = conf_zone_get(conf, C_ZONEFILE_SYNC, update->zone->name);
if (conf_int(&val) == 0) {
zone_events_schedule_now(update->zone, ZONE_EVENT_FLUSH);
}
return KNOT_EOK;
}
......
#!/usr/bin/env python3
'''With zonefile-flush: 0, test that the zonefile gets flushed immediately in various scenarios'''
from dnstest.test import Test
from dnstest.utils import *
t = Test()
master = t.server("knot")
slave = t.server("knot")
zone = t.zone_rnd(1, dnssec=False, records=100)
t.link(zone, master, slave)
master.dnssec(zone).enable = True
master.zonefile_sync = 0
slave.zonefile_sync = 0
t.start()
m_zfpath = master.zones[zone[0].name].zfile.path
s_zfpath = slave.zones[zone[0].name].zfile.path
master.zones_wait(zone)
slave.zones_wait(zone)
t.sleep(2)
# check zonefile flushed after load and sign
master.zone_verify(zone)
# check zonefile flushed after AXFR
slave.zone_verify(zone)
m_mtime1 = os.stat(m_zfpath).st_mtime
s_mtime1 = os.stat(s_zfpath).st_mtime
up = master.update(zone)
up.add("djojdw", 3600, "TXT", "this wont sure be there yet")
up.send("NOERROR")
t.sleep(2)
m_mtime2 = os.stat(m_zfpath).st_mtime
s_mtime2 = os.stat(s_zfpath).st_mtime
# check zonefile flushed after DDNS
if m_mtime2 == m_mtime1:
set_err("Not flushed after DDNS")
# check zonefile flushed after IXFR
if s_mtime2 == s_mtime1:
set_err("Not flushed after IXFR")
t.end()
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment