diff options
author | Zuul <zuul@review.opendev.org> | 2023-05-10 17:41:21 +0000 |
---|---|---|
committer | Gerrit Code Review <review@openstack.org> | 2023-05-10 17:41:21 +0000 |
commit | 357e5ba1bb3a3a28baf844db698d1bfeff7593c1 (patch) | |
tree | 21961d69fec90a84c0accc94233fe7c9057767cb | |
parent | 641399fdd00966f0e6cedcaafffa787ac44dc7bd (diff) | |
parent | 323e9f5f93c99121c6ee34e711fb4fd1d191e430 (diff) | |
download | glance-stable/yoga.tar.gz |
Merge "Fix unintentional exception inspecting VMDK" into stable/yogastable/yoga
-rwxr-xr-x | glance/common/format_inspector.py | 2 | ||||
-rw-r--r-- | glance/tests/unit/common/test_format_inspector.py | 18 |
2 files changed, 19 insertions, 1 deletions
diff --git a/glance/common/format_inspector.py b/glance/common/format_inspector.py index fbd20273b..351c300dd 100755 --- a/glance/common/format_inspector.py +++ b/glance/common/format_inspector.py @@ -567,7 +567,7 @@ class VMDKInspector(FileInspector): else: vmdktype = b'formatnotfound' if vmdktype != b'monolithicSparse': - raise ImageFormatError('Unsupported VMDK format %s' % vmdktype) + LOG.warning('Unsupported VMDK format %s', vmdktype) return 0 # If we have the descriptor, we definitely have the header diff --git a/glance/tests/unit/common/test_format_inspector.py b/glance/tests/unit/common/test_format_inspector.py index 4b29c19b3..d229d094f 100644 --- a/glance/tests/unit/common/test_format_inspector.py +++ b/glance/tests/unit/common/test_format_inspector.py @@ -153,6 +153,24 @@ class TestFormatInspectors(test_utils.BaseTestCase): def test_vdi_invalid(self): self._test_format_with_invalid_data('vdi') + def test_vmdk_invalid_type(self): + fmt = format_inspector.get_inspector('vmdk')() + wrapper = format_inspector.InfoWrapper(open(__file__, 'rb'), fmt) + while True: + chunk = wrapper.read(32) + if not chunk: + break + + wrapper.close() + + fake_rgn = mock.MagicMock() + fake_rgn.complete = True + fake_rgn.data = b'foocreateType="someunknownformat"bar' + + with mock.patch.object(fmt, 'has_region', return_value=True): + with mock.patch.object(fmt, 'region', return_value=fake_rgn): + self.assertEqual(0, fmt.virtual_size) + class TestFormatInspectorInfra(test_utils.BaseTestCase): def _test_capture_region_bs(self, bs): |