runtime-rs: force shutdown shim process in it can't exit

In some case the call of cleanup from shim to service manager will fail,
and the shim process will continue to running, that will make process leak.

This commit will force shutdown the shim process in case of any errors in
service crate.

Fixes: #5087

Signed-off-by: Bin Liu <bin@hyper.sh>
This commit is contained in:
Bin Liu
2022-09-02 17:36:28 +08:00
parent b5786361e9
commit 86ad832e37
3 changed files with 31 additions and 6 deletions

View File

@@ -155,7 +155,7 @@ impl ServiceManager {
let handler = RuntimeHandlerManager::new(sid, sender)
.await
.context("new runtime handler")?;
handler.cleanup().await?;
handler.cleanup().await.context("runtime handler cleanup")?;
let temp_dir = [KATA_PATH, sid].join("/");
if std::fs::metadata(temp_dir.as_str()).is_ok() {
// try to remove dir and skip the result