From 323e9f5f93c99121c6ee34e711fb4fd1d191e430 Mon Sep 17 00:00:00 2001 From: Dan Smith Date: Wed, 9 Nov 2022 07:33:37 -0800 Subject: [PATCH 1/2] Fix unintentional exception inspecting VMDK It looks like a raise statement was left in the virtual_size property handler for VMDK, which should have been converted to a log at some point. All the other inspectors return zero for virtual_size if the format does not match or they are unable to parse the data. This converts that raise to a log, and adds a test to make sure we make it far enough in the processing of the complex VMDK format to ensure that behavior. Closes-Bug: #1983279 Change-Id: I0352ab6b2c00055de094ac5902b8d50941d06dcf (cherry picked from commit 199722a65a88f9c28b554b180ec36415ed3a51ac) (cherry picked from commit 07f98747a2d4bf65f44348603ecba639d602db4d) --- glance/common/format_inspector.py | 2 +- .../tests/unit/common/test_format_inspector.py | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/glance/common/format_inspector.py b/glance/common/format_inspector.py index fbd20273be..351c300ddb 100755 --- a/glance/common/format_inspector.py +++ b/glance/common/format_inspector.py @@ -567,7 +567,7 @@ def virtual_size(self): 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 4b29c19b30..d229d094fb 100644 --- a/glance/tests/unit/common/test_format_inspector.py +++ b/glance/tests/unit/common/test_format_inspector.py @@ -153,6 +153,24 @@ def test_vmdk_invalid(self): 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): From 76339c30770fbf4f67f665741f1c8f385bcb68f8 Mon Sep 17 00:00:00 2001 From: OpenStack Release Bot Date: Fri, 9 Feb 2024 15:19:06 +0000 Subject: [PATCH 2/2] Update .gitreview for unmaintained/yoga Change-Id: I21b308c70c14255d29ae2e1feffa2c3fd59fd6eb --- .gitreview | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitreview b/.gitreview index 740efa07cf..b4a2ec88e6 100644 --- a/.gitreview +++ b/.gitreview @@ -2,4 +2,4 @@ host=review.opendev.org port=29418 project=openstack/glance.git -defaultbranch=stable/yoga +defaultbranch=unmaintained/yoga