Commit c50fa46e authored by Jan Včelák's avatar Jan Včelák 🚀

Merge branch 'zone_refresh_fixes' into 'master'

Zone refresh fixes

fixes #479

See merge request !594
parents 4e11b42e 85b2f230
......@@ -85,10 +85,12 @@ int event_load(conf_t *conf, zone_t *zone)
zone_contents_deep_free(&old);
}
/* Schedule notify and refresh after load. */
if (zone_is_slave(conf, zone)) {
/* Schedule refresh after load if not already scheduled. */
if (zone_is_slave(conf, zone) &&
zone_events_get_time(zone, ZONE_EVENT_REFRESH) == 0) {
zone_events_schedule(zone, ZONE_EVENT_REFRESH, ZONE_EVENT_NOW);
}
/* Schedule notify. */
if (!zone_contents_is_empty(contents)) {
zone_events_schedule(zone, ZONE_EVENT_NOTIFY, ZONE_EVENT_NOW);
zone->bootstrap_retry = ZONE_EVENT_NOW;
......
......@@ -230,10 +230,7 @@ static zone_t *create_zone_new(conf_t *conf, const knot_dname_t *name,
zone_events_enqueue(zone, ZONE_EVENT_LOAD);
break;
case ZONE_STATUS_BOOSTRAP:
if (zone_events_get_time(zone, ZONE_EVENT_REFRESH) == 0) {
// Plan immediate refresh if not already planned.
zone_events_schedule(zone, ZONE_EVENT_REFRESH, ZONE_EVENT_NOW);
}
zone_events_schedule(zone, ZONE_EVENT_REFRESH, ZONE_EVENT_NOW);
break;
case ZONE_STATUS_NOT_FOUND:
break;
......
......@@ -53,6 +53,7 @@ for server in [master1, master2]:
# failover to second master
master1.stop()
slave.clean(zone=False, timers=True)
slave.start()
slave.zone_wait(zone, serial=20, equal=True, greater=False)
master1.start()
......
#!/usr/bin/env python3
'''Test for loading of dumped zone'''
from dnstest.test import Test
t = Test()
master = t.server("bind")
slave = t.server("knot")
reference = t.server("bind")
zones = t.zone_rnd(4) + t.zone(".") + t.zone("records.")
t.link(zones, master, slave)
t.link(zones, reference)
t.start()
# Wait for servers.
master.zones_wait(zones)
slave.zones_wait(zones)
reference.zones_wait(zones)
# Dump zones on slave.
slave.flush()
# Compare master with reference server
t.xfr_diff(reference, master, zones)
# Compare slave with reference server
t.xfr_diff(reference, slave, zones)
# Stop master.
master.stop()
# Reload dumped zone files.
slave.stop()
slave.start()
# Compare reloaded slave with reference server
slave.zones_wait(zones)
t.xfr_diff(reference, slave, zones)
t.end()
#!/usr/bin/env python3
'''Test for loading of dumped zone'''
'''Test for slave zone refresh when loading.'''
from dnstest.test import Test
from dnstest.utils import *
t = Test()
master = t.server("bind")
master = t.server("knot")
slave = t.server("knot")
reference = t.server("bind")
zones = t.zone_rnd(4) + t.zone(".") + t.zone("records.")
slave.disable_notify = True
zone_del = t.zone_rnd(1, dnssec=False)
zone_upd = t.zone_rnd(1, dnssec=False)
zones = zone_del + zone_upd
t.link(zones, master, slave)
t.link(zones, reference)
t.start()
# Wait for servers.
master.zones_wait(zones)
serial_del_init = master.zone_wait(zone_del)
serial_upd_init = master.zone_wait(zone_upd)
slave.zones_wait(zones)
reference.zones_wait(zones)
# Dump zones on slave.
slave.flush()
# Compare master with reference server
t.xfr_diff(reference, master, zones)
slave.stop()
# Compare slave with reference server
t.xfr_diff(reference, slave, zones)
# Update a zonefile on the master.
master.update_zonefile(zone_upd, random=True)
master.reload()
# Stop master.
master.stop()
# Remove a zonefile on the slave.
slave.clean(zone=zone_del, timers=False)
# Reload dumped zone files.
slave.stop()
slave.start()
# Compare reloaded slave with reference server
slave.zones_wait(zones)
t.xfr_diff(reference, slave, zones)
# Check for immediate zone transfer if deleted.
slave.zone_wait(zone_del, serial=serial_del_init, equal=True, greater=False)
# Check for untouched zone if retransfer already scheduled.
serial_upd = slave.zone_wait(zone_upd)
master.zone_wait(zone_upd, serial_upd, equal=False, greater=True)
t.end()
......@@ -663,6 +663,8 @@ class Server(object):
def clean(self, zone=True, timers=True):
if zone:
zone = zone_arg_check(zone)
# Remove all zonefiles.
if zone is True:
for _z in sorted(self.zones):
......
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