From 3b7e6abcbc7d920c906d86727830bb12b4b9bc7b Mon Sep 17 00:00:00 2001 From: wangkf Date: Thu, 6 Jul 2017 19:46:22 +0800 Subject: [PATCH] Change ramdisk log filename template ironic collects ramdisk logs from agent, and save it to /var/log/ironic/deploy. The time stamp part of log filename is formatted as '%Y-%m-%d-%H:%M:%S', as an example: 7b52d13a-9372-448d-9252-fffbaf2db942_1fb52a75-04b6-4c73-80c4-\ 8d49dc30f650_2017-07-06-09:03:18.tar.gz The colon is not handled properly by tar, it fails to untar a file with colon in file name. This patch provides a workaround by changing colon with dash in time stamp. Closes-Bug: #1702672 Change-Id: I1d60939768ffa75de050aa309a3203de553ae877 --- ironic/drivers/utils.py | 2 +- ironic/tests/unit/drivers/test_utils.py | 4 ++-- ...hange-ramdisk-log-filename-142b10d0b02a5ca6.yaml | 13 +++++++++++++ 3 files changed, 16 insertions(+), 3 deletions(-) create mode 100644 releasenotes/notes/change-ramdisk-log-filename-142b10d0b02a5ca6.yaml diff --git a/ironic/drivers/utils.py b/ironic/drivers/utils.py index 65902bf031..860a89922a 100644 --- a/ironic/drivers/utils.py +++ b/ironic/drivers/utils.py @@ -269,7 +269,7 @@ def get_ramdisk_logs_file_name(node): :param node: A node object. :returns: The log file name. """ - timestamp = timeutils.utcnow().strftime('%Y-%m-%d-%H:%M:%S') + timestamp = timeutils.utcnow().strftime('%Y-%m-%d-%H-%M-%S') file_name_fields = [node.uuid] if node.instance_uuid: file_name_fields.append(node.instance_uuid) diff --git a/ironic/tests/unit/drivers/test_utils.py b/ironic/tests/unit/drivers/test_utils.py index c0952bf078..4a1bc7f94b 100644 --- a/ironic/tests/unit/drivers/test_utils.py +++ b/ironic/tests/unit/drivers/test_utils.py @@ -260,7 +260,7 @@ class UtilsRamdiskLogsTestCase(tests_base.TestCase): mock_utcnow.return_value = datetime.datetime(2000, 1, 1, 0, 0) name = driver_utils.get_ramdisk_logs_file_name(self.node) expected_name = ('1be26c0b-03f2-4d2e-ae87-c02d7f33c123_' - '2000-01-01-00:00:00.tar.gz') + '2000-01-01-00-00-00.tar.gz') self.assertEqual(expected_name, name) # with instance_info @@ -269,7 +269,7 @@ class UtilsRamdiskLogsTestCase(tests_base.TestCase): self.context, instance_uuid=instance_uuid) name = driver_utils.get_ramdisk_logs_file_name(node2) expected_name = ('1be26c0b-03f2-4d2e-ae87-c02d7f33c123_' + - instance_uuid + '_2000-01-01-00:00:00.tar.gz') + instance_uuid + '_2000-01-01-00-00-00.tar.gz') self.assertEqual(expected_name, name) @mock.patch.object(driver_utils, 'store_ramdisk_logs', autospec=True) diff --git a/releasenotes/notes/change-ramdisk-log-filename-142b10d0b02a5ca6.yaml b/releasenotes/notes/change-ramdisk-log-filename-142b10d0b02a5ca6.yaml new file mode 100644 index 0000000000..9f14507dea --- /dev/null +++ b/releasenotes/notes/change-ramdisk-log-filename-142b10d0b02a5ca6.yaml @@ -0,0 +1,13 @@ +--- +upgrade: + - | + Changes timestamp part of ramdisk log filename by replacing + colon with dash. The ``tar`` command does not handle colon + properly, and untar of the file with colon in filename will + fail. +fixes: + - | + Changes timestamp part of ramdisk log filename by replacing + colon with dash. The ``tar`` command does not handle colon + properly, and untar of the file with colon in filename will + fail.