Merge "No need to do a shutdown(wait=True) when in a context-manager"
This commit is contained in:
commit
a6b3c798bf
@ -35,27 +35,24 @@ class HealthManager(object):
|
||||
amp_health_repo = repo.AmphoraHealthRepository()
|
||||
|
||||
with futures.ThreadPoolExecutor(max_workers=self.threads) as executor:
|
||||
try:
|
||||
# Don't start checking immediately, as the health manager may
|
||||
# have been down for a while and amphorae not able to check in.
|
||||
LOG.debug("Pausing before starting health check")
|
||||
time.sleep(CONF.health_manager.heartbeat_timeout)
|
||||
# Don't start checking immediately, as the health manager may
|
||||
# have been down for a while and amphorae not able to check in.
|
||||
LOG.debug("Pausing before starting health check")
|
||||
time.sleep(CONF.health_manager.heartbeat_timeout)
|
||||
while True:
|
||||
session = db_api.get_session()
|
||||
LOG.debug("Starting amphora health check")
|
||||
failover_count = 0
|
||||
while True:
|
||||
session = db_api.get_session()
|
||||
LOG.debug("Starting amphora health check")
|
||||
failover_count = 0
|
||||
while True:
|
||||
amp = amp_health_repo.get_stale_amphora(session)
|
||||
if amp is None:
|
||||
break
|
||||
failover_count += 1
|
||||
LOG.info("Stale amphora's id is: %s",
|
||||
amp.amphora_id)
|
||||
executor.submit(self.cw.failover_amphora,
|
||||
amp.amphora_id)
|
||||
if failover_count > 0:
|
||||
LOG.info("Failed over %s amphora",
|
||||
failover_count)
|
||||
time.sleep(CONF.health_manager.health_check_interval)
|
||||
finally:
|
||||
executor.shutdown(wait=True)
|
||||
amp = amp_health_repo.get_stale_amphora(session)
|
||||
if amp is None:
|
||||
break
|
||||
failover_count += 1
|
||||
LOG.info("Stale amphora's id is: %s",
|
||||
amp.amphora_id)
|
||||
executor.submit(self.cw.failover_amphora,
|
||||
amp.amphora_id)
|
||||
if failover_count > 0:
|
||||
LOG.info("Failed over %s amphora",
|
||||
failover_count)
|
||||
time.sleep(CONF.health_manager.health_check_interval)
|
||||
|
@ -110,18 +110,15 @@ class CertRotation(object):
|
||||
amp_repo = repo.AmphoraRepository()
|
||||
|
||||
with futures.ThreadPoolExecutor(max_workers=self.threads) as executor:
|
||||
try:
|
||||
session = db_api.get_session()
|
||||
rotation_count = 0
|
||||
while True:
|
||||
amp = amp_repo.get_cert_expiring_amphora(session)
|
||||
if not amp:
|
||||
break
|
||||
rotation_count += 1
|
||||
LOG.debug("Cert expired amphora's id is: %s", amp.id)
|
||||
executor.submit(self.cw.amphora_cert_rotation, amp.id)
|
||||
if rotation_count > 0:
|
||||
LOG.info("Rotated certificates for %s amphora" %
|
||||
rotation_count)
|
||||
finally:
|
||||
executor.shutdown(wait=True)
|
||||
session = db_api.get_session()
|
||||
rotation_count = 0
|
||||
while True:
|
||||
amp = amp_repo.get_cert_expiring_amphora(session)
|
||||
if not amp:
|
||||
break
|
||||
rotation_count += 1
|
||||
LOG.debug("Cert expired amphora's id is: %s", amp.id)
|
||||
executor.submit(self.cw.amphora_cert_rotation, amp.id)
|
||||
if rotation_count > 0:
|
||||
LOG.info("Rotated certificates for %s amphora" %
|
||||
rotation_count)
|
||||
|
Loading…
Reference in New Issue
Block a user