Merge branch 'incident/log-file-issues' into 'dev'

Fix log file pathing issues

See merge request crafty-controller/crafty-4!406
This commit is contained in:
Iain Powrie 2022-07-18 21:11:41 +00:00
commit 3d6299ca33
3 changed files with 16 additions and 4 deletions

View File

@ -7,9 +7,10 @@
- Toggle Visible servers on status page ([Merge Request](https://gitlab.com/crafty-controller/crafty-4/-/merge_requests/399))
### Bug fixes
- Fixes stats recording for Oracle hosts ([Merge Request](https://gitlab.com/crafty-controller/crafty-4/-/merge_requests/397))
- Improve the use of the object oriented architecture ([Merge Request](https://gitlab.com/crafty-controller/crafty-4/-/merge_requests/400))
- Improve use of object oriented architecture ([Merge Request](https://gitlab.com/crafty-controller/crafty-4/-/merge_requests/400))
- Fix issue with API Server Instance is not serializable ([Merge Request](https://gitlab.com/crafty-controller/crafty-4/-/merge_requests/401))
- Fix an issue where the motd were not displayed properly one small screens ([Merge Request](https://gitlab.com/crafty-controller/crafty-4/-/merge_requests/402))
- Fix issue where the motd was not displayed properly on small screens ([Merge Request](https://gitlab.com/crafty-controller/crafty-4/-/merge_requests/402))
- Fix log file path issues caused by using relative paths ([Merge Request](https://gitlab.com/crafty-controller/crafty-4/-/merge_requests/406))
### Tweaks
- Remove server.props requirement ([Merge Request](https://gitlab.com/crafty-controller/crafty-4/-/merge_requests/403))
- Add platform & crafty version info to support logs ([Merge Request](https://gitlab.com/crafty-controller/crafty-4/-/merge_requests/405))

View File

@ -2,6 +2,7 @@ import os
import logging
import time
import json
import pathlib
import typing as t
from app.classes.controllers.roles_controller import RolesController
@ -516,7 +517,14 @@ class ServersController(metaclass=Singleton):
continue
log_files = list(
filter(lambda val: val != latest_log_file, os.listdir(logs_path))
filter(
lambda val: val != latest_log_file,
os.listdir(
pathlib.Path(
server["path"], os.path.split(server["log_path"])[0]
)
),
)
)
for log_file in log_files:
log_file_path = os.path.join(logs_path, log_file)

View File

@ -160,7 +160,10 @@ class Controller:
final_path += "_" + server["server_uuid"]
os.mkdir(final_path)
try:
FileHelpers.copy_file(server["log_path"], final_path)
FileHelpers.copy_file(
pathlib.Path(server["path"], server["log_path"]),
final_path,
)
except Exception as e:
logger.warning(f"Failed to copy file with error: {e}")
# Copy crafty logs to archive dir