From adfbcb9499e44d133196c93301e7813e4a29b474 Mon Sep 17 00:00:00 2001 From: TingtingYu Date: Sat, 16 Sep 2017 10:30:55 +0800 Subject: [PATCH] Add code to fix the problem that support existed loadbalancer policy For the previous question that support existed loadbalancer policy,I found some bugs which it would report error if I post params without health or add member failed. To fix these bugs, I add some code to check the param about health and control to delete loadbalancer if existed loadbalancer not new creating. Change-Id: I64a711673866a8e6455dbf0d86910326507e9f3d Closes-Bug: 1715070 --- senlin/policies/lb_policy.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/senlin/policies/lb_policy.py b/senlin/policies/lb_policy.py index eed4a4d6c..4d18151e5 100644 --- a/senlin/policies/lb_policy.py +++ b/senlin/policies/lb_policy.py @@ -350,8 +350,8 @@ class LoadBalancingPolicy(base.Policy): data['loadbalancer'] = self.lb data['pool'] = self.pool_spec.get(self.POOL_ID, None) data['vip_address'] = self.vip_spec.get(self.VIP_ADDRESS, None) - if self.hm_spec.get(self.HM_ID, None): - data['healthmonitor'] = self.hm_spec.get(self.HM_ID, None) + if self.hm_spec and self.hm_spec.get(self.HM_ID, None): + data['healthmonitor'] = self.hm_spec.get(self.HM_ID) else: res, data = lb_driver.lb_create(self.vip_spec, self.pool_spec, self.hm_spec) @@ -369,7 +369,8 @@ class LoadBalancingPolicy(base.Policy): # were created and return the failure reason. # TODO(anyone): May need to "roll-back" changes caused by any # successful member_add() calls. - lb_driver.lb_delete(**data) + if not self.lb: + lb_driver.lb_delete(**data) return False, 'Failed in adding node into lb pool' node.data.update({'lb_member': member_id})