thin-edge / thin-edge.io

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

Software update logs don't give any error information if the software type doesn't have a corresponding plugin #3057

Closed jarhodes314 closed 1 month ago

jarhodes314 commented 2 months ago

Describe the bug When installing an unknown software type, the logs just show the operation as failed without any insight as to why


==================================================================
Triggered software_update workflow
==================================================================

topic:     te/device/main///cmd/software_update/c8y-mapper-11670838
operation: software_update
cmd_id:    c8y-mapper-11670838
time:      2024-08-07T16:37:48.342185125Z

==================================================================

----------------------[ software_update @ init | time=2024-08-07T16:37:48.347497973Z ]----------------------

State:    {"logPath":"/var/log/tedge/agent/workflow-software_update-c8y-mapper-11670838.log","status":"init","updateList":[{"modules":[{"action":"install","name":"test-zip","url":"http://127.0.0.1:8001/c8y/inventory/binaries/11672113","version":"0.0.1"}],"type":"zip"}]}

Action:   move to scheduled state

=> moving to software_update @ scheduled

----------------------[ software_update @ scheduled | time=2024-08-07T16:37:48.372301529Z ]----------------------

State:    {"logPath":"/var/log/tedge/agent/workflow-software_update-c8y-mapper-11670838.log","status":"scheduled","updateList":[{"modules":[{"action":"install","name":"test-zip","url":"http://127.0.0.1:8001/c8y/inventory/binaries/11672113","version":"0.0.1"}],"type":"zip"}]}

Action:   builtin

----------------------[ software_update @ executing | time=2024-08-07T16:37:48.520805017Z ]----------------------

State:    {"logPath":"/var/log/tedge/agent/workflow-software_update-c8y-mapper-11670838.log","status":"executing","updateList":[{"modules":[{"action":"install","name":"test-zip","url":"http://127.0.0.1:8001/c8y/inventory/binaries/11672113","version":"0.0.1"}],"type":"zip"}]}

Action:   builtin

----------------------[ software_update @ failed | time=2024-08-07T16:37:48.538945166Z ]----------------------

State:    {"failures":[{"modules":[],"type":"zip"}],"logPath":"/var/log/tedge/agent/workflow-software_update-c8y-mapper-11670838.log","reason":"1 error, see device log file /var/log/tedge/agent/workflow-software_update-c8y-mapper-11670838.log","status":"failed","updateList":[{"modules":[{"action":"install","name":"test-zip","url":"http://127.0.0.1:8001/c8y/inventory/binaries/11672113","version":"0.0.1"}],"type":"zip"}]}

Action:   wait for the requester to finalize the command

To Reproduce

  1. Upload a file to the software repository and specify the software type as something the device doesn't have a plugin installed for (e.g. "zip").
  2. Attempt to install the software package on the thin-edge device and see the operation fail
  3. Look at the operation log uploaded following the failure and observe the lack of useful failure information.

Expected behavior The log should specify that the software type isn't recognised.

Environment (please complete the following information):

gligorisaev commented 2 months ago

@jarhodes314 is this a bug?, because I cannot find anywhere that this log specification is required, if not than I think it should be improvement

jarhodes314 commented 2 months ago

@gligorisaev the fix for this issue should do two things when trying to install a package with an unknown software type:

  1. It will log an error message in the software update log
  2. If there is only one error, the failure reason field in Cumulocity will show the Rust error message (as well as telling people to consult the log file for more information), rather than just saying "1 error". Therefore, it should be easy to distinguish between e.g. authentication errors due to incorrect setup with a custom domain and software type for which no plugin is registered without needing to look at the logfile
gligorisaev commented 2 months ago

I am confirming it is working as described