fix oci.WithImageConfigArgs for windows#2887
fix oci.WithImageConfigArgs for windows#2887crosbymichael merged 3 commits intocontainerd:masterfrom
Conversation
Codecov Report
@@ Coverage Diff @@
## master #2887 +/- ##
==========================================
- Coverage 47.5% 44.19% -3.31%
==========================================
Files 91 101 +10
Lines 8460 10808 +2348
==========================================
+ Hits 4019 4777 +758
- Misses 3717 5297 +1580
- Partials 724 734 +10
Continue to review full report at Codecov.
|
There was a problem hiding this comment.
Should there be a test for config.WorkingDir == "" to default it to C:\ for Windows as it's done from Linux above in L321?
There was a problem hiding this comment.
I thought it make some sense to have "" value, assuming it has meaning "unspecified" to bypass it father and something later will know what exactly it means. In other words I wasn't sure if it is right place to do it. So should I add this test here?
There was a problem hiding this comment.
What do you need to change the existing code? Seems like all that is new is the s.Process.Cwd = config.WorkingDir. Doesn't config.Cmd... expand properly to zero automatically by golang?
There was a problem hiding this comment.
Seems the model is inconsistent already. We should likely be using replaceOrAppendEnvValues everywhere. But at a minimum I think yes we should be appending here too otherwise call order would really matter for env's.
There was a problem hiding this comment.
hmm, when we use replaceOrAppendEnvValues, what should override what? s.Process.Env should override config.Env or opposite config.Env overrides s.Process.Env ? In other words it should be:
s.Process.Env = replaceOrAppendEnvValues(s.Process.Env, config.Env)
or
s.Process.Env = replaceOrAppendEnvValues(config.Env, s.Process.Env)
?
There was a problem hiding this comment.
also should we check if current working directory was already set or override it no matter what?
cwd := config.WorkingDir
if cwd == "" {
cwd = "/"
}
s.Process.Cwd = cwd
or
if s.Process.Cwd != "" {
s.Process.Cwd = config.WorkingDir
}
more specifically, say we have image:
FROM ...
...
WORKDIR "/bin"
then we create container with options:
opts := []oci.SpecOpts{
WithProcessCwd("/app"),
WithImageConfig(image)
}
what should be current working directory for this container "/app" or "/bin"?
There was a problem hiding this comment.
I added following changes:
WithImageConfigArgs will override env,args,cwd of all previous WithXxx calls.
env will be merged using replaceOrAppendEnvValues instead of append.
args,cwd will be just replaced
There was a problem hiding this comment.
Should s.Process.Env be appended to ^ as done for Linux in L313?
There was a problem hiding this comment.
Hard to answer for me actually, as I have arguments "for" and "against". So on one hand it was like this before but on other hand why do we have different behavior for linux and windows? Also why do we have different "merge"/"apply" behaviors, so all other parameters we replace/override, but for env we use "append" behavior, what are use cases to have this exception?
Signed-off-by: Andrey Kolomentsev <[email protected]>
c8b400d to
bfda164
Compare
Signed-off-by: Andrey Kolomentsev <[email protected]>
7f28ff6 to
cb140b8
Compare
Signed-off-by: Andrey Kolomentsev <[email protected]>
|
LGTM from me. @crosbymichael @jterry75 PTAL |
jterry75
left a comment
There was a problem hiding this comment.
LGTM. Appreciate the tests!
|
LGTM |
fix parameters passing for windows when use oci.WithImageConfigArgs