summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZuul <zuul@review.openstack.org>2018-11-30 14:29:50 +0000
committerGerrit Code Review <review@openstack.org>2018-11-30 14:29:50 +0000
commit1b53f38b9ccdb9eed98fe14028eb2ea9d0f4e126 (patch)
tree0d288a625774ef77690fcbb61d2ea9139a0f3720
parent7111fcb407a11baa1ea0d2bbee7ba76ec748e884 (diff)
parent56164c886a81c5d5c67eaac789a6288dd555189b (diff)
Merge "OpenStack: count leaked nodes in unmanaged quota"
-rwxr-xr-xnodepool/driver/openstack/provider.py16
1 files changed, 11 insertions, 5 deletions
diff --git a/nodepool/driver/openstack/provider.py b/nodepool/driver/openstack/provider.py
index d202f9f..325e9cb 100755
--- a/nodepool/driver/openstack/provider.py
+++ b/nodepool/driver/openstack/provider.py
@@ -182,15 +182,21 @@ class OpenStackProvider(Provider):
182 flavors = self.listFlavorsById() 182 flavors = self.listFlavorsById()
183 used_quota = QuotaInformation() 183 used_quota = QuotaInformation()
184 184
185 node_ids = set([n.id for n in self._zk.nodeIterator()])
186
185 for server in self.listNodes(): 187 for server in self.listNodes():
186 meta = server.get('metadata', {}) 188 meta = server.get('metadata', {})
187 189
188 nodepool_provider_name = meta.get('nodepool_provider_name') 190 nodepool_provider_name = meta.get('nodepool_provider_name')
189 if nodepool_provider_name and \ 191 if (nodepool_provider_name and
190 nodepool_provider_name == self.provider.name: 192 nodepool_provider_name == self.provider.name):
191 # This provider (regardless of the launcher) owns this server 193 # This provider (regardless of the launcher) owns this
192 # so it must not be accounted for unmanaged quota. 194 # server so it must not be accounted for unmanaged
193 continue 195 # quota; unless it has leaked.
196 nodepool_node_id = meta.get('nodepool_node_id')
197 if not (nodepool_node_id and nodepool_node_id in node_ids):
198 # It has not leaked.
199 continue
194 200
195 flavor = flavors.get(server.flavor.id) 201 flavor = flavors.get(server.flavor.id)
196 used_quota.add(QuotaInformation.construct_from_flavor(flavor)) 202 used_quota.add(QuotaInformation.construct_from_flavor(flavor))