mirror of
https://github.com/kata-containers/kata-containers.git
synced 2025-09-18 23:39:30 +00:00
agent: Add CreateContainer support for pre-pulled bundle
- Add a check in setup_bundle to see if the bundle already exists and if it does then skip the setup. Fixes: #2617 Co-authored-by: Dave Hay <david_hay@uk.ibm.com> Signed-off-by: stevenhorsman <steven@uk.ibm.com>
This commit is contained in:
@@ -1653,20 +1653,27 @@ fn setup_bundle(cid: &str, spec: &mut Spec) -> Result<PathBuf> {
|
|||||||
let config_path = bundle_path.join("config.json");
|
let config_path = bundle_path.join("config.json");
|
||||||
let rootfs_path = bundle_path.join("rootfs");
|
let rootfs_path = bundle_path.join("rootfs");
|
||||||
|
|
||||||
fs::create_dir_all(&rootfs_path)?;
|
let rootfs_exists = Path::new(&rootfs_path).exists();
|
||||||
baremount(
|
info!(
|
||||||
&spec_root.path,
|
sl!(),
|
||||||
rootfs_path.to_str().unwrap(),
|
"The rootfs_path is {:?} and exists: {}", rootfs_path, rootfs_exists
|
||||||
"bind",
|
);
|
||||||
MsFlags::MS_BIND,
|
|
||||||
"",
|
if !rootfs_exists {
|
||||||
&sl!(),
|
fs::create_dir_all(&rootfs_path)?;
|
||||||
)?;
|
baremount(
|
||||||
|
&spec_root.path,
|
||||||
|
rootfs_path.to_str().unwrap(),
|
||||||
|
"bind",
|
||||||
|
MsFlags::MS_BIND,
|
||||||
|
"",
|
||||||
|
&sl!(),
|
||||||
|
)?;
|
||||||
|
}
|
||||||
spec.root = Some(Root {
|
spec.root = Some(Root {
|
||||||
path: rootfs_path.to_str().unwrap().to_owned(),
|
path: rootfs_path.to_str().unwrap().to_owned(),
|
||||||
readonly: spec_root.readonly,
|
readonly: spec_root.readonly,
|
||||||
});
|
});
|
||||||
|
|
||||||
let _ = spec.save(config_path.to_str().unwrap());
|
let _ = spec.save(config_path.to_str().unwrap());
|
||||||
|
|
||||||
let olddir = unistd::getcwd().context("cannot getcwd")?;
|
let olddir = unistd::getcwd().context("cannot getcwd")?;
|
||||||
|
Reference in New Issue
Block a user