Do not try and download zones for empty url
If the leader has updated the sync time but not yet published a src url then the charm can attempt to download the zones from an empty url Change-Id: If50872887c9bf993f1524c6bb1e3cad03eda5809 Closes-Bug: #1753980
This commit is contained in:
parent
a178745bb2
commit
e95b02a465
|
@ -443,15 +443,20 @@ class DesignateBindCharm(openstack_charm.OpenStackCharm):
|
|||
'available'),
|
||||
level=hookenv.WARNING)
|
||||
else:
|
||||
self.service_control('stop', ['bind9'])
|
||||
url = DesignateBindCharm.get_sync_src()
|
||||
self.wget_file(url, ZONE_DIR)
|
||||
tar_file = url.split('/')[-1]
|
||||
subprocess.check_call(['tar', 'xf', tar_file], cwd=ZONE_DIR)
|
||||
os.remove('{}/{}'.format(ZONE_DIR, tar_file))
|
||||
self.service_control('start', ['bind9'])
|
||||
reactive.remove_state('sync.request.sent')
|
||||
reactive.set_state('zones.initialised')
|
||||
if url:
|
||||
self.service_control('stop', ['bind9'])
|
||||
self.wget_file(url, ZONE_DIR)
|
||||
tar_file = url.split('/')[-1]
|
||||
subprocess.check_call(['tar', 'xf', tar_file], cwd=ZONE_DIR)
|
||||
os.remove('{}/{}'.format(ZONE_DIR, tar_file))
|
||||
self.service_control('start', ['bind9'])
|
||||
reactive.remove_state('sync.request.sent')
|
||||
reactive.set_state('zones.initialised')
|
||||
else:
|
||||
hookenv.log(('Leader has not set valid url for zone download '
|
||||
' defering until leader provides url'),
|
||||
level=hookenv.WARNING)
|
||||
|
||||
def set_apparmor(self):
|
||||
"""Disbale apparmor for named
|
||||
|
|
|
@ -405,6 +405,19 @@ class TestDesignateBindCharm(Helper):
|
|||
'http://ip1/tarfile.tar',
|
||||
'/var/cache/bind')
|
||||
|
||||
def test_retrieve_zones_cluster_relation_nourl(self):
|
||||
relation = mock.MagicMock()
|
||||
self.patch(designate_bind.DesignateBindCharm, 'get_sync_time')
|
||||
self.patch(designate_bind.DesignateBindCharm, 'get_sync_src')
|
||||
self.patch_object(designate_bind.DesignateBindCharm, 'wget_file')
|
||||
self.patch(designate_bind.hookenv, 'log')
|
||||
self.get_sync_src.return_value = None
|
||||
relation.retrieve_local.return_value = ['10']
|
||||
self.get_sync_time.return_value = '20'
|
||||
a = designate_bind.DesignateBindCharm()
|
||||
a.retrieve_zones(relation)
|
||||
self.assertFalse(self.wget_file.called)
|
||||
|
||||
def test_retrieve_zones_no_cluster_relation(self):
|
||||
self.patch(designate_bind.DesignateBindCharm, 'get_sync_time')
|
||||
self.patch(designate_bind.DesignateBindCharm, 'get_sync_src')
|
||||
|
|
Loading…
Reference in New Issue