-
Notifications
You must be signed in to change notification settings - Fork 351
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix : fix gid duplication, additional_gids etc not getting used in exec #3018
Conversation
Signed-off-by: Yashodhan Joshi <[email protected]>
Signed-off-by: Yashodhan Joshi <[email protected]>
let mut env_exists = false; | ||
let mut env: Vec<String> = self | ||
.env | ||
.iter() | ||
.map(|(k, v)| { | ||
if k == "PATH" { | ||
env_exists = true; | ||
} | ||
format!("{k}={v}") | ||
}) | ||
.collect(); | ||
// It is not possible in normal flow that path is None. The original container | ||
// creation would have failed if path was absent. However we use Option | ||
// just as a caution, and if neither exec cmd not original spec has PATH, | ||
// the container creation will fail later which is ok | ||
if let Some(p) = path { | ||
if !env_exists { | ||
env.push(p); | ||
} | ||
} | ||
env |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- If there is a more semantic way, let me know, these multiple checks are not particularly idiomatic.
- If there are no envs at all (self.env is empty) should we simply clone from the original container? I feel that is what the user would expect.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@YJDoc2 rename env_exists
to path_exists
There are a couple of other fixes needed in exec impl as well, so probably split this PR into another one. duplicate gid is pretty small in scope, so not mixing it with exec changes. |
Opening another PR to split this into two. |
This PR does following fixes:
PATH
from original container in case not provided to exec : exec allows supplying env vars, but by default it does not set any. This causes issue when running exec directly via youki, as it would error withPATH is not set
. Given that we are exec-ing into an existing container, the expectation would be the same env would be applied, or atleast the path would be taken from it. I guess any higher runtime (docker/podman) automatically sets envs from original container, but I have injected path if missing.I want to also add tests for these, but wanted to get a review on the changes before that.