Skip to content

Commit 3e52a32

Browse files
committed
Fix cgroup.events error when cgroup is gone before reading events
If cgroup is gone before reading the cgroup.events file then it will return an error. Treat errors as unpopulated to account for it.
1 parent f2cd92f commit 3e52a32

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

src/runc/container.rs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,15 @@ impl CgroupEventNotifier {
2828

2929
fn populated(&mut self) -> Result<bool> {
3030
let file = self.file.get_mut();
31-
file.seek(std::io::SeekFrom::Start(0))
32-
.context("Cannot seek to start")?;
31+
let Ok(_) = file.seek(std::io::SeekFrom::Start(0)) else {
32+
return Ok(false);
33+
};
3334
for line in BufReader::new(file).lines() {
34-
let line = line.context("Cannot read line")?;
35+
let Ok(line) = line else {
36+
// IO errors on cgroup.events file indicate that the cgroup has been deleted, so
37+
// it is no longer populated.
38+
return Ok(false);
39+
};
3540
if line.starts_with("populated ") {
3641
return Ok(line.ends_with('1'));
3742
}

0 commit comments

Comments
 (0)