Skip to content

Commit

Permalink
ec2 driver: fixed race when adding a node with volume
Browse files Browse the repository at this point in the history
  • Loading branch information
tcrivat committed Jul 23, 2016
1 parent d283c95 commit 3c7a4bc
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions conpaas-director/cpsdirector/iaas/clouds/ec2.py
Original file line number Diff line number Diff line change
Expand Up @@ -215,8 +215,24 @@ def kill_instance(self, node):


def create_volume(self, size, name, vm_id):
node = [ node for node in self.driver.list_nodes()
if node.id == vm_id ][0]

# Make sure that we wait a little until the new node shows up
while True:
try:
nodes = self.driver.list_nodes()
except:
self.logger.debug('[create_volume] list_nodes() failed,'
' sleeping 1 second')
time.sleep(1)
continue
nodes = [ node for node in nodes if node.id == vm_id ]
if nodes:
node = nodes[0]
break
else:
self.logger.debug('[create_volume] new node is not in'
' list_nodes(), sleeping 1 second')
time.sleep(1)

# We have to create the volume in the same availability zone as the
# instance we want to attach it to. Let's find out the availability
Expand Down

0 comments on commit 3c7a4bc

Please sign in to comment.