thin-edge.io
thin-edge.io copied to clipboard
Restart operation returns IO error when /run/tedge_agent directory is missing
Describe the bug
tedge_agent
returns an IO error when /run/tedge_agent
directory is not found. The operation fails.
2022-03-03T18:49:03.63846719Z ERROR sm-agent: tedge_agent::agent: No such file or directory (os error 2)
To Reproduce For Raspberry Pi:
- After the agent starts, execute a restart operation. This should be successful.
- After the step 1, the device should keep
/run/tedge_agent
directory. Delete the directory. - Execute another restart operation. This operation returns error immediately due to the directory is missing. (the error message is not clear though).
For Alpine docker:
In any case, it always returns the IO error. The /run/tedge_agent
directory is never created by tedge_agent
.
Expected behavior
tedge_agent
creates /run/tedge_agent
directory when the device doesn't have that directory.
Environment (please complete the following information):
- thin-edge.io version [0.5.4]
I tried it on ubuntu there is no issue I could restart the tedge_agent successfully.
@PradeepKiruvale
Did you delete the directory /run/tedge_agent
while tedge_agent
is running?
I did a little further investigation.
In tedge-agent.service
, we have this line.
RuntimeDirectory=tedge_agent
This creates /run/tedge_agent
directory while the service is running. The current implementation of "restart" is depending on the directory.
In restart_operation_handler.rs
,
const SLASH_RUN_PATH_TEDGE_AGENT_RESTART: &str = "tedge_agent/tedge_agent_restart";
If /run/tedge_agent
doesn't exist, it will cause IO error directory not found as I reported initially.
This means, if user run tedge_agent
without systemd service, restart operation will fail. So as my initial report on Alpine docker.
So, I changed the temporary file location from /run/tedge_agent
to /tmp
. It should not change the end user experience.
Resolved by #1575 Build is #927
Tested and bug is NOT reproducable