Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions .zuul.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -591,9 +591,21 @@
irrelevant-files: *nova-base-irrelevant-files
required-projects:
- openstack/nova
- name: openstack/cinder-tempest-plugin
override-checkout: zed-last
pre-run:
- playbooks/ceph/glance-copy-policy.yaml
vars:
# NOTE(elod.illes): this job started to break with the following five
# test cases, somewhere around merging cinder-tempest-plugin patch
# I281f881ad565e565839522ddf02057f7545c7146 so let's just exclude
# them to unblock the gate.
tempest_exclude_regex: "\
(test_delete_dep_chain)|\
(test_delete_dep_chain_2)|\
(test_delete_source_snapshot)|\
(test_delete_source_volume)|\
(test_nova_image_snapshot_dependency)"
# NOTE(danms): These tests create an empty non-raw image, which nova
# will refuse because we set never_download_image_if_on_rbd in this job.
# Just skip these tests for this case.
Expand Down
1 change: 1 addition & 0 deletions nova/tests/unit/virt/libvirt/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -382,6 +382,7 @@ class FakeImgInfo(object):
FakeImgInfo.file_format = file_format
FakeImgInfo.backing_file = backing_file
FakeImgInfo.virtual_size = 1
FakeImgInfo.format_specific = None if file_format == 'raw' else {}

return FakeImgInfo()

Expand Down
31 changes: 31 additions & 0 deletions nova/tests/unit/virt/test_images.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,37 @@ def test_fetch_to_raw_errors(self, convert_image, qemu_img_info, fetch):
images.fetch_to_raw,
None, 'href123', '/no/path')

@mock.patch.object(images, 'convert_image',
side_effect=exception.ImageUnacceptable)
@mock.patch.object(images, 'qemu_img_info')
@mock.patch.object(images, 'fetch')
def test_fetch_to_raw_data_file(self, convert_image, qemu_img_info_fn,
fetch):
# NOTE(danms): the above test needs the following line as well, as it
# is broken without it.
qemu_img_info = qemu_img_info_fn.return_value
qemu_img_info.backing_file = None
qemu_img_info.file_format = 'qcow2'
qemu_img_info.virtual_size = 20
qemu_img_info.format_specific = {'data': {'data-file': 'somefile'}}
self.assertRaisesRegex(exception.ImageUnacceptable,
'Image href123 is unacceptable.*somefile',
images.fetch_to_raw,
None, 'href123', '/no/path')

@mock.patch('os.rename')
@mock.patch.object(images, 'qemu_img_info')
@mock.patch.object(images, 'fetch')
def test_fetch_to_raw_from_raw(self, fetch, qemu_img_info_fn, mock_rename):
# Make sure we support a case where we fetch an already-raw image and
# qemu-img returns None for "format_specific".
qemu_img_info = qemu_img_info_fn.return_value
qemu_img_info.file_format = 'raw'
qemu_img_info.backing_file = None
qemu_img_info.format_specific = None
images.fetch_to_raw(None, 'href123', '/no/path')
mock_rename.assert_called_once_with('/no/path.part', '/no/path')

@mock.patch.object(compute_utils, 'disk_ops_semaphore')
@mock.patch('nova.privsep.utils.supports_direct_io', return_value=True)
@mock.patch('oslo_concurrency.processutils.execute')
Expand Down
9 changes: 9 additions & 0 deletions nova/virt/images.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,15 @@ def fetch_to_raw(context, image_href, path, trusted_certs=None):
reason=(_("fmt=%(fmt)s backed by: %(backing_file)s") %
{'fmt': fmt, 'backing_file': backing_file}))

try:
data_file = data.format_specific['data']['data-file']
except (KeyError, TypeError, AttributeError):
data_file = None
if data_file is not None:
raise exception.ImageUnacceptable(image_id=image_href,
reason=(_("fmt=%(fmt)s has data-file: %(data_file)s") %
{'fmt': fmt, 'data_file': data_file}))

if fmt == 'vmdk':
check_vmdk_image(image_href, data)

Expand Down