Skip to content

Commit

Permalink
Fix heat deletion failed if floating ip is not found
Browse files Browse the repository at this point in the history
Novaclient will throw out a Not Found exception if the
floating ip not exists. Heat should catch this exception
to continue to delete the stack.

Closes-Bug: #1234593

Change-Id: Ifd9d34de37cc5dd57804787d8b1455f0321fc86f
  • Loading branch information
Hui HX Xiang authored and Steven Hardy committed Oct 12, 2013
1 parent b14f780 commit 2aa4186
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
5 changes: 4 additions & 1 deletion heat/engine/resources/eip.py
Expand Up @@ -118,7 +118,10 @@ def handle_delete(self):
if e.status_code != 404:
raise e
else:
self.nova().floating_ips.delete(self.resource_id)
try:
self.nova().floating_ips.delete(self.resource_id)
except clients.novaclient.exceptions.NotFound:
pass

def FnGetRefId(self):
return unicode(self._ipaddress())
Expand Down
20 changes: 20 additions & 0 deletions heat/tests/test_eip.py
Expand Up @@ -12,6 +12,8 @@
# License for the specific language governing permissions and limitations
# under the License.

import mox

from testtools import skipIf

from heat.common import exception
Expand Down Expand Up @@ -223,6 +225,24 @@ def test_eip_with_exception(self):
rsrc.handle_create)
self.m.VerifyAll()

def test_delete_eip_with_exception(self):
self.m.StubOutWithMock(self.fc.floating_ips, 'delete')
eip.ElasticIp.nova().MultipleTimes().AndReturn(self.fc)
self.fc.floating_ips.delete(mox.IsA(object)).AndRaise(
clients.novaclient.exceptions.NotFound('fake_falure'))
self.fc.servers.get(mox.IsA(object)).AndReturn(False)
self.m.ReplayAll()

t = template_format.parse(eip_template)
stack = utils.parse_stack(t)
resource_name = 'IPAddress'
rsrc = eip.ElasticIp(resource_name,
t['Resources'][resource_name],
stack)
rsrc.resource_id = 'fake_id'
rsrc.handle_delete()
self.m.VerifyAll()


class AllocTest(HeatTestCase):

Expand Down

0 comments on commit 2aa4186

Please sign in to comment.