Skip to content

Commit

Permalink
agent: reduce reference count for failed mount
Browse files Browse the repository at this point in the history
The kata agent adds a reference for each storage object before mount
and skip mount again if the storage object is known. We need to
remove the object reference if mount fails.

Fixes: #5364

Signed-off-by: Feng Wang <feng.wang@databricks.com>
  • Loading branch information
fengwang-db authored and bergwolf committed Oct 8, 2022
1 parent 3eb6f58 commit 20c0252
Showing 1 changed file with 14 additions and 10 deletions.
24 changes: 14 additions & 10 deletions src/agent/src/mount.rs
Expand Up @@ -779,16 +779,20 @@ pub async fn add_storages(
}
};

// Todo need to rollback the mounted storage if err met.

if res.is_err() {
error!(
logger,
"add_storages failed, storage: {:?}, error: {:?} ", storage, res
);
}

let mount_point = res?;
let mount_point = match res {
Err(e) => {
error!(
logger,
"add_storages failed, storage: {:?}, error: {:?} ", storage, e
);
let mut sb = sandbox.lock().await;
sb.unset_sandbox_storage(&storage.mount_point)
.map_err(|e| warn!(logger, "fail to unset sandbox storage {:?}", e))
.ok();
return Err(e);
}
Ok(m) => m,
};

if !mount_point.is_empty() {
mount_list.push(mount_point);
Expand Down

0 comments on commit 20c0252

Please sign in to comment.