Browse Source

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
tags/3.5.0
Clint Byrum 6 months ago
parent
commit
b328c6de45
1 changed files with 2 additions and 2 deletions
  1. 2
    2
      nodepool/driver/aws/handler.py

+ 2
- 2
nodepool/driver/aws/handler.py View File

@@ -49,8 +49,6 @@ class AwsInstanceLauncher(NodeLauncher):
49 49
                 attempts += 1
50 50
             time.sleep(1)
51 51
 
52
-        instance.create_tags(Tags=[{'Key': 'nodepool_id',
53
-                                    'Value': str(self.node.id)}])
54 52
         instance_id = instance.id
55 53
         self.node.external_id = instance_id
56 54
         self.zk.storeNode(self.node)
@@ -60,6 +58,8 @@ class AwsInstanceLauncher(NodeLauncher):
60 58
             state = instance.state.get('Name')
61 59
             self.log.debug("Instance %s is %s" % (instance_id, state))
62 60
             if state == 'running':
61
+                instance.create_tags(Tags=[{'Key': 'nodepool_id',
62
+                                            'Value': str(self.node.id)}])
63 63
                 break
64 64
             time.sleep(0.5)
65 65
             instance.reload()

Loading…
Cancel
Save