Skip to content

Commit eb9ad86

Browse files
author
Gabriel Monroy
committed
ignore node does not exist errors in the event of unclean destroy
1 parent af4b082 commit eb9ad86

1 file changed

Lines changed: 11 additions & 8 deletions

File tree

celerytasks/ec2.py

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -133,14 +133,17 @@ def terminate_node(node_id, creds, params, provider_id):
133133
if i.state == "terminated":
134134
break
135135
# pull the node from the database
136-
node = Node.objects.get(uuid=node_id)
137-
chef_id = node.id
138-
node.provider_id = None
139-
node.fqdn = None
140-
node.metadata = {}
141-
node.save()
142-
# delete the node itself from the database
143-
node.delete()
136+
try:
137+
node = Node.objects.get(uuid=node_id)
138+
chef_id = node.id
139+
node.provider_id = None
140+
node.fqdn = None
141+
node.metadata = {}
142+
node.save()
143+
# delete the node itself from the database
144+
node.delete()
145+
except Node.DoesNotExist:
146+
pass # ignore node does not exist
144147
# purge the node & client records from chef server
145148
client = ChefAPI(settings.CHEF_SERVER_URL,
146149
settings.CHEF_CLIENT_NAME,

0 commit comments

Comments
 (0)