thin-edge / thin-edge.io

The open edge framework for lightweight IoT devices
https://thin-edge.io
Apache License 2.0
219 stars 54 forks source link

log file request does not return fixed log file path if the file's last modified date does not match date filter #2966

Closed reubenmiller closed 2 months ago

reubenmiller commented 3 months ago

Is your feature improvement request related to a problem? Please describe.

Log file request operations have some unexpected behaviour (from the user's perspective) when using fixed paths.

For instance, when given the following tedge-log-plugin.toml configuration:

file: /etc/tedge/plugins/tedge-log-plugin.toml

files = [
    { type = "tedge-bridge-monitor", path = '/var/log/tedge-bridge-monitor/tedge-bridge-monitor.log' },
]

When the user requests a log file for the tedge-bridge-monitor type, the user is met with the following failureReason in the operation if the file has not been modified within the given dateFrom/dateTo range (of the operation request):

Failed to initiate log file upload: No logs found for log type "tedge-bridge-monitor"

The above error message is unexpected from the user's perspective because they have given an explicit path to a log file, and just want to see the contents, however the result is dependent on the last modified timestamp of the file (which the user has no idea what it would be), where the failureReason suggests that the file does not exist.

I understand that the limitation exists what since the log request handler can't know the contents of the file to apply dateFrom/dateTo range filtering from the contents of the file, however applying the date range filtering on a single file is very unexpected, and is annoying for users, as they then have to change the dateFrom/dateTo range to some very wide range (e.g. 1970 -> now) if they have no idea when the file was last written to.

Describe the solution you'd like

For file based log requests:

Describe alternatives you've considered

Alternatively, the error message could be changed to something indicates that the a time range was applied:

Failed to initiate log file upload: No logs found for log type "tedge-bridge-monitor" for the given time range

Additional context

gligorisaev commented 2 months ago

The review was done in the PR: https://github.com/thin-edge/thin-edge.io/pull/2991