summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorClint Byrum <clint@fewbar.com>2019-01-14 17:20:41 -0800
committerClint Byrum <clint@fewbar.com>2019-02-04 08:48:27 -0800
commitb328c6de45be693fd44397c11c73261cd20490e3 (patch)
tree3045d91fec186a10b536d2d9c65fafb978cd4b5a
parent7b640f7f48e46c2ba6b4603d38e077716a13c57e (diff)
EC2: Do not tag an instance until it is running
Sometimes an instance stays as a reservation for a long time, sometimes it's only a reservation for a split second. Before this change, the tag would usually work, because the reservation turned to an instance fast enough. But many times we've observed the instance conversion taking 5 - 10 seconds, and this is long enough that the tag operation fails, and then nodepool loses track of the instance entirely. Change-Id: Iaa5c230976625d8a5c5afd7970691e235f0f77f7
Notes
Notes (review): Code-Review+2: Monty Taylor <mordred@inaugust.com> Code-Review+2: David Shrewsbury <dshrewsb@redhat.com> Code-Review+2: Tobias Henkel <tobias.henkel@bmw.de> Workflow+1: Tobias Henkel <tobias.henkel@bmw.de> Verified+2: Zuul Submitted-by: Zuul Submitted-at: Mon, 04 Feb 2019 19:23:09 +0000 Reviewed-on: https://review.openstack.org/634740 Project: openstack-infra/nodepool Branch: refs/heads/master
-rw-r--r--nodepool/driver/aws/handler.py4
1 files changed, 2 insertions, 2 deletions
diff --git a/nodepool/driver/aws/handler.py b/nodepool/driver/aws/handler.py
index c18f2f6..47da54d 100644
--- a/nodepool/driver/aws/handler.py
+++ b/nodepool/driver/aws/handler.py
@@ -49,8 +49,6 @@ class AwsInstanceLauncher(NodeLauncher):
49 attempts += 1 49 attempts += 1
50 time.sleep(1) 50 time.sleep(1)
51 51
52 instance.create_tags(Tags=[{'Key': 'nodepool_id',
53 'Value': str(self.node.id)}])
54 instance_id = instance.id 52 instance_id = instance.id
55 self.node.external_id = instance_id 53 self.node.external_id = instance_id
56 self.zk.storeNode(self.node) 54 self.zk.storeNode(self.node)
@@ -60,6 +58,8 @@ class AwsInstanceLauncher(NodeLauncher):
60 state = instance.state.get('Name') 58 state = instance.state.get('Name')
61 self.log.debug("Instance %s is %s" % (instance_id, state)) 59 self.log.debug("Instance %s is %s" % (instance_id, state))
62 if state == 'running': 60 if state == 'running':
61 instance.create_tags(Tags=[{'Key': 'nodepool_id',
62 'Value': str(self.node.id)}])
63 break 63 break
64 time.sleep(0.5) 64 time.sleep(0.5)
65 instance.reload() 65 instance.reload()