def reconcile_zones(bind=True):
"""
Periodic task that reconciles everything zone-related (zone deletion, policy record updates)
"""
redis_client = redis.from_url(settings.LOCK_SERVER_URL)
lock = redis_client.lock('reconcile_zones', timeout=60)
if not lock.acquire(blocking=False):
logger.info('Cannot aquire task lock. Probaly another task is running. Bailing out.')
return
try:
for zone in models.Zone.need_reconciliation():
try:
zone.reconcile()
lock.extend(5) # extend the lease each time we rebuild a tree
except Exception:
logger.exception(
"reconcile failed for Zone %s.%s", zone, zone.root
)
finally:
lock.release()
评论列表
文章目录