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
This commit is contained in:
@@ -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)
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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.
|
||||
Reference in New Issue
Block a user