Browse Source

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
James E. Blair 4 months ago
parent
commit
56164c886a
1 changed files with 11 additions and 5 deletions
  1. 11
    5
      nodepool/driver/openstack/provider.py

+ 11
- 5
nodepool/driver/openstack/provider.py View File

@@ -182,15 +182,21 @@ class OpenStackProvider(Provider):
182 182
         flavors = self.listFlavorsById()
183 183
         used_quota = QuotaInformation()
184 184
 
185
+        node_ids = set([n.id for n in self._zk.nodeIterator()])
186
+
185 187
         for server in self.listNodes():
186 188
             meta = server.get('metadata', {})
187 189
 
188 190
             nodepool_provider_name = meta.get('nodepool_provider_name')
189
-            if nodepool_provider_name and \
190
-                    nodepool_provider_name == self.provider.name:
191
-                # This provider (regardless of the launcher) owns this server
192
-                # so it must not be accounted for unmanaged quota.
193
-                continue
191
+            if (nodepool_provider_name and
192
+                nodepool_provider_name == self.provider.name):
193
+                # This provider (regardless of the launcher) owns this
194
+                # server so it must not be accounted for unmanaged
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 201
             flavor = flavors.get(server.flavor.id)
196 202
             used_quota.add(QuotaInformation.construct_from_flavor(flavor))

Loading…
Cancel
Save