Skip to content

fix(3207, 3209) Difference between the exec command in runc and youki#3210

Open
tommady wants to merge 63 commits intoyouki-dev:mainfrom
tommady:close-issue-3207
Open

fix(3207, 3209) Difference between the exec command in runc and youki#3210
tommady wants to merge 63 commits intoyouki-dev:mainfrom
tommady:close-issue-3207

Conversation

@tommady
Copy link
Collaborator

@tommady tommady commented Jul 29, 2025

Description

Type of Change

  • Bug fix (non-breaking change that fixes an issue)
  • New feature (non-breaking change that adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update
  • Refactoring (no functional changes)
  • Performance improvement
  • Test updates
  • CI/CD related changes
  • Other (please describe):

Testing

  • Added new unit tests
  • Added new integration tests
  • Ran existing test suite
  • Tested manually (please provide steps)

Related Issues

Fixes #3207 #3209

Additional Context

dependabot bot and others added 14 commits August 11, 2025 20:48
Bumps the patch group with 4 updates: [libc](https://github.com/rust-lang/libc), [clap](https://github.com/clap-rs/clap), [serde_json](https://github.com/serde-rs/json) and [clap_complete](https://github.com/clap-rs/clap).


Updates `libc` from 0.2.174 to 0.2.175
- [Release notes](https://github.com/rust-lang/libc/releases)
- [Changelog](https://github.com/rust-lang/libc/blob/0.2.175/CHANGELOG.md)
- [Commits](rust-lang/libc@0.2.174...0.2.175)

Updates `clap` from 4.5.4 to 4.5.13
- [Release notes](https://github.com/clap-rs/clap/releases)
- [Changelog](https://github.com/clap-rs/clap/blob/master/CHANGELOG.md)
- [Commits](clap-rs/clap@clap_complete-v4.5.4...clap_complete-v4.5.13)

Updates `serde_json` from 1.0.141 to 1.0.142
- [Release notes](https://github.com/serde-rs/json/releases)
- [Commits](serde-rs/json@v1.0.141...v1.0.142)

Updates `clap_complete` from 4.5.1 to 4.5.13
- [Release notes](https://github.com/clap-rs/clap/releases)
- [Changelog](https://github.com/clap-rs/clap/blob/master/CHANGELOG.md)
- [Commits](clap-rs/clap@clap_complete-v4.5.1...clap_complete-v4.5.13)

---
updated-dependencies:
- dependency-name: libc
  dependency-version: 0.2.175
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: patch
- dependency-name: clap
  dependency-version: 4.5.13
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: patch
- dependency-name: serde_json
  dependency-version: 1.0.142
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: patch
- dependency-name: clap_complete
  dependency-version: 4.5.13
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Bumps the patch group with 3 updates: [oci-spec](https://github.com/youki-dev/oci-spec-rs), [thiserror](https://github.com/dtolnay/thiserror) and [anyhow](https://github.com/dtolnay/anyhow).


Updates `oci-spec` from 0.8.1 to 0.8.2
- [Changelog](https://github.com/youki-dev/oci-spec-rs/blob/main/release.md)
- [Commits](youki-dev/oci-spec-rs@v0.8.1...v0.8.2)

Updates `thiserror` from 2.0.12 to 2.0.14
- [Release notes](https://github.com/dtolnay/thiserror/releases)
- [Commits](dtolnay/thiserror@2.0.12...2.0.14)

Updates `anyhow` from 1.0.98 to 1.0.99
- [Release notes](https://github.com/dtolnay/anyhow/releases)
- [Commits](dtolnay/anyhow@1.0.98...1.0.99)

---
updated-dependencies:
- dependency-name: oci-spec
  dependency-version: 0.8.2
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: patch
- dependency-name: thiserror
  dependency-version: 2.0.14
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: patch
- dependency-name: anyhow
  dependency-version: 1.0.99
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Signed-off-by: tommady <tommady@users.noreply.github.com>
Signed-off-by: tommady <tommady@users.noreply.github.com>
…Option of vector of string

Signed-off-by: tommady <tommady@users.noreply.github.com>
Signed-off-by: tommady <tommady@users.noreply.github.com>
…ux yet

Signed-off-by: tommady <tommady@users.noreply.github.com>
Signed-off-by: tommady <tommady@users.noreply.github.com>
Signed-off-by: tommady <tommady@users.noreply.github.com>
Signed-off-by: tommady <tommady@users.noreply.github.com>
Signed-off-by: tommady <tommady@users.noreply.github.com>
tommady and others added 14 commits August 17, 2025 11:26
Signed-off-by: tommady <tommady@users.noreply.github.com>
Bumps the patch group with 1 update: [thiserror](https://github.com/dtolnay/thiserror).


Updates `thiserror` from 2.0.14 to 2.0.15
- [Release notes](https://github.com/dtolnay/thiserror/releases)
- [Commits](dtolnay/thiserror@2.0.14...2.0.15)

---
updated-dependencies:
- dependency-name: thiserror
  dependency-version: 2.0.15
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Bumps the patch group with 1 update: [serde_json](https://github.com/serde-rs/json).


Updates `serde_json` from 1.0.142 to 1.0.143
- [Release notes](https://github.com/serde-rs/json/releases)
- [Commits](serde-rs/json@v1.0.142...v1.0.143)

---
updated-dependencies:
- dependency-name: serde_json
  dependency-version: 1.0.143
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Signed-off-by: tommady <tommady@users.noreply.github.com>
Bumps the patch group with 1 update: [thiserror](https://github.com/dtolnay/thiserror).


Updates `thiserror` from 2.0.15 to 2.0.16
- [Release notes](https://github.com/dtolnay/thiserror/releases)
- [Commits](dtolnay/thiserror@2.0.15...2.0.16)

---
updated-dependencies:
- dependency-name: thiserror
  dependency-version: 2.0.16
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Signed-off-by: tommady <tommady@users.noreply.github.com>
Bumps the patch group with 1 update: [regex](https://github.com/rust-lang/regex).


Updates `regex` from 1.11.1 to 1.11.2
- [Release notes](https://github.com/rust-lang/regex/releases)
- [Changelog](https://github.com/rust-lang/regex/blob/master/CHANGELOG.md)
- [Commits](rust-lang/regex@1.11.1...1.11.2)

---
updated-dependencies:
- dependency-name: regex
  dependency-version: 1.11.2
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Bumps the patch group with 1 update: [tracing-subscriber](https://github.com/tokio-rs/tracing).


Updates `tracing-subscriber` from 0.3.19 to 0.3.20
- [Release notes](https://github.com/tokio-rs/tracing/releases)
- [Commits](tokio-rs/tracing@tracing-subscriber-0.3.19...tracing-subscriber-0.3.20)

---
updated-dependencies:
- dependency-name: tracing-subscriber
  dependency-version: 0.3.20
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Copy link
Member

@saku3 saku3 left a comment

Choose a reason for hiding this comment

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

I haven’t been able to review everything yet, but I did check the cgroup-related parts.

I’m not sure whether the deletion logic works correctly when a sub-cgroup is created.

$ youki  run -b tutorial container

another terminal

$ youki exec container sh -euc "mkdir /sys/fs/cgroup/foobar && echo 1 > /sys/fs/cgroup/foobar/cgroup.procs && grep -w foobar /proc/1/cgroup"

the original terminal

$ exit
ERROR libcontainer::container::container_delete: failed to remove cgroup due to: V2(WrappedIo(Other { err: Custom { kind: TimedOut, error: "could not delete" }, path: "/sys/fs/cgroup/:youki:container" })) cgroup_path=":youki:container"
ERROR youki: error in executing command: io error: at /sys/fs/cgroup/:youki:container: could not delete

Caused by:
    at /sys/fs/cgroup/:youki:container: could not delete
run failed : io error: at /sys/fs/cgroup/:youki:container: could not delete

@@ -0,0 +1,64 @@
use anyhow::anyhow;
Copy link
Member

Choose a reason for hiding this comment

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

Ideally, the following test cases should exist.

  • Now move init to a subcgroup, and check it was moved.
youki exec a sh -euc "mkdir /sys/fs/cgroup/foobar && echo 1 > /sys/fs/cgroup/foobar/cgroup.procs && grep -w foobar /proc/1/cgroup"
  • The init process is now in "/foo", but an exec process can still join "/" because we haven't enabled any domain controller yet.
 youki exec a grep '^0::/$' /proc/self/cgroup
  • Turn on a domain controller (memory).
 youki exec a sh -euc 'echo $$ > /sys/fs/cgroup/foobar/cgroup.procs; echo +memory > /sys/fs/cgroup/cgroup.subtree_control'
  • An exec process can no longer join "/" after turning on a domain controller. Check that cgroup v2 fallback to init cgroup works.
    • This command is expected to succeed.
 youki exec a sh -euc "cat /proc/self/cgroup && grep '^0::/foobar$' /proc/self/cgroup"
  • Check that --cgroup / disables the init cgroup fallback.
    • This command is expected to fail.
youki exec --cgroup / a true
  • Check that explicit --cgroup foobar works.
youki exec --cgroup foobar a grep '^0::/foobar$' /proc/self/cgroup
  • Check all processes is in foobar (this check is redundant).
youki exec --cgroup foobar a sh -euc '! grep -vwH foobar /proc/*/cgroup'
  • Add a second subcgroup, check we're in it.
youki exec --cgroup foobar a mkdir /sys/fs/cgroup/second
youki exec --cgroup second a grep -w second /proc/self/cgroup

@tommady tommady self-assigned this Dec 20, 2025
Signed-off-by: tommady <tommady@users.noreply.github.com>
Signed-off-by: tommady <tommady@users.noreply.github.com>
Signed-off-by: tommady <tommady@users.noreply.github.com>
Signed-off-by: tommady <tommady@users.noreply.github.com>
@tommady tommady marked this pull request as draft January 6, 2026 11:20
@tommady
Copy link
Collaborator Author

tommady commented Jan 6, 2026

The changes in #3347 will help address and enhance the testcase requested by saku3.

Just a memo for myself — turning this PR back to draft.

@saku3
Copy link
Member

saku3 commented Jan 31, 2026

@tommady
I haven’t had much time to review this PR recently — sorry about that.

For this PR, if we can’t move it forward until issue #3347 is resolved, I think we could proceed by leaving TODO comments (or create sub-issue) for the parts related to #3347 for now.

What approach would be easiest for you to proceed?

@tommady
Copy link
Collaborator Author

tommady commented Feb 2, 2026

@tommady I haven’t had much time to review this PR recently — sorry about that.

For this PR, if we can’t move it forward until issue #3347 is resolved, I think we could proceed by leaving TODO comments (or create sub-issue) for the parts related to #3347 for now.

What approach would be easiest for you to proceed?

Thanks for the suggestion!

From my point of view, this PR is ready for review.
Aside from the parts related to issue #3347, there was also an earlier comment from you:
#3210 (comment)

Because of that, some of the cgroup tests can’t be implemented right now.

So yes, please review it when you have time 🙂

Signed-off-by: tommady <tommady@users.noreply.github.com>
Signed-off-by: tommady <tommady@users.noreply.github.com>
@tommady tommady marked this pull request as ready for review February 2, 2026 05:58
@saku3
Copy link
Member

saku3 commented Feb 2, 2026

Thank! I’ll review it this week.

Copy link
Member

@saku3 saku3 left a comment

Choose a reason for hiding this comment

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

I've left a few comments.
Everything else looks good to me.
Could you please take a look when you have a chance?
Thanks for the solid work on this!

fn get_no_new_privileges(&self, spec: &Spec) -> Option<bool> {
self.no_new_privs
.filter(|&is_set| is_set)
.or_else(|| spec.process().clone().and_then(|p| p.no_new_privileges()))
Copy link
Member

Choose a reason for hiding this comment

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

It looks like we can avoid using clone().

Suggested change
.or_else(|| spec.process().clone().and_then(|p| p.no_new_privileges()))
.or_else(|| spec.process().as_ref().and_then(|p| p.no_new_privileges()))


let id2 = id.clone();
let dir2 = dir.to_path_buf();
std::thread::spawn(move || {
Copy link
Member

Choose a reason for hiding this comment

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

This means we want to resume the paused container at the end, right?

This might be prone to flakiness.
Would you consider using scopeguard::defer!?

Copy link
Collaborator Author

@tommady tommady Feb 7, 2026

Choose a reason for hiding this comment

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

scopeguard was removed earlier (see commit below), and in this case it would also resume the container too late since it only runs at scope exit. I’ll use an mpsc channel instead to explicitly synchronize the resume during exec --ignore-paused. Thanks for the suggestion.

123b51a

sub_cgroup_path
)));
}
final_cgroups_path = potential_path;
Copy link
Member

Choose a reason for hiding this comment

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

Shouldn’t the final value we want to set be normalized?

Suggested change
final_cgroups_path = potential_path;
final_cgroups_path = normalized;

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

good catcha!

Signed-off-by: tommady <tommady@users.noreply.github.com>
Signed-off-by: tommady <tommady@users.noreply.github.com>
Signed-off-by: tommady <tommady@users.noreply.github.com>
Signed-off-by: tommady <tommady@users.noreply.github.com>
@tommady tommady requested a review from saku3 February 8, 2026 02:54
Signed-off-by: tommady <tommady@users.noreply.github.com>
Signed-off-by: tommady <tommady@users.noreply.github.com>
Signed-off-by: tommady <tommady@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Difference between the exec command in runc and youki

3 participants

Comments