thin-edge.io icon indicating copy to clipboard operation
thin-edge.io copied to clipboard

Restart operation returns IO error when /run/tedge_agent directory is missing

Open rina23q opened this issue 2 years ago • 2 comments

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:

  1. After the agent starts, execute a restart operation. This should be successful.
  2. After the step 1, the device should keep /run/tedge_agent directory. Delete the directory.
  3. 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]

rina23q avatar Mar 03 '22 19:03 rina23q

I tried it on ubuntu there is no issue I could restart the tedge_agent successfully.

PradeepKiruvale avatar Mar 04 '22 05:03 PradeepKiruvale

@PradeepKiruvale Did you delete the directory /run/tedge_agent while tedge_agent is running?

rina23q avatar Mar 04 '22 08:03 rina23q

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.

rina23q avatar Nov 08 '22 11:11 rina23q

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

rina23q avatar Nov 10 '22 13:11 rina23q

Tested and bug is NOT reproducable

gligorisaev avatar Nov 15 '22 06:11 gligorisaev