Fix metastatic missing pool config

The metastatic driver was ignoring the 3 standard pool configuration
options (max-servers, priority, and node-attributes) due to a missing
superclass method call.  Correct that and update tests to validate.

Further, the node-attributes option was undocumented for the metastatic
driver, so add it to the docs.

Change-Id: I6a65ea5b8ddb319bc131f87e0793f3626379e15f
Co-Authored-By: Benedikt Loeffler <benedikt.loeffler@bmw.de>
This commit is contained in:
James E. Blair 2023-10-23 10:04:02 -07:00
parent 28d36ad5a5
commit 7a1c75f918
4 changed files with 28 additions and 0 deletions

View File

@ -85,6 +85,12 @@ itself, which is "meta".
to apply to all pools within that provider, or it can be
overridden here for a specific pool.
.. attr:: node-attributes
:type: dict
A dictionary of key-value pairs that will be stored with the node data
in ZooKeeper. The keys and values can be any arbitrary string.
.. attr:: max-servers
:type: int

View File

@ -79,6 +79,7 @@ class MetastaticPool(ConfigPool):
self.load(pool_config)
def load(self, pool_config):
super().load(pool_config)
self.name = pool_config['name']
self.max_servers = pool_config.get('max-servers', math.inf)
for label in pool_config.get('labels', []):

View File

@ -34,6 +34,9 @@ providers:
pools:
- name: main
max-servers: 96
node-attributes:
backattr: back
testattr: backing
labels:
- name: backing-label
cloud-image: fake-image
@ -45,6 +48,10 @@ providers:
pools:
- name: main
max-servers: 10
priority: 1
node-attributes:
metaattr: meta
testattr: metastatic
labels:
- name: user-label
backing-label: backing-label

View File

@ -85,6 +85,12 @@ class TestDriverMetastatic(tests.DBTestCase):
pool = self.useNodepool(configfile, watermark_sleep=1)
self.startPool(pool)
manager = pool.getProviderManager('fake-provider')
pool_worker = pool.getPoolWorkers('meta-provider')[0]
pool_config = pool_worker.getPoolConfig()
self.assertEqual(pool_config.max_servers, 10)
self.assertEqual(pool_config.priority, 1)
manager.adapter._client.create_image(name="fake-image")
# Request a node, verify that there is a backing node, and it
@ -104,6 +110,14 @@ class TestDriverMetastatic(tests.DBTestCase):
self.assertEqual(bn1.host_keys, node1.host_keys)
self.assertEqual(['ssh-rsa FAKEKEY'], node1.host_keys)
self.assertEqual(bn1.id, node1.driver_data['backing_node'])
self.assertEqual(bn1.attributes, {
'backattr': 'back',
'testattr': 'backing',
})
self.assertEqual(node1.attributes, {
'metaattr': 'meta',
'testattr': 'metastatic',
})
# Allocate a second node, should have same backing node
node2 = self._requestNode()