diff --git a/ironic_python_agent/extensions/standby.py b/ironic_python_agent/extensions/standby.py index 333bbe848..5f1b9945d 100644 --- a/ironic_python_agent/extensions/standby.py +++ b/ironic_python_agent/extensions/standby.py @@ -600,6 +600,10 @@ class StandbyExtension(base.BaseAgentExtension): except exception.InstanceDeployFailure: # Note: the catch internal to the helper method logs any errors. pass + # Fix the root partition UUID + root_uuid = disk_utils.block_uuid(device) + LOG.info("{} UUID is now {}".format(device, root_uuid)) + self.partition_uuids['root uuid'] = root_uuid def _fix_up_partition_uuids(self, image_info, device): if self.partition_uuids is None: diff --git a/ironic_python_agent/tests/unit/extensions/test_standby.py b/ironic_python_agent/tests/unit/extensions/test_standby.py index a25d38ac5..9f138e47d 100644 --- a/ironic_python_agent/tests/unit/extensions/test_standby.py +++ b/ironic_python_agent/tests/unit/extensions/test_standby.py @@ -1169,12 +1169,14 @@ class TestStandbyExtension(base.IronicAgentTest): download_mock.assert_called_once_with(image_info) write_mock.assert_called_once_with(image_info, device) + @mock.patch('ironic_lib.disk_utils.block_uuid', autospec=True) @mock.patch('ironic_lib.disk_utils.fix_gpt_partition', autospec=True) @mock.patch('hashlib.md5', autospec=True) @mock.patch('builtins.open', autospec=True) @mock.patch('requests.get', autospec=True) def test_stream_raw_image_onto_device(self, requests_mock, open_mock, - md5_mock, fix_gpt_mock): + md5_mock, fix_gpt_mock, + block_uuid_mock): image_info = _build_fake_image_info() response = requests_mock.return_value response.status_code = 200 @@ -1184,6 +1186,9 @@ class TestStandbyExtension(base.IronicAgentTest): file_mock.read.return_value = None hexdigest_mock = md5_mock.return_value.hexdigest hexdigest_mock.return_value = image_info['checksum'] + self.agent_extension.partition_uuids = {} + + block_uuid_mock.return_value = 'aaaabbbb' self.agent_extension._stream_raw_image_onto_device(image_info, '/dev/foo') @@ -1194,6 +1199,11 @@ class TestStandbyExtension(base.IronicAgentTest): expected_calls = [mock.call('some'), mock.call('content')] file_mock.write.assert_has_calls(expected_calls) fix_gpt_mock.assert_called_once_with('/dev/foo', node_uuid=None) + block_uuid_mock.assert_called_once_with('/dev/foo') + self.assertEqual( + 'aaaabbbb', + self.agent_extension.partition_uuids['root uuid'] + ) @mock.patch('hashlib.md5', autospec=True) @mock.patch('builtins.open', autospec=True) diff --git a/releasenotes/notes/streaming-uuid-fdf136a7745fbb3d.yaml b/releasenotes/notes/streaming-uuid-fdf136a7745fbb3d.yaml new file mode 100644 index 000000000..462c9c91f --- /dev/null +++ b/releasenotes/notes/streaming-uuid-fdf136a7745fbb3d.yaml @@ -0,0 +1,5 @@ +--- +fixes: + - | + Fixes incorrect root partition UUID after streaming a raw partition + image.