Use process env for StartContainer hooks when without explicit hook env#3470
Use process env for StartContainer hooks when without explicit hook env#3470bells17 wants to merge 4 commits intoyouki-dev:mainfrom
Conversation
e4671c9 to
f15f234
Compare
df1b2d8 to
49ff36e
Compare
nayuta723
left a comment
There was a problem hiding this comment.
Thank you for your contribution! I've left a few nits. Please take a look when you have a momemnt.
crates/libcontainer/src/hooks.rs
Outdated
| .args(vec![ | ||
| String::from("bash"), | ||
| String::from("-c"), | ||
| String::from("printenv TEST_ENV > /dev/null"), |
There was a problem hiding this comment.
Maybe we should validate the TEST_ENV value here?
crates/libcontainer/src/hooks.rs
Outdated
| let hook = HookBuilder::default() | ||
| .path("bash") | ||
| .args(vec![ | ||
| String::from("bash"), |
There was a problem hiding this comment.
Can you use sh instead of bash?
f0e22cd to
5c58ad5
Compare
|
@nayuta723 Thank you for the review! I've addressed your feedback:
Could you please take another look? |
saku3
left a comment
There was a problem hiding this comment.
Thanks.
Is it possible to add e2e tests?
https://github.com/opencontainers/runc/blob/main/tests/integration/hooks.bats#L44
…ook env Signed-off-by: bells17 <bells171@gmail.com>
Signed-off-by: bells17 <bells171@gmail.com>
Signed-off-by: bells17 <bells171@gmail.com>
Add two integration tests to verify startContainer hook environment variable behavior: - start_container_env_inherit: verifies hooks inherit process.env when no explicit env is set - start_container_env_explicit: verifies hooks use only their explicit env and do not inherit process.env Signed-off-by: bells17 <bells171@gmail.com>
61f2478 to
69160bb
Compare
|
NOTE: Since there were conflicts, I performed a rebase and a force push. |
|
@saku3 I've added the e2e tests. Could you take another look? |
saku3
left a comment
There was a problem hiding this comment.
Thank you for adding the e2e test.
Could you take another look at the status handling here?
From what I tested, the following test should fail, but it passes:
fn get_test_explicit_env() -> Test {
Test::new(
"start_container_env_explicit",
Box::new(|| {
run_hook_env_test(
"false",
vec![],
None,
)
}),
)
}
| } | ||
|
|
||
| pub fn get_start_container_env_tests() -> TestGroup { | ||
| let mut tg = TestGroup::new("start_container_env"); |
There was a problem hiding this comment.
start_container_env sounds a bit too generic. Since this is specifically testing the hook environment, start_container_hook_env_inherit might be clearer.
Description
Fix StartContainer hooks to use the container's process.env when no explicit env is specified in the hook definition, matching runc's behavior.
Type of Change
Testing
Related Issues
Fixes #3380
Additional Context