Commit 2556ff34 authored by Jerry's avatar Jerry
Browse files

merged trac #336: zonemgr should be attempting to refresh expired zones.


git-svn-id: svn://bind10.isc.org/svn/bind10/trunk@3139 e5f2f494-b856-4b98-b285-d166d9295462
parent 7785e4c8
104. [bug] jerry
bin/zonemgr: zonemgr should be attempting to refresh expired zones.
(Trac #336, r3138)
103. [bug] jerry
lib/python/isc/log: Fixed an issue with python logging,
python log shouldn't die with OSError.(Trac #267, r3137)
......
......@@ -42,15 +42,16 @@ class MyZonemgrRefresh(ZonemgrRefresh):
def __init__(self):
self._cc = MySession()
self._db_file = "initdb.file"
current_time = time.time()
self._zonemgr_refresh_info = {
('sd.cn.', 'IN'): {
'last_refresh_time': 1280474398.822142,
'next_refresh_time': 1280481598.822153,
'last_refresh_time': current_time,
'next_refresh_time': current_time + 6500,
'zone_soa_rdata': 'a.dns.cn. root.cnnic.cn. 2009073105 7200 3600 2419200 21600',
'zone_state': 0},
('tw.cn', 'CH'): {
'last_refresh_time': 1280474399.116421,
'next_refresh_time': 1280481599.116433,
'last_refresh_time': current_time,
'next_refresh_time': current_time + 6900,
'zone_soa_rdata': 'a.dns.cn. root.cnnic.cn. 2009073112 7200 3600 2419200 21600',
'zone_state': 0}
}
......@@ -311,6 +312,11 @@ class TestZonemgrRefresh(unittest.TestCase):
self.assertTrue((time1 + 3 * 3600 / 4) <= next_refresh_time)
self.assertTrue(next_refresh_time <= time2 + 3600)
self.assertEqual(ZONE_OK, self.zone_refresh._zonemgr_refresh_info[ZONE_NAME_CLASS1_IN]["zone_state"])
self.zone_refresh._zonemgr_refresh_info[ZONE_NAME_CLASS1_IN]["last_refresh_time"] = time1 - 2419200
self.zone_refresh.zone_refresh_fail(ZONE_NAME_CLASS1_IN)
self.assertEqual(ZONE_EXPIRED, self.zone_refresh._zonemgr_refresh_info[ZONE_NAME_CLASS1_IN]["zone_state"])
self.assertRaises(ZonemgrException, self.zone_refresh.zone_refresh_fail, ("org.cn.", "CH"))
self.assertRaises(ZonemgrException, self.zone_refresh.zone_refresh_fail, ZONE_NAME_CLASS3_IN)
......@@ -332,17 +338,6 @@ class TestZonemgrRefresh(unittest.TestCase):
zone_need_refresh = self.zone_refresh._find_need_do_refresh_zone()
self.assertEqual(ZONE_NAME_CLASS1_IN, zone_need_refresh)
self.zone_refresh._zonemgr_refresh_info[ZONE_NAME_CLASS1_IN]["last_refresh_time"] = time1 - 2419200
self.zone_refresh._zonemgr_refresh_info[ZONE_NAME_CLASS1_IN]["zone_state"] = ZONE_EXPIRED
zone_need_refresh = self.zone_refresh._find_need_do_refresh_zone()
self.assertEqual(None, zone_need_refresh)
self.zone_refresh._zonemgr_refresh_info[ZONE_NAME_CLASS1_IN]["zone_state"] = ZONE_REFRESHING
self.zone_refresh._zonemgr_refresh_info[ZONE_NAME_CLASS1_IN]["notify_master"] = "192.168.0.1"
zone_need_refresh = self.zone_refresh._find_need_do_refresh_zone()
self.assertEqual(ZONE_NAME_CLASS1_IN, zone_need_refresh)
self.assertEqual(ZONE_EXPIRED, self.zone_refresh._zonemgr_refresh_info[ZONE_NAME_CLASS1_IN]["zone_state"])
self.zone_refresh._zonemgr_refresh_info[ZONE_NAME_CLASS2_CH]["refresh_timeout"] = time1
zone_need_refresh = self.zone_refresh._find_need_do_refresh_zone()
self.assertEqual(ZONE_NAME_CLASS2_CH, zone_need_refresh)
......
......@@ -170,7 +170,11 @@ class ZonemgrRefresh:
raise ZonemgrException("[b10-zonemgr] Zone (%s, %s) doesn't "
"belong to zonemgr" % zone_name_class)
return
self._set_zone_state(zone_name_class, ZONE_OK)
# Is zone expired?
if (self._zone_is_expired(zone_name_class)):
self._set_zone_state(zone_name_class, ZONE_EXPIRED)
else:
self._set_zone_state(zone_name_class, ZONE_OK)
self._set_zone_retry_timer(zone_name_class)
def zone_handle_notify(self, zone_name_class, master):
......@@ -272,25 +276,14 @@ class ZonemgrRefresh:
"""
zone_need_refresh = None
for zone_name_class in self._zonemgr_refresh_info.keys():
# Does the zone expired?
if (ZONE_EXPIRED != self._get_zone_state(zone_name_class) and
self._zone_is_expired(zone_name_class)):
log_msg("Zone (%s, %s) is expired." % zone_name_class)
self._set_zone_state(zone_name_class, ZONE_EXPIRED)
zone_state = self._get_zone_state(zone_name_class)
# If zone is expired and doesn't receive notify, skip the zone
if (ZONE_EXPIRED == zone_state and
(not self._get_zone_notifier_master(zone_name_class))):
continue
# If hasn't received refresh response but are within refresh timeout, skip the zone
if (ZONE_REFRESHING == zone_state and
(self._get_zone_refresh_timeout(zone_name_class) > self._get_current_time())):
continue
# Get the zone with minimum next_refresh_time
if ((None == zone_need_refresh) or
if ((zone_need_refresh is None) or
(self._get_zone_next_refresh_time(zone_name_class) <
self._get_zone_next_refresh_time(zone_need_refresh))):
zone_need_refresh = zone_name_class
......
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