Skip to content

cgroups-rs: fix verify_path() logic#159

Merged
Tim-Zhang merged 1 commit intokata-containers:mainfrom
Lu-yq:fix-verify-path
Nov 21, 2025
Merged

cgroups-rs: fix verify_path() logic#159
Tim-Zhang merged 1 commit intokata-containers:mainfrom
Lu-yq:fix-verify-path

Conversation

@Lu-yq
Copy link

@Lu-yq Lu-yq commented Nov 9, 2025

Because the semantics of controller.base has changed, the logic for verify_path should be modified.

Fixes: #158

src/fs/mod.rs Outdated

fn verify_path(&self) -> Result<()> {
if self.get_path().starts_with(self.get_base()) {
if self.get_path().is_absolute() {
Copy link
Member

@justxuewei justxuewei Nov 12, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, this is the common part of cgroupfs. I think we only need to make sure whether the get_path() exists or not.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

image Actually, verify_path() is in front of the cgroupfs directory creation process, so we cannot verify whether get_path() exists prior to its execution.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMHO, there is no relation between the path and the base. According to the current codebase, the path is the mount point, and the base is the mount root. Both of them are read from /proc/self/mountinfo. Without DinD, self.get_path().starts_with(self.get_base()) works coincidentally. The typical root is /, and controllers are under /sys/fs/cgroup. With DinD, a mount namespace might be applied. The mount root differs from container engines and is unpredictable. In your case, it is /docker/{xxxx}. So my idea is that we can remove verify_path() function completely. WDYT?

Copy link
Member

@justxuewei justxuewei Nov 12, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I found that the verify_path was introduced in commit c63dad4. Before commit 4005ad8, the root and base are the same one, see 4005ad8#diff-f058debe54b01b2b04c284d1b5ec01250c4cfce0fd4508222079b87dbec9416eL433-R436. IMHO, verify_path never throws errors previously and is completely useless. Removing it is reasonable to me.

Copy link
Member

@justxuewei justxuewei Nov 12, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Need some input from @lifupan @Tim-Zhang @quanweiZhou

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed with removing it. In version 0.4.0, the mount point behavior differs between Pouch and Docker environments - the former is /, while the latter is /docker/$cid. The behavior of this function is indeed somewhat unpredictable. cc @quanweiZhou

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Need some input from @lifupan @Tim-Zhang @quanweiZhou

From the current information, this validation doesn't seem to serve much purpose and could actually introduce problems. I support removing this validation.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Apologies for the delay. After removing verify_path(), during regression testing of our project, we encountered a sporadic issue where creating cgroups occasionally fails. Once I identify the root cause and find an appropriate fix, I'll update the patch here.

@justxuewei
Copy link
Member

Hey @Lu-yq, how is the progress going? We are going to release a new version soon, the next version might be a couple of months after that. /cc @Tim-Zhang @pmores

@Tim-Zhang
Copy link
Member

Hi @Lu-yq , We got a CI error:

Error: The SoB (DCO) check failed

  293423cd246a91021b2c3fb17ea6dab338df6195    Expected "Lu-yq <443471302@qq.com>", but got "luyongqiang.lyq <luyongqiang.lyq@alibaba-inc.com>".

  What should I do to fix it ?

  All proposed commits should include a Signed-Off-By: <your-email-address> line in their commit message.
  This is most conveniently done by using --signoff (-s) when running git commit.

Please fix it, thanks

remove the verify_path() logic because the
semantics change of controller.base.

Signed-off-by: Lu-yq <443471302@qq.com>
@Lu-yq
Copy link
Author

Lu-yq commented Nov 20, 2025

I have removed the verify_path() now! plz have a look @justxuewei @Tim-Zhang cc @quanweiZhou

Copy link
Member

@justxuewei justxuewei left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lgtm, thanks!

Copy link
Member

@Tim-Zhang Tim-Zhang left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks

@Tim-Zhang Tim-Zhang merged commit cf4c62d into kata-containers:main Nov 21, 2025
6 checks passed
Tim-Zhang added a commit to Tim-Zhang/cgroups-rs that referenced this pull request Nov 21, 2025
Bump major(minor actually) version for incompatible changes in kata-containers#154.

Changelog:
- kata-containers#152
- kata-containers#154
- kata-containers#159

Signed-off-by: Tim Zhang <tim@hyper.sh>
@Tim-Zhang Tim-Zhang mentioned this pull request Nov 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

verify_path() fails when create cgroups controllers in Docker container

4 participants

Comments