summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJames E. Blair <jeblair@redhat.com>2018-11-29 15:19:46 -0800
committerJames E. Blair <jeblair@redhat.com>2018-11-29 15:19:46 -0800
commit56164c886a81c5d5c67eaac789a6288dd555189b (patch)
tree712c8d45611aa8a70ab8921fc31a72b8b2f8efbf
parent81936cd818bbf5cf8084160c112e4a1a5a5aa03b (diff)
OpenStack: count leaked nodes in unmanaged quota
If a node has leaked, it won't be counted against quota because it's still recognized as belonging to the nodepool provider so it doesn't count against unmanaged quota, however, there is no zk record for it, so it also isn't counted against managed quota. This throws quota calculations off for as long as the leaked instances exist in nova. To correct this, count leaked nodes against unmanaged quota. Change-Id: I5a658649b881ed80b777096ec48cb6207f2a9cc6
Notes
Notes (review): Code-Review+2: Paul Belanger <pabelanger@redhat.com> Code-Review+2: Clark Boylan <cboylan@sapwetik.org> 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:50 +0000 Reviewed-on: https://review.openstack.org/621040 Project: openstack-infra/nodepool Branch: refs/heads/master
-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))