summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJames E. Blair <jeblair@redhat.com>2018-11-29 15:35:24 -0800
committerJames E. Blair <jeblair@redhat.com>2018-11-29 15:38:34 -0800
commitafbf9108d893ede0d147da2afe16c9e6d4bc76d4 (patch)
tree41d280216ee3b0cdea452c5b9b63da8dc799564e
parent56164c886a81c5d5c67eaac789a6288dd555189b (diff)
OpenStack: store ZK records for launch error nodes
If we get an error on create server, we currently leak the instance because we don't store the external id of the instance in ZK. It should eventually be deleted since it's a leaked instance, but we try to keep track of as much as possible. OpenStackSDK can often return the external id to us in these cases, so handle that case and store the external id on a ZK record so that the instance is correctly accounted for. Change-Id: I7ec448e9a7cf6cd01903bf7b5bf4b07a1c143fb8
Notes
Notes (review): Code-Review+2: Clark Boylan <cboylan@sapwetik.org> Code-Review+2: Paul Belanger <pabelanger@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: Fri, 30 Nov 2018 14:29:51 +0000 Reviewed-on: https://review.openstack.org/621043 Project: openstack-infra/nodepool Branch: refs/heads/master
-rw-r--r--nodepool/driver/openstack/handler.py40
1 files changed, 24 insertions, 16 deletions
diff --git a/nodepool/driver/openstack/handler.py b/nodepool/driver/openstack/handler.py
index 4712392..c52d458 100644
--- a/nodepool/driver/openstack/handler.py
+++ b/nodepool/driver/openstack/handler.py
@@ -18,6 +18,7 @@ import pprint
18import random 18import random
19 19
20from kazoo import exceptions as kze 20from kazoo import exceptions as kze
21import openstack
21 22
22from nodepool import exceptions 23from nodepool import exceptions
23from nodepool import nodeutils as utils 24from nodepool import nodeutils as utils
@@ -122,22 +123,29 @@ class OpenStackNodeLauncher(NodeLauncher):
122 # because that isn't available in ZooKeeper until after the server is 123 # because that isn't available in ZooKeeper until after the server is
123 # active, which could cause a race in leak detection. 124 # active, which could cause a race in leak detection.
124 125
125 server = self.handler.manager.createServer( 126 try:
126 hostname, 127 server = self.handler.manager.createServer(
127 image=image_external, 128 hostname,
128 min_ram=self.label.min_ram, 129 image=image_external,
129 flavor_name=self.label.flavor_name, 130 min_ram=self.label.min_ram,
130 key_name=self.label.key_name, 131 flavor_name=self.label.flavor_name,
131 az=self.node.az, 132 key_name=self.label.key_name,
132 config_drive=config_drive, 133 az=self.node.az,
133 nodepool_node_id=self.node.id, 134 config_drive=config_drive,
134 nodepool_node_label=self.node.type[0], 135 nodepool_node_id=self.node.id,
135 nodepool_image_name=image_name, 136 nodepool_node_label=self.node.type[0],
136 networks=self.pool.networks, 137 nodepool_image_name=image_name,
137 security_groups=self.pool.security_groups, 138 networks=self.pool.networks,
138 boot_from_volume=self.label.boot_from_volume, 139 security_groups=self.pool.security_groups,
139 volume_size=self.label.volume_size, 140 boot_from_volume=self.label.boot_from_volume,
140 instance_properties=self.label.instance_properties) 141 volume_size=self.label.volume_size,
142 instance_properties=self.label.instance_properties)
143 except openstack.cloud.exc.OpenStackCloudCreateException as e:
144 if e.resource_id:
145 self.node.external_id = e.resource_id
146 # The outer exception handler will handle storing the
147 # node immediately after this.
148 raise
141 149
142 self.node.external_id = server.id 150 self.node.external_id = server.id
143 self.node.hostname = hostname 151 self.node.hostname = hostname