Merge "Fix LB status updates"
This commit is contained in:
commit
dd542b1080
|
@ -98,7 +98,7 @@ class UpdateHealthDb(object):
|
|||
|
||||
listeners = health['listeners']
|
||||
|
||||
# Do not update ampohra health if the reporting listener count
|
||||
# Do not update amphora health if the reporting listener count
|
||||
# does not match the expected listener count
|
||||
if len(listeners) == expected_listener_count:
|
||||
|
||||
|
@ -119,9 +119,6 @@ class UpdateHealthDb(object):
|
|||
# update listener and nodes db information
|
||||
for listener_id, listener in six.iteritems(listeners):
|
||||
|
||||
listener_model = self.listener_repo.get(session, id=listener_id)
|
||||
lb_id = listener_model.load_balancer_id
|
||||
|
||||
listener_status = None
|
||||
# OPEN = HAProxy listener status nbconn < maxconn
|
||||
if listener.get('status') == constants.OPEN:
|
||||
|
@ -199,6 +196,12 @@ class UpdateHealthDb(object):
|
|||
except sqlalchemy.orm.exc.NoResultFound:
|
||||
LOG.error(_LE("Pool %s is not in DB"), pool_id)
|
||||
|
||||
# Update the load balancer status last
|
||||
# TODO(sbalukoff): This logic will need to be adjusted if we
|
||||
# start supporting multiple load balancers per amphora
|
||||
lb_id = self.amphora_repo.get(
|
||||
session, id=health['id']).load_balancer_id
|
||||
if lb_id is not None:
|
||||
try:
|
||||
self._update_status_and_emit_event(
|
||||
session, self.loadbalancer_repo,
|
||||
|
|
|
@ -81,6 +81,24 @@ class TestUpdateHealthDb(base.TestCase):
|
|||
'info_type': 'pool', 'info_id': 'pool-id-1',
|
||||
'info_payload': {'operating_status': 'ONLINE'}})
|
||||
|
||||
@mock.patch('octavia.db.api.get_session')
|
||||
def test_update_health_no_listener(self, session):
|
||||
|
||||
health = {
|
||||
"id": self.FAKE_UUID_1,
|
||||
"listeners": {}}
|
||||
|
||||
session.return_value = 'blah'
|
||||
lb = mock.MagicMock()
|
||||
lb.operating_status.lower.return_value = 'blah'
|
||||
self.amphora_repo.get.load_balancer_id.return_value = self.FAKE_UUID_1
|
||||
self.loadbalancer_repo.get.return_value = lb
|
||||
|
||||
self.hm.update_health(health)
|
||||
self.assertTrue(self.amphora_repo.get.called)
|
||||
self.assertTrue(lb.operating_status.lower.called)
|
||||
self.assertTrue(self.loadbalancer_repo.update.called)
|
||||
|
||||
@mock.patch('octavia.db.api.get_session')
|
||||
def test_update_health_Online(self, session):
|
||||
|
||||
|
|
Loading…
Reference in New Issue