Allow Periodic Sync to be restricted to a subset of zones
Pool Manager's periodic sync should allow for sync'ing only zone changed in the last N seconds. Change-Id: I0c338500970b840646deb0552d7ab02b1ecf6621 Closes-Bug: 1412598
This commit is contained in:
parent
04c3bc7be1
commit
8916384d49
|
@ -49,6 +49,9 @@ OPTS = [
|
|||
help='The flag for the sync timer'),
|
||||
cfg.IntOpt('periodic-sync-interval', default=300,
|
||||
help='The time between synchronizing the servers with Storage'),
|
||||
cfg.IntOpt('periodic-sync-seconds', default=None,
|
||||
help='Zones Updated within last N seconds will be syncd. Use '
|
||||
'None to sync all zones.'),
|
||||
cfg.StrOpt('cache-driver', default='sqlalchemy',
|
||||
help='The cache driver to use'),
|
||||
]
|
||||
|
|
|
@ -24,6 +24,7 @@ from oslo_concurrency import lockutils
|
|||
from designate import backend
|
||||
from designate import exceptions
|
||||
from designate import objects
|
||||
from designate import utils
|
||||
from designate.central import rpcapi as central_api
|
||||
from designate.mdns import rpcapi as mdns_api
|
||||
from designate import service
|
||||
|
@ -283,8 +284,17 @@ class Service(service.RPCService):
|
|||
context = DesignateContext.get_admin_context(all_tenants=True)
|
||||
|
||||
criterion = {
|
||||
'pool_id': cfg.CONF['service:pool_manager'].pool_id
|
||||
'pool_id': cfg.CONF['service:pool_manager'].pool_id,
|
||||
}
|
||||
|
||||
periodic_sync_seconds = \
|
||||
cfg.CONF['service:pool_manager'].periodic_sync_seconds
|
||||
|
||||
if periodic_sync_seconds is not None:
|
||||
# Generate the current serial, will provide a UTC Unix TS.
|
||||
current = utils.increment_serial()
|
||||
criterion['serial'] = ">%s" % (current - periodic_sync_seconds)
|
||||
|
||||
domains = self.central_api.find_domains(context, criterion)
|
||||
|
||||
try:
|
||||
|
|
|
@ -109,6 +109,18 @@ class SQLAlchemy(object):
|
|||
elif isinstance(value, basestring) and value.startswith('!'):
|
||||
queryval = value[1:]
|
||||
query = query.where(column != queryval)
|
||||
elif isinstance(value, basestring) and value.startswith('<='):
|
||||
queryval = value[2:]
|
||||
query = query.where(column <= queryval)
|
||||
elif isinstance(value, basestring) and value.startswith('<'):
|
||||
queryval = value[1:]
|
||||
query = query.where(column < queryval)
|
||||
elif isinstance(value, basestring) and value.startswith('>='):
|
||||
queryval = value[2:]
|
||||
query = query.where(column >= queryval)
|
||||
elif isinstance(value, basestring) and value.startswith('>'):
|
||||
queryval = value[1:]
|
||||
query = query.where(column > queryval)
|
||||
else:
|
||||
query = query.where(column == value)
|
||||
|
||||
|
|
|
@ -654,6 +654,50 @@ class StorageTestCase(object):
|
|||
with testtools.ExpectedException(exceptions.DomainNotFound):
|
||||
self.storage.find_domain(self.admin_context, criterion)
|
||||
|
||||
def test_find_domain_criterion_lessthan(self):
|
||||
domain = self.create_domain()
|
||||
|
||||
# Test Finding No Results (serial is not < serial)
|
||||
criterion = dict(
|
||||
name=domain['name'],
|
||||
serial='<%s' % domain['serial'],
|
||||
)
|
||||
|
||||
with testtools.ExpectedException(exceptions.DomainNotFound):
|
||||
self.storage.find_domain(self.admin_context, criterion)
|
||||
|
||||
# Test Finding 1 Result (serial is < serial + 1)
|
||||
criterion = dict(
|
||||
name=domain['name'],
|
||||
serial='<%s' % (domain['serial'] + 1),
|
||||
)
|
||||
|
||||
result = self.storage.find_domain(self.admin_context, criterion)
|
||||
|
||||
self.assertEqual(result['name'], domain['name'])
|
||||
|
||||
def test_find_domain_criterion_greaterthan(self):
|
||||
domain = self.create_domain()
|
||||
|
||||
# Test Finding No Results (serial is not > serial)
|
||||
criterion = dict(
|
||||
name=domain['name'],
|
||||
serial='>%s' % domain['serial'],
|
||||
)
|
||||
|
||||
with testtools.ExpectedException(exceptions.DomainNotFound):
|
||||
self.storage.find_domain(self.admin_context, criterion)
|
||||
|
||||
# Test Finding 1 Result (serial is > serial - 1)
|
||||
criterion = dict(
|
||||
name=domain['name'],
|
||||
serial='>%s' % (domain['serial'] - 1),
|
||||
)
|
||||
|
||||
result = self.storage.find_domain(self.admin_context, criterion)
|
||||
|
||||
self.assertEqual(result['name'], domain['name'])
|
||||
|
||||
def test_update_domain(self):
|
||||
# Create a domain
|
||||
domain = self.create_domain(name='example.org.')
|
||||
|
|
|
@ -132,6 +132,7 @@ debug = False
|
|||
#poll_delay = 1
|
||||
#periodic_recovery_interval = 120
|
||||
#periodic_sync_interval = 300
|
||||
#periodic_sync_seconds = None
|
||||
#cache_driver = sqlalchemy
|
||||
|
||||
##############
|
||||
|
|
Loading…
Reference in New Issue