Skip to content

Commit 75f3b50

Browse files
authored
Merge pull request #81 from stackhpc/upstream/zed-2024-07-08
Synchronise zed with upstream
2 parents 916efd4 + d69d441 commit 75f3b50

File tree

4 files changed

+53
-0
lines changed

4 files changed

+53
-0
lines changed

.zuul.yaml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -591,9 +591,21 @@
591591
irrelevant-files: *nova-base-irrelevant-files
592592
required-projects:
593593
- openstack/nova
594+
- name: openstack/cinder-tempest-plugin
595+
override-checkout: zed-last
594596
pre-run:
595597
- playbooks/ceph/glance-copy-policy.yaml
596598
vars:
599+
# NOTE(elod.illes): this job started to break with the following five
600+
# test cases, somewhere around merging cinder-tempest-plugin patch
601+
# I281f881ad565e565839522ddf02057f7545c7146 so let's just exclude
602+
# them to unblock the gate.
603+
tempest_exclude_regex: "\
604+
(test_delete_dep_chain)|\
605+
(test_delete_dep_chain_2)|\
606+
(test_delete_source_snapshot)|\
607+
(test_delete_source_volume)|\
608+
(test_nova_image_snapshot_dependency)"
597609
# NOTE(danms): These tests create an empty non-raw image, which nova
598610
# will refuse because we set never_download_image_if_on_rbd in this job.
599611
# Just skip these tests for this case.

nova/tests/unit/virt/libvirt/test_utils.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -382,6 +382,7 @@ class FakeImgInfo(object):
382382
FakeImgInfo.file_format = file_format
383383
FakeImgInfo.backing_file = backing_file
384384
FakeImgInfo.virtual_size = 1
385+
FakeImgInfo.format_specific = None if file_format == 'raw' else {}
385386

386387
return FakeImgInfo()
387388

nova/tests/unit/virt/test_images.py

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,37 @@ def test_fetch_to_raw_errors(self, convert_image, qemu_img_info, fetch):
112112
images.fetch_to_raw,
113113
None, 'href123', '/no/path')
114114

115+
@mock.patch.object(images, 'convert_image',
116+
side_effect=exception.ImageUnacceptable)
117+
@mock.patch.object(images, 'qemu_img_info')
118+
@mock.patch.object(images, 'fetch')
119+
def test_fetch_to_raw_data_file(self, convert_image, qemu_img_info_fn,
120+
fetch):
121+
# NOTE(danms): the above test needs the following line as well, as it
122+
# is broken without it.
123+
qemu_img_info = qemu_img_info_fn.return_value
124+
qemu_img_info.backing_file = None
125+
qemu_img_info.file_format = 'qcow2'
126+
qemu_img_info.virtual_size = 20
127+
qemu_img_info.format_specific = {'data': {'data-file': 'somefile'}}
128+
self.assertRaisesRegex(exception.ImageUnacceptable,
129+
'Image href123 is unacceptable.*somefile',
130+
images.fetch_to_raw,
131+
None, 'href123', '/no/path')
132+
133+
@mock.patch('os.rename')
134+
@mock.patch.object(images, 'qemu_img_info')
135+
@mock.patch.object(images, 'fetch')
136+
def test_fetch_to_raw_from_raw(self, fetch, qemu_img_info_fn, mock_rename):
137+
# Make sure we support a case where we fetch an already-raw image and
138+
# qemu-img returns None for "format_specific".
139+
qemu_img_info = qemu_img_info_fn.return_value
140+
qemu_img_info.file_format = 'raw'
141+
qemu_img_info.backing_file = None
142+
qemu_img_info.format_specific = None
143+
images.fetch_to_raw(None, 'href123', '/no/path')
144+
mock_rename.assert_called_once_with('/no/path.part', '/no/path')
145+
115146
@mock.patch.object(compute_utils, 'disk_ops_semaphore')
116147
@mock.patch('nova.privsep.utils.supports_direct_io', return_value=True)
117148
@mock.patch('oslo_concurrency.processutils.execute')

nova/virt/images.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,15 @@ def fetch_to_raw(context, image_href, path, trusted_certs=None):
157157
reason=(_("fmt=%(fmt)s backed by: %(backing_file)s") %
158158
{'fmt': fmt, 'backing_file': backing_file}))
159159

160+
try:
161+
data_file = data.format_specific['data']['data-file']
162+
except (KeyError, TypeError, AttributeError):
163+
data_file = None
164+
if data_file is not None:
165+
raise exception.ImageUnacceptable(image_id=image_href,
166+
reason=(_("fmt=%(fmt)s has data-file: %(data_file)s") %
167+
{'fmt': fmt, 'data_file': data_file}))
168+
160169
if fmt == 'vmdk':
161170
check_vmdk_image(image_href, data)
162171

0 commit comments

Comments
 (0)