Browse Source

Merge "OpenStack: count leaked nodes in unmanaged quota"

Zuul 4 months ago
parent
commit
1b53f38b9c
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