Ignore LB not existed when delete member pool

A Cluster can't detach a LB policy was attached before
when i do deleted LB have id is specifying in that LB policy.

Closes-Bug: #1830152
Change-Id: Iedc9b65eef35c0f6a16cb7caa34269a9a63c2a87
This commit is contained in:
Bo Tran 2019-05-07 17:21:27 +07:00 committed by Bo Tran Van
parent 06c160365e
commit 8cc0503203
2 changed files with 12 additions and 7 deletions

View File

@ -339,10 +339,11 @@ class LoadBalancerDriver(base.DriverBase):
# loadbalancer status will be checked before deleting lb member
# request is sent out. If loadbalancer keeps unready till waiting
# timeout, exception will be raised to fail member_remove.
res = self._wait_for_lb_ready(lb_id)
if not res:
msg = 'Loadbalancer %s is not ready.' % lb_id
raise exception.Error(msg)
res = self._wait_for_lb_ready(lb_id, ignore_not_found=True)
# res = self._wait_for_lb_ready(lb_id)
# if not res:
# msg = 'Loadbalancer %s is not ready.' % lb_id
# raise exception.Error(msg)
self.oc().pool_member_delete(pool_id, member_id)
except (exception.InternalError, exception.Error) as ex:
LOG.exception('Failed in removing member %(m)s from pool %(p)s: '

View File

@ -661,7 +661,8 @@ class TestOctaviaLBaaSDriver(base.SenlinTestCase):
self.assertTrue(res)
self.oc.pool_member_delete.assert_called_once_with(pool_id, member_id)
self.lb_driver._wait_for_lb_ready.assert_has_calls(
[mock.call(lb_id), mock.call(lb_id, ignore_not_found=True)])
[mock.call(lb_id, ignore_not_found=True),
mock.call(lb_id, ignore_not_found=True)])
def test_member_remove_lb_unready_for_member_delete(self):
self.lb_driver._wait_for_lb_ready = mock.Mock()
@ -669,7 +670,9 @@ class TestOctaviaLBaaSDriver(base.SenlinTestCase):
res = self.lb_driver.member_remove('LB_ID', 'POOL_ID', 'MEMBER_ID')
self.assertFalse(res)
self.lb_driver._wait_for_lb_ready.assert_called_once_with('LB_ID')
self.lb_driver._wait_for_lb_ready.assert_has_calls(
[mock.call('LB_ID', ignore_not_found=True),
mock.call('LB_ID', ignore_not_found=True)])
def test_member_remove_member_delete_failed(self):
self.lb_driver._wait_for_lb_ready = mock.Mock()
@ -690,4 +693,5 @@ class TestOctaviaLBaaSDriver(base.SenlinTestCase):
res = self.lb_driver.member_remove('LB_ID', 'POOL_ID', 'MEMBER_ID')
self.assertIsNone(res)
self.lb_driver._wait_for_lb_ready.assert_has_calls(
[mock.call('LB_ID'), mock.call('LB_ID', ignore_not_found=True)])
[mock.call('LB_ID', ignore_not_found=True),
mock.call('LB_ID', ignore_not_found=True)])