diff options
author | Steve Baker <sbaker@redhat.com> | 2021-03-19 09:34:28 +1300 |
---|---|---|
committer | Dmitry Tantsur <dtantsur@protonmail.com> | 2021-03-19 12:08:43 +0100 |
commit | e61336602f2f3054511dc9e381a7f0c1f18fda82 (patch) | |
tree | 61ccae971bc4515963b0337af2d64f9db37a426d | |
parent | 85b3afd863aec09940b44da9ed89d7cfcbf66e82 (diff) | |
download | ironic-python-agent-e61336602f2f3054511dc9e381a7f0c1f18fda82.tar.gz |
Fix root UUID for streamed partition images
The root UUID changes after a streamed partition image is written to
the block device, causing later deployment failure when assuming the
old UUID.
This change updates the root UUID after streaming the partition image
is complete.
This issue may have been missed in local testing because deploying the
same image repeatedly will result in stable root UUID across runs.
Change-Id: Ice4630c16fc216980488d1427f3b02e1b8a417fa
-rw-r--r-- | ironic_python_agent/extensions/standby.py | 4 | ||||
-rw-r--r-- | ironic_python_agent/tests/unit/extensions/test_standby.py | 12 | ||||
-rw-r--r-- | releasenotes/notes/streaming-uuid-fdf136a7745fbb3d.yaml | 5 |
3 files changed, 20 insertions, 1 deletions
diff --git a/ironic_python_agent/extensions/standby.py b/ironic_python_agent/extensions/standby.py index 333bbe84..5f1b9945 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 a25d38ac..9f138e47 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 00000000..462c9c91 --- /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. |