The task_dir successfully cleans when the file is absent
Signed-off-by: fengwei0328 <feng.wei8@zte.com.cn>
This commit is contained in:
parent
7051e312f5
commit
1e17e1495e
|
|
@ -108,7 +108,7 @@ impl Shim for Service {
|
|||
let namespace = self.namespace.as_str();
|
||||
let bundle = current_dir().map_err(io_error!(e, "get current dir"))?;
|
||||
let opts = read_options(&bundle).await?;
|
||||
let runtime = read_runtime(&bundle).await?;
|
||||
let runtime = read_runtime(&bundle).await.unwrap_or_default();
|
||||
|
||||
let runc = create_runc(
|
||||
&runtime,
|
||||
|
|
@ -117,7 +117,9 @@ impl Shim for Service {
|
|||
&opts,
|
||||
Some(Arc::new(ShimExecutor::default())),
|
||||
)?;
|
||||
let pid = read_pid_from_file(&bundle.join(INIT_PID_FILE)).await?;
|
||||
let pid = read_pid_from_file(&bundle.join(INIT_PID_FILE))
|
||||
.await
|
||||
.unwrap_or_default();
|
||||
|
||||
runc.delete(&self.id, Some(&DeleteOpts { force: true }))
|
||||
.await
|
||||
|
|
|
|||
|
|
@ -99,8 +99,13 @@ pub async fn read_spec(bundle: impl AsRef<Path>) -> Result<Spec> {
|
|||
serde_json::from_str::<Spec>(content.as_str()).map_err(other_error!("read spec"))
|
||||
}
|
||||
|
||||
// read_options reads the option information from the path.
|
||||
// When the file does not exist, read_options returns nil without an error.
|
||||
pub async fn read_options(bundle: impl AsRef<Path>) -> Result<Options> {
|
||||
let path = bundle.as_ref().join(OPTIONS_FILE_NAME);
|
||||
if !path.exists() {
|
||||
return Ok(Options::default());
|
||||
}
|
||||
let opts_str = read_file_to_str(path).await?;
|
||||
let opts =
|
||||
serde_json::from_str::<JsonOptions>(&opts_str).map_err(other_error!("read options"))?;
|
||||
|
|
|
|||
Loading…
Reference in New Issue