mirror of
https://github.com/kata-containers/kata-containers.git
synced 2025-06-28 00:07:16 +00:00
Merge pull request #8023 from cmaf/runtime-rs-ch-pause-resume
runtime-rs: Update status for pause and resume
This commit is contained in:
commit
83e731328f
@ -366,28 +366,42 @@ impl Container {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub async fn pause(&self) -> Result<()> {
|
pub async fn pause(&self) -> Result<()> {
|
||||||
let inner = self.inner.read().await;
|
let mut inner = self.inner.write().await;
|
||||||
if inner.init_process.get_status().await == ProcessStatus::Paused {
|
let status = inner.init_process.get_status().await;
|
||||||
warn!(self.logger, "container is paused no need to pause");
|
if status != ProcessStatus::Running {
|
||||||
|
warn!(
|
||||||
|
self.logger,
|
||||||
|
"container is in {:?} state, will not pause", status
|
||||||
|
);
|
||||||
return Ok(());
|
return Ok(());
|
||||||
}
|
}
|
||||||
|
|
||||||
self.agent
|
self.agent
|
||||||
.pause_container(self.container_id.clone().into())
|
.pause_container(self.container_id.clone().into())
|
||||||
.await
|
.await
|
||||||
.context("agent pause container")?;
|
.context("agent pause container")?;
|
||||||
|
inner.set_state(ProcessStatus::Paused).await;
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn resume(&self) -> Result<()> {
|
pub async fn resume(&self) -> Result<()> {
|
||||||
let inner = self.inner.read().await;
|
let mut inner = self.inner.write().await;
|
||||||
if inner.init_process.get_status().await == ProcessStatus::Running {
|
let status = inner.init_process.get_status().await;
|
||||||
warn!(self.logger, "container is running no need to resume");
|
if status != ProcessStatus::Paused {
|
||||||
|
warn!(
|
||||||
|
self.logger,
|
||||||
|
"container is in {:?} state, will not resume", status
|
||||||
|
);
|
||||||
return Ok(());
|
return Ok(());
|
||||||
}
|
}
|
||||||
|
|
||||||
self.agent
|
self.agent
|
||||||
.resume_container(self.container_id.clone().into())
|
.resume_container(self.container_id.clone().into())
|
||||||
.await
|
.await
|
||||||
.context("agent pause container")?;
|
.context("agent pause container")?;
|
||||||
|
inner.set_state(ProcessStatus::Running).await;
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user