Remove dangling symlinks after node log removal
Dangling symlinks caused snapshots to generate without part of logs. The symlinks were a leftover after deleteing logs from deleted nodes. Existence of log folders was checked using os.path.exists function, it was changed to os.path.lexists, which returns True for broken symlinks. Change-Id: I446df0595ba668800e89f378ab08bd33cec4fb56 Closes-Bug: #1494838
This commit is contained in:
parent
5aed5a7e96
commit
2a327bd01e
@ -86,7 +86,7 @@ class TestNodeLogsUtils(BaseTestCase):
|
||||
logs_utils.delete_node_logs(node, prefix)
|
||||
|
||||
self.assertTrue(
|
||||
all(not os.path.exists(path) for path in [link, folder, file_]))
|
||||
all(not os.path.lexists(path) for path in [link, folder, file_]))
|
||||
|
||||
@mock.patch('os.path.islink', side_effect=OSError)
|
||||
def test_delete_node_no_existing_logs(self, _):
|
||||
|
@ -110,6 +110,6 @@ def delete_node_logs(node, prefix=settings.SYSLOG_DIR):
|
||||
logger.debug("Deleting logs for removed environment's nodes")
|
||||
|
||||
for log_path in log_paths:
|
||||
if os.path.exists(log_path):
|
||||
if os.path.lexists(log_path):
|
||||
logger.debug('delete_node_logs log_path="%s"', log_path)
|
||||
remove_silently(log_path)
|
||||
|
Loading…
Reference in New Issue
Block a user