Fix health registry claim bug(2)
This patch fixes health registry claim api with correct logic. Change-Id: I2d494095eca627cc9b86bddf3c72d403aa54a27a Closes-Bug: #1658661
This commit is contained in:
parent
62c9f95652
commit
4e4db04449
|
@ -1433,8 +1433,10 @@ def registry_claim(context, engine_id):
|
|||
if svc_ids:
|
||||
q_reg = q_reg.filter(
|
||||
models.HealthRegistry.engine_id.notin_(svc_ids))
|
||||
q_reg.update({'engine_id': engine_id}, synchronize_session=False)
|
||||
|
||||
result = q_reg.all()
|
||||
q_reg.update({'engine_id': engine_id}, synchronize_session=False)
|
||||
|
||||
return result
|
||||
|
||||
|
||||
|
|
|
@ -360,8 +360,9 @@ class HealthManager(service.Service):
|
|||
'enabled': r.enabled,
|
||||
}
|
||||
|
||||
LOG.info(_LI("Loading cluster %s for health monitoring"),
|
||||
r.cluster_id)
|
||||
LOG.info(_LI("Loading cluster %(c)s enalbed=%(e)s for "
|
||||
"health monitoring"),
|
||||
{'c': r.cluster_id, 'e': r.enabled})
|
||||
|
||||
if r.enabled:
|
||||
entry = self._start_check(entry)
|
||||
|
|
|
@ -71,8 +71,8 @@ class DBAPIRegistryTest(base.SenlinTestCase):
|
|||
|
||||
registries = db_api.registry_claim(self.ctx, engine_id='ENGINE_ID')
|
||||
self.assertEqual(2, len(registries))
|
||||
self.assertEqual('ENGINE_ID', registries[0].engine_id)
|
||||
self.assertEqual('ENGINE_ID', registries[1].engine_id)
|
||||
self.assertEqual('DEAD_ENGINE', registries[0].engine_id)
|
||||
self.assertEqual('DEAD_ENGINE', registries[1].engine_id)
|
||||
|
||||
@mock.patch.object(db_utils, 'is_service_dead')
|
||||
def test_registry_claim_with_dead_engine(self, mock_check):
|
||||
|
@ -89,7 +89,7 @@ class DBAPIRegistryTest(base.SenlinTestCase):
|
|||
registries = db_api.registry_claim(self.ctx, engine_id='ENGINE_ID')
|
||||
|
||||
self.assertEqual(1, len(registries))
|
||||
self.assertEqual('ENGINE_ID', registries[0].engine_id)
|
||||
self.assertEqual('SERVICE_ID_DEAD', registries[0].engine_id)
|
||||
|
||||
def test_registry_delete(self):
|
||||
registry = self._create_registry('CLUSTER_ID',
|
||||
|
|
Loading…
Reference in New Issue