fix(attach-cgroup): only attach to a cgroup if it is already set up#52
fix(attach-cgroup): only attach to a cgroup if it is already set up#52
Conversation
bba33a1 to
cc81fb0
Compare
cc81fb0 to
8d1f187
Compare
| let path_str = path | ||
| .to_str() | ||
| .ok_or(anyhow!("path is somehow not valid utf-8"))?; | ||
| let subtree = CGroup::open(path_str)?; |
There was a problem hiding this comment.
add .context() here?
| .unwrap_or("/sys/fs/cgroup".to_string()); | ||
| let cgroot = CGroup::open(&cgbase)?; | ||
| let subtree = cgroot.create_child(format!("styrolite-{}", self.identity()?))?; | ||
| let name = format!("styrolite-{}", self.identity()?); |
There was a problem hiding this comment.
Do we want to create this at all?
Why not just try and open whatever cgroup path is given by the caller, regardless of what it is, and attach to it, regardless of whether it has this path segment in it?
Another option is to check if we got the default path of /sys/fs/cgroup and only append the custom path specifier in that case, otherwise take the path that's given and attach.
| path.push(&name); | ||
|
|
||
| if !path.exists() { | ||
| return Ok(()); |
There was a problem hiding this comment.
Do we want to return with no error and no binding if the path doesn't exist? Seems like we should warn here, since we effectively are skipping attach without a warn/error.
There was a problem hiding this comment.
That would be an API change. I don't want to change the API right now.
No description provided.