Partial revert for disabled provider change

Commit 1cf2cddf9d attempted to
short-circuit request handling when a provider was disabled by
setting max-servers to 0. That prevents the provider from declining
any requests, and thus prevents a request from ever reaching
FAILURE status if none of the other providers can satisfy it (the
request declined_by array is compared against the list of registered
launchers).

This adds a test for this case (which was run against the current
code and proved it was broken).

Change-Id: I8a2f9771b55b08259ecffa3475bdd2d4f2654464
This commit is contained in:
David Shrewsbury 2018-01-29 13:21:16 -05:00
parent 9fece4da71
commit 6c6cbfc209
3 changed files with 70 additions and 4 deletions

View File

@ -157,13 +157,11 @@ class PoolWorker(threading.Thread):
the handler for completion.
'''
provider = self.getProviderConfig()
if not provider or (self.pool_name not in provider.pools):
if not provider:
self.log.info("Missing config. Deleted provider?")
return
pool_config = provider.pools[self.pool_name]
if provider.max_concurrency == 0 or pool_config.max_servers <= 0:
if provider.max_concurrency == 0:
return
for req_id in self.zk.getNodeRequests():

View File

@ -0,0 +1,47 @@
elements-dir: .
images-dir: '{images_dir}'
zookeeper-servers:
- host: {zookeeper_host}
port: {zookeeper_port}
chroot: {zookeeper_chroot}
labels:
- name: fake-label
min-ready: 1
providers:
- name: fake-provider
cloud: fake
driver: fake
region-name: fake-region
rate: 0.0001
diskimages:
- name: fake-image
meta:
key: value
key2: value
pools:
- name: main
max-servers: 0
availability-zones:
- az1
networks:
- net-name
labels:
- name: fake-label
diskimage: fake-image
min-ram: 8192
flavor-name: 'Fake'
diskimages:
- name: fake-image
elements:
- fedora
- vm
release: 21
env-vars:
TMPDIR: /opt/dib_tmp
DIB_IMAGE_CACHE: /opt/dib_cache
DIB_CLOUD_IMAGES: http://download.fedoraproject.org/pub/fedora/linux/releases/test/21-Beta/Cloud/Images/x86_64/
BASE_IMAGE_FILE: Fedora-Cloud-Base-20141029-21_Beta.x86_64.qcow2

View File

@ -1013,3 +1013,24 @@ class TestLauncher(tests.DBTestCase):
self.assertEqual(req.state, zk.FULFILLED)
self.assertEqual(1, len(req.declined_by))
self.assertIn('fake-provider-main', req.declined_by[0])
def test_disabled_provider(self):
'''
A request should fail even with a provider that is disabled by
setting max-servers to 0. Because we look to see that all providers
decline a request by comparing the declined_by request attribute to
the list of registered launchers, this means that each must attempt
to handle it at least once, and thus decline it.
'''
configfile = self.setup_config('disabled_provider.yaml')
self.useBuilder(configfile)
pool = self.useNodepool(configfile, watermark_sleep=1)
pool.start()
req = zk.NodeRequest()
req.state = zk.REQUESTED
req.node_types.append('fake-label')
self.zk.storeNodeRequest(req)
req = self.waitForNodeRequest(req)
self.assertEqual(req.state, zk.FAILED)