mirror of
https://github.com/aljazceru/kata-containers.git
synced 2025-12-19 07:14:22 +01:00
runtime-rs: Clean up mount points shared to guest
Fixed issues where shared volumes couldn't umount correctly. The rootfs of each container is cleaned up after the container is killed, except for `NydusRootfs`. `ShareFsRootfs::cleanup()` calls `VirtiofsShareMount::umount_rootfs()` to umount mount points shared to the guest, and umounts the bundle rootfs. Fixes: #5898 Signed-off-by: Xuewei Niu <niuxuewei.nxw@antgroup.com>
This commit is contained in:
@@ -249,6 +249,7 @@ impl ContainerInner {
|
||||
.await?;
|
||||
|
||||
self.clean_volumes().await.context("clean volumes")?;
|
||||
self.clean_rootfs().await.context("clean rootfs")?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
@@ -279,7 +280,7 @@ impl ContainerInner {
|
||||
unhandled.push(Arc::clone(v));
|
||||
warn!(
|
||||
sl!(),
|
||||
"Failed to clean volume {:?}, error = {:?}",
|
||||
"Failed to clean the volume = {:?}, error = {:?}",
|
||||
v.get_volume_mount(),
|
||||
err
|
||||
);
|
||||
@@ -290,4 +291,23 @@ impl ContainerInner {
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
async fn clean_rootfs(&mut self) -> Result<()> {
|
||||
let mut unhandled = Vec::new();
|
||||
for rootfs in self.rootfs.iter() {
|
||||
if let Err(err) = rootfs.cleanup().await {
|
||||
unhandled.push(Arc::clone(rootfs));
|
||||
warn!(
|
||||
sl!(),
|
||||
"Failed to umount rootfs, cid = {:?}, error = {:?}",
|
||||
self.container_id(),
|
||||
err
|
||||
);
|
||||
}
|
||||
}
|
||||
if !unhandled.is_empty() {
|
||||
self.rootfs = unhandled;
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user