agent: Handle EINVAL error when umounting container rootfs

Container/Sandbox clean up should not fail if root FS is not mounted.
This PR handles EINVAL errors when umount2 is called.

Fixes: #10166

Signed-off-by: Silenio Quarti <silenio_quarti@ca.ibm.com>
This commit is contained in:
Silenio Quarti 2024-08-15 09:25:37 -04:00
parent 74662a0721
commit 0dd16e6b25

View File

@ -1306,7 +1306,14 @@ impl BaseContainer for LinuxContainer {
.to_string()
.as_str(),
MntFlags::MNT_DETACH,
)?;
)
.or_else(|e| {
if e.ne(&nix::Error::EINVAL) {
return Err(anyhow!(e));
}
warn!(self.logger, "rootfs not mounted");
Ok(())
})?;
fs::remove_dir_all(&self.root)?;
let cgm = self.cgroup_manager.as_mut();