[
https://issues.apache.org/jira/browse/LIBCLOUD-85?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13031957#comment-13031957
]
Philip Schwartz commented on LIBCLOUD-85:
-----------------------------------------
>From df8a1465033da3bba18cd7cb09306e85f8a0ec34 Mon Sep 17 00:00:00 2001
From: Philip Schwartz <[email protected]>
Date: Wed, 11 May 2011 14:54:39 -0400
Subject: [PATCH] LIBCLOUD-85: fixed - Added exception handling for failed call
to ex_create_tags on create_node. Except block destroys the hanging node that
did not create with the Name tag as requested.
---
libcloud/compute/drivers/ec2.py | 6 +++++-
1 files changed, 5 insertions(+), 1 deletions(-)
diff --git a/libcloud/compute/drivers/ec2.py b/libcloud/compute/drivers/ec2.py
index 7805cd0..f45921d 100644
--- a/libcloud/compute/drivers/ec2.py
+++ b/libcloud/compute/drivers/ec2.py
@@ -822,7 +822,11 @@ class EC2NodeDriver(NodeDriver):
nodes = self._to_nodes(object, 'instancesSet/item')
for node in nodes:
- self.ex_create_tags(node=node, tags={'Name': kwargs['name']})
+ try:
+ self.ex_create_tags(node=node, tags={'Name': kwargs['name']})
+ except Exception as err:
+ self.destroy_node(node)
+ raise Exception("Create Node failed due to call to
ex_create_tags, destroying node: " + node.id)
if len(nodes) == 1:
return nodes[0]
--
1.7.0.4
> Exception handling in cascaded function call in ec2 create_node is needed.
> --------------------------------------------------------------------------
>
> Key: LIBCLOUD-85
> URL: https://issues.apache.org/jira/browse/LIBCLOUD-85
> Project: Libcloud
> Issue Type: Bug
> Components: Compute
> Affects Versions: 0.4.1, 0.5.0
> Reporter: Philip Schwartz
>
> In create_node for ec2, a call to ex_create_tags.
> for node in nodes:
> self.ex_create_tags(node=node, tags={'Name': kwargs['name']})
> This should catch an exception and clean up the failed create if an exception
> is thrown. Currently when the ex_create_tags fails due to a node not being
> registered correctly yet (but created), an exception of node id does not
> exist is thrown. This cascades as a failure of the full call to any code
> calling create_node when in fact the node was created.
--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira