mirror of
https://github.com/kata-containers/kata-containers.git
synced 2025-06-28 16:27:50 +00:00
runtime-rs: Enhancement of DirectVolume when using CSI.
We use a matching direct-volume path to determine whether an OCI mount is a DirectVolume. However, we should handle the case where no match is found appropriately. This error will be defined as a non-DirectVolume type when judging the OCI mount but not failed. Fixes: #8619 Signed-off-by: alex.lyn <alex.lyn@antgroup.com>
This commit is contained in:
parent
80d631ee84
commit
aa42f0a03f
@ -3,7 +3,7 @@
|
|||||||
// SPDX-License-Identifier: Apache-2.0
|
// SPDX-License-Identifier: Apache-2.0
|
||||||
//
|
//
|
||||||
|
|
||||||
use anyhow::{Context, Result};
|
use anyhow::{anyhow, Context, Result};
|
||||||
|
|
||||||
use kata_types::mount::{
|
use kata_types::mount::{
|
||||||
get_volume_mount_info, join_path, DirectVolumeMountInfo, KATA_DIRECT_VOLUME_ROOT_PATH,
|
get_volume_mount_info, join_path, DirectVolumeMountInfo, KATA_DIRECT_VOLUME_ROOT_PATH,
|
||||||
@ -28,5 +28,12 @@ pub fn get_direct_volume_path(volume_path: &str) -> Result<String> {
|
|||||||
let volume_full_path =
|
let volume_full_path =
|
||||||
join_path(KATA_DIRECT_VOLUME_ROOT_PATH, volume_path).context("failed to join path.")?;
|
join_path(KATA_DIRECT_VOLUME_ROOT_PATH, volume_path).context("failed to join path.")?;
|
||||||
|
|
||||||
Ok(volume_full_path.display().to_string())
|
if volume_full_path.exists() {
|
||||||
|
Ok(volume_full_path.display().to_string())
|
||||||
|
} else {
|
||||||
|
Err(anyhow!(format!(
|
||||||
|
"direct volume path {:?} Not Found",
|
||||||
|
&volume_full_path
|
||||||
|
)))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user