Skip to content

Commit badcd94

Browse files
Zuulopenstack-gerrit
authored andcommitted
Merge "oci: permit an 'unknown' but valid image"
2 parents 173c754 + c4998fc commit badcd94

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

ironic_python_agent/disk_utils.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -444,7 +444,9 @@ def get_and_validate_image_format(filename, ironic_disk_format):
444444
raise errors.InvalidImage(
445445
details=msg % (img_format, fmts)
446446
)
447-
elif ironic_disk_format and ironic_disk_format != img_format:
447+
elif (ironic_disk_format
448+
and ironic_disk_format != img_format
449+
and ironic_disk_format != 'unknown'):
448450
msg = ("Security: Expected format was %s, but image was "
449451
"actually %s" % (ironic_disk_format, img_format))
450452
LOG.error(msg)

ironic_python_agent/tests/unit/test_disk_utils.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1013,6 +1013,18 @@ def test_format_mismatch(self, mock_ii):
10131013
disk_utils.get_and_validate_image_format,
10141014
'/fake/path', fmt)
10151015

1016+
@mock.patch.object(disk_utils, '_image_inspection', autospec=True)
1017+
def test_format_unknown_happy(self, mock_ii):
1018+
"""ironic_disk_format=unknown, but we detect it as a qcow3"""
1019+
CONF.set_override('disable_deep_image_inspection', False)
1020+
fmt = 'unknown'
1021+
mock_ii.return_value = MockFormatInspectorCls('qcow2', 0, True)
1022+
self.assertEqual(
1023+
('qcow2', 0),
1024+
disk_utils.get_and_validate_image_format('/fake/path', fmt)
1025+
)
1026+
mock_ii.assert_called_once_with('/fake/path')
1027+
10161028
@mock.patch.object(disk_utils, '_image_inspection', autospec=True)
10171029
@mock.patch.object(qemu_img, 'image_info', autospec=True)
10181030
def test_format_mismatch_but_disabled(self, mock_info, mock_ii):

0 commit comments

Comments
 (0)