Update some variable names
Now that the component we registered is a "pool" change the call sites to use "launcher_pools" instead of "launchers". This may reduce some ambiguity. (s/launcher/pool/ might still be ambiguous since it may not be clear whethere we're talking about our own pools or other pools; thus the choice of "launcher_pool" for the variable name.) Also, remove a redundant test assertion. Change-Id: I865883cdb115bf72a3bd034d9290f60666d64b66
This commit is contained in:
parent
ea35fd5152
commit
1323d0b556
|
@ -641,9 +641,9 @@ class NodeRequestHandler(NodeRequestHandlerNotifications,
|
||||||
# want to make sure we don't continuously grow this array.
|
# want to make sure we don't continuously grow this array.
|
||||||
if self.launcher_id not in self.request.declined_by:
|
if self.launcher_id not in self.request.declined_by:
|
||||||
self.request.declined_by.append(self.launcher_id)
|
self.request.declined_by.append(self.launcher_id)
|
||||||
launchers = set([x.id for x in self.zk.getRegisteredPools()])
|
launcher_pools = set([x.id for x in self.zk.getRegisteredPools()])
|
||||||
if launchers.issubset(set(self.request.declined_by)):
|
if launcher_pools.issubset(set(self.request.declined_by)):
|
||||||
# All launchers have declined it
|
# All launcher_pools have declined it
|
||||||
self.log.debug("Failing declined node request")
|
self.log.debug("Failing declined node request")
|
||||||
self.request.state = zk.FAILED
|
self.request.state = zk.FAILED
|
||||||
else:
|
else:
|
||||||
|
|
|
@ -121,7 +121,7 @@ class PoolWorker(threading.Thread, stats.StatsReporter):
|
||||||
# become out of date as the loop progresses, but it should be
|
# become out of date as the loop progresses, but it should be
|
||||||
# good enough to determine whether we should process requests
|
# good enough to determine whether we should process requests
|
||||||
# which express a preference for a specific provider.
|
# which express a preference for a specific provider.
|
||||||
launchers = self.zk.getRegisteredPools()
|
launcher_pools = self.zk.getRegisteredPools()
|
||||||
|
|
||||||
pm = self.getProviderManager()
|
pm = self.getProviderManager()
|
||||||
has_quota_support = isinstance(pm, QuotaSupport)
|
has_quota_support = isinstance(pm, QuotaSupport)
|
||||||
|
@ -180,8 +180,8 @@ class PoolWorker(threading.Thread, stats.StatsReporter):
|
||||||
log = get_annotated_logger(self.log, event_id=req.event_id,
|
log = get_annotated_logger(self.log, event_id=req.event_id,
|
||||||
node_request_id=req.id)
|
node_request_id=req.id)
|
||||||
# Get the candidate launchers for these nodes
|
# Get the candidate launchers for these nodes
|
||||||
candidate_launchers = set(
|
candidate_launcher_pools = set(
|
||||||
x for x in launchers
|
x for x in launcher_pools
|
||||||
if (set(x.supported_labels).issuperset(set(req.node_types)) and
|
if (set(x.supported_labels).issuperset(set(req.node_types)) and
|
||||||
x.id not in req.declined_by)
|
x.id not in req.declined_by)
|
||||||
)
|
)
|
||||||
|
@ -189,26 +189,26 @@ class PoolWorker(threading.Thread, stats.StatsReporter):
|
||||||
# which is online
|
# which is online
|
||||||
if req.provider and req.provider != self.provider_name:
|
if req.provider and req.provider != self.provider_name:
|
||||||
# The request is asking for a specific provider
|
# The request is asking for a specific provider
|
||||||
launcher_ids_for_provider = set(
|
launcher_pool_ids_for_provider = set(
|
||||||
x.id for x in candidate_launchers
|
x.id for x in candidate_launcher_pools
|
||||||
if x.provider_name == req.provider
|
if x.provider_name == req.provider
|
||||||
)
|
)
|
||||||
if launcher_ids_for_provider:
|
if launcher_pool_ids_for_provider:
|
||||||
# There is a launcher online which can satisfy the
|
# There is a launcher online which can satisfy the
|
||||||
# request that has not yet declined the request,
|
# request that has not yet declined the request,
|
||||||
# so yield to it.
|
# so yield to it.
|
||||||
log.debug("Yielding request to provider %s %s",
|
log.debug("Yielding request to provider %s %s",
|
||||||
req.provider, launcher_ids_for_provider)
|
req.provider, launcher_pool_ids_for_provider)
|
||||||
continue
|
continue
|
||||||
|
|
||||||
priority = self.getPriority()
|
priority = self.getPriority()
|
||||||
launcher_ids_with_higher_priority = set(
|
launcher_pool_ids_with_higher_priority = set(
|
||||||
x.id for x in candidate_launchers
|
x.id for x in candidate_launcher_pools
|
||||||
if x.priority < priority and not x.paused
|
if x.priority < priority and not x.paused
|
||||||
)
|
)
|
||||||
if launcher_ids_with_higher_priority:
|
if launcher_pool_ids_with_higher_priority:
|
||||||
log.debug("Yielding request to higher priority providers %s",
|
log.debug("Yielding request to higher priority providers %s",
|
||||||
launcher_ids_with_higher_priority)
|
launcher_pool_ids_with_higher_priority)
|
||||||
continue
|
continue
|
||||||
|
|
||||||
if has_quota_support and not all(label_quota.get(l, math.inf) > 0
|
if has_quota_support and not all(label_quota.get(l, math.inf) > 0
|
||||||
|
|
|
@ -98,13 +98,13 @@ class StatsReporter(object):
|
||||||
|
|
||||||
states = {}
|
states = {}
|
||||||
|
|
||||||
launchers = zk_conn.getRegisteredPools()
|
launcher_pools = zk_conn.getRegisteredPools()
|
||||||
labels = set()
|
labels = set()
|
||||||
for launcher in launchers:
|
for launcher_pool in launcher_pools:
|
||||||
labels.update(launcher.supported_labels)
|
labels.update(launcher_pool.supported_labels)
|
||||||
providers = set()
|
providers = set()
|
||||||
for launcher in launchers:
|
for launcher_pool in launcher_pools:
|
||||||
providers.add(launcher.provider_name)
|
providers.add(launcher_pool.provider_name)
|
||||||
|
|
||||||
# Initialize things we know about to zero
|
# Initialize things we know about to zero
|
||||||
for state in zk.Node.VALID_STATES:
|
for state in zk.Node.VALID_STATES:
|
||||||
|
|
|
@ -267,9 +267,9 @@ def label_list(zk):
|
||||||
# NOTE(ianw): maybe add to each entry a list of which
|
# NOTE(ianw): maybe add to each entry a list of which
|
||||||
# launchers support the label?
|
# launchers support the label?
|
||||||
labels = set()
|
labels = set()
|
||||||
launchers = zk.getRegisteredPools()
|
launcher_pools = zk.getRegisteredPools()
|
||||||
for launcher in launchers:
|
for launcher_pool in launcher_pools:
|
||||||
labels.update(set(launcher.supported_labels))
|
labels.update(set(launcher_pool.supported_labels))
|
||||||
|
|
||||||
for label in labels:
|
for label in labels:
|
||||||
objs.append({'label': label})
|
objs.append({'label': label})
|
||||||
|
|
|
@ -1669,7 +1669,6 @@ class TestLauncher(tests.DBTestCase):
|
||||||
self.assertEqual('secret', fake_image.env_vars['REG_PASSWORD'])
|
self.assertEqual('secret', fake_image.env_vars['REG_PASSWORD'])
|
||||||
|
|
||||||
zk_servers = pool.config.zookeeper_servers
|
zk_servers = pool.config.zookeeper_servers
|
||||||
self.assertTrue(len(zk_servers) > 0)
|
|
||||||
expected = (f'{self.zookeeper_host}:{self.zookeeper_port}'
|
expected = (f'{self.zookeeper_host}:{self.zookeeper_port}'
|
||||||
f'{self.zookeeper_chroot}')
|
f'{self.zookeeper_chroot}')
|
||||||
self.assertEqual(expected, zk_servers)
|
self.assertEqual(expected, zk_servers)
|
||||||
|
@ -1924,19 +1923,20 @@ class TestLauncher(tests.DBTestCase):
|
||||||
pool.start()
|
pool.start()
|
||||||
|
|
||||||
self.waitForNodes('fake-label')
|
self.waitForNodes('fake-label')
|
||||||
launchers = self.zk.getRegisteredPools()
|
launcher_pools = self.zk.getRegisteredPools()
|
||||||
self.assertEqual(1, len(launchers))
|
self.assertEqual(1, len(launcher_pools))
|
||||||
|
|
||||||
# the fake-label-unused label should not appear
|
# the fake-label-unused label should not appear
|
||||||
self.assertEqual({'fake-label'}, set(launchers[0].supported_labels))
|
self.assertEqual({'fake-label'},
|
||||||
|
set(launcher_pools[0].supported_labels))
|
||||||
|
|
||||||
self.replace_config(configfile, 'launcher_reg2.yaml')
|
self.replace_config(configfile, 'launcher_reg2.yaml')
|
||||||
|
|
||||||
# we should get 1 additional label now
|
# we should get 1 additional label now
|
||||||
while (set(launchers[0].supported_labels) !=
|
while (set(launcher_pools[0].supported_labels) !=
|
||||||
{'fake-label', 'fake-label2'}):
|
{'fake-label', 'fake-label2'}):
|
||||||
time.sleep(1)
|
time.sleep(1)
|
||||||
launchers = self.zk.getRegisteredPools()
|
launcher_pools = self.zk.getRegisteredPools()
|
||||||
|
|
||||||
@mock.patch('nodepool.driver.openstack.handler.'
|
@mock.patch('nodepool.driver.openstack.handler.'
|
||||||
'OpenStackNodeLauncher._launchNode')
|
'OpenStackNodeLauncher._launchNode')
|
||||||
|
|
|
@ -40,13 +40,13 @@ class TestComponentRegistry(tests.DBTestCase):
|
||||||
})
|
})
|
||||||
launcher.register()
|
launcher.register()
|
||||||
|
|
||||||
launchers = self.zk.getRegisteredPools()
|
launcher_pools = self.zk.getRegisteredPools()
|
||||||
self.assertEqual(1, len(launchers))
|
self.assertEqual(1, len(launcher_pools))
|
||||||
self.assertEqual(launcher.id, list(launchers)[0].id)
|
self.assertEqual(launcher.id, list(launcher_pools)[0].id)
|
||||||
|
|
||||||
launcher.unregister()
|
launcher.unregister()
|
||||||
launchers = self.zk.getRegisteredPools()
|
launcher_pools = self.zk.getRegisteredPools()
|
||||||
self.assertEqual(0, len(launchers))
|
self.assertEqual(0, len(launcher_pools))
|
||||||
|
|
||||||
|
|
||||||
class TestZooKeeper(tests.DBTestCase):
|
class TestZooKeeper(tests.DBTestCase):
|
||||||
|
|
Loading…
Reference in New Issue