fix: cleanup temp log artefacts created for log_upload#4141
fix: cleanup temp log artefacts created for log_upload#4141albinsuresh wants to merge 2 commits intothin-edge:mainfrom
Conversation
Robot Results
Failed Tests
|
Codecov Report❌ Patch coverage is 📢 Thoughts on this report? Let us know! 🚀 New features to boost your workflow:
|
rina23q
left a comment
There was a problem hiding this comment.
Approved. Confirmed it fixed the reported issue.
| println!("{}", line); | ||
| } | ||
|
|
||
| std::fs::remove_file(log_path)?; |
There was a problem hiding this comment.
You can ignore this. What I was thinking here:
If we use tempfile instead of regular file creation for the temporary file, we probably don't need to have this remove_file(). However, then the return type of FileLogPlugin::get() and the actual function new_read_logs() would need to be changed to NamedTempFile. Doable, but not sure if it's worth it.
Bravo555
left a comment
There was a problem hiding this comment.
NOTE: The same issue happens with config snapshot operation
When the same check is applied to config snapshot test:
diff --git a/tests/RobotFramework/tests/cumulocity/configuration/configuration_with_file_transfer_https.robot b/tests/RobotFramework/tests/cumulocity/configuration/configuration_with_file_transfer_https.robot
index 824c5536c5..a8c08e0de6 100644
--- a/tests/RobotFramework/tests/cumulocity/configuration/configuration_with_file_transfer_https.robot
+++ b/tests/RobotFramework/tests/cumulocity/configuration/configuration_with_file_transfer_https.robot
@@ -54,6 +54,11 @@ File Transfer Service is accessible over HTTPS from child device
Configuration snapshots are uploaded to File Transfer Service via HTTPS
Get Configuration Should Succeed device=${CHILD_SN} external_id=${PARENT_SN}:device:${CHILD_SN}
+ # Validate that all temporary files created for the log upload operation are cleaned up
+ ThinEdgeIO.Set Device Context ${FTS_SN}
+ Execute Command ls /tmp/CONFIG1* exp_exit_code=2
+ Execute Command ls /var/tedge/file-transfer/${PARENT_SN}:device:${CHILD_SN}/config_snapshot/CONFIG1* exp_exit_code=2
+
Configuration snapshots are uploaded to File Transfer Service via HTTPS with client certificate
Enable Certificate Authentication for File Transfer Service
Get Configuration Should Succeed device=${CHILD_SN} external_id=${PARENT_SN}:device:${CHILD_SN}
It fails:
`ls /var/tedge/file-transfer/TS...` returned an unexpected exit code
stdout:
/var/tedge/file-transfer/TST_hoard_massive_carrier:device:TST_detour_smart_gang/config_snapshot/CONFIG1-c8y-mapper-54216380
stderr:
I'd say since this is the same issue, it should should also be fixed in this PR.
Proposed changes
Cleanup the following temp files created during the
log_uploadoperation handling:fileplugin combining all target filesThe
agentwas already deleting the tmp file that it creates after applying the filters like line count and search text.Types of changes
Paste Link to the issue
#4139
Checklist
just prepare-devonce)just formatas mentioned in CODING_GUIDELINESjust checkas mentioned in CODING_GUIDELINESFurther comments