-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This adds the bulk of the image pre-caching logic to the conductor task manager. It takes an aggregate and list of image ids from the API service and handles the process of calling to the relevant compute nodes to initiate the image downloads, honoring the (new) config knob for overall task parallelism. Related to blueprint image-precache-support Change-Id: Id7c0ab7ae0586d49d88ff2afae149e25e59a3489
- Loading branch information
Showing
11 changed files
with
312 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
# Licensed under the Apache License, Version 2.0 (the "License"); you may | ||
# not use this file except in compliance with the License. You may obtain | ||
# a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT | ||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the | ||
# License for the specific language governing permissions and limitations | ||
# under the License. | ||
|
||
from oslo_config import cfg | ||
|
||
imagecache_group = cfg.OptGroup( | ||
'image_cache', | ||
title='Image Cache Options', | ||
help=""" | ||
A collection of options specific to image caching. | ||
""") | ||
imagecache_opts = [ | ||
cfg.IntOpt('precache_concurrency', | ||
default=1, | ||
min=1, | ||
help=""" | ||
Maximum number of compute hosts to trigger image precaching in parallel. | ||
When an image precache request is made, compute nodes will be contacted | ||
to initiate the download. This number constrains the number of those that | ||
will happen in parallel. Higher numbers will cause more computes to work | ||
in parallel and may result in reduced time to complete the operation, but | ||
may also DDoS the image service. Lower numbers will result in more sequential | ||
operation, lower image service load, but likely longer runtime to completion. | ||
"""), | ||
] | ||
|
||
|
||
ALL_OPTS = (imagecache_opts,) | ||
|
||
|
||
def register_opts(conf): | ||
conf.register_group(imagecache_group) | ||
conf.register_opts(imagecache_opts, group=imagecache_group) | ||
|
||
|
||
def list_opts(): | ||
return {imagecache_group: imagecache_opts} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
# Licensed under the Apache License, Version 2.0 (the "License"); you may | ||
# not use this file except in compliance with the License. You may obtain | ||
# a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT | ||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the | ||
# License for the specific language governing permissions and limitations | ||
# under the License. | ||
|
||
from oslo_utils.fixture import uuidsentinel as uuids | ||
|
||
from nova import context | ||
from nova import objects | ||
from nova import test | ||
from nova.tests.unit import fake_notifier | ||
|
||
|
||
class ImageCacheTest(test.TestCase): | ||
NUMBER_OF_CELLS = 2 | ||
|
||
def setUp(self): | ||
super(ImageCacheTest, self).setUp() | ||
|
||
self.flags(compute_driver='fake.FakeDriverWithCaching') | ||
|
||
fake_notifier.stub_notifier(self) | ||
self.addCleanup(fake_notifier.reset) | ||
self.context = context.get_admin_context() | ||
|
||
self.conductor = self.start_service('conductor') | ||
self.compute1 = self.start_service('compute', host='compute1') | ||
self.compute2 = self.start_service('compute', host='compute2') | ||
self.compute3 = self.start_service('compute', host='compute3', | ||
cell='cell2') | ||
self.compute4 = self.start_service('compute', host='compute4', | ||
cell='cell2') | ||
self.compute5 = self.start_service('compute', host='compute5', | ||
cell='cell2') | ||
|
||
cell2 = self.cell_mappings['cell2'] | ||
with context.target_cell(self.context, cell2) as cctxt: | ||
srv = objects.Service.get_by_compute_host(cctxt, 'compute5') | ||
srv.forced_down = True | ||
srv.save() | ||
|
||
def test_cache_image(self): | ||
"""Test caching images by injecting the request directly to | ||
the conductor service and making sure it fans out and calls | ||
the expected nodes. | ||
""" | ||
|
||
aggregate = objects.Aggregate(name='test', | ||
uuid=uuids.aggregate, | ||
id=1, | ||
hosts=['compute1', 'compute3', | ||
'compute4', 'compute5']) | ||
self.conductor.compute_task_mgr.cache_images( | ||
self.context, aggregate, ['an-image']) | ||
|
||
# NOTE(danms): We expect only three image cache attempts because | ||
# compute5 is marked as forced-down and compute2 is not in the | ||
# requested aggregate. | ||
for host in ['compute1', 'compute3', 'compute4']: | ||
mgr = getattr(self, host) | ||
self.assertEqual(set(['an-image']), mgr.driver.cached_images) | ||
for host in ['compute2', 'compute5']: | ||
mgr = getattr(self, host) | ||
self.assertEqual(set(), mgr.driver.cached_images) | ||
|
||
fake_notifier.wait_for_versioned_notifications( | ||
'aggregate.cache_images.start') | ||
fake_notifier.wait_for_versioned_notifications( | ||
'aggregate.cache_images.end') |
Oops, something went wrong.