-
Notifications
You must be signed in to change notification settings - Fork 18.7k
LCOW: WORKDIR correct handling #34405
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
Conversation
bca1b6f
to
e2c0405
Compare
{"linux", ``, `foo`, `/foo`, ``}, | ||
{"linux", ``, `/foo`, `/foo`, ``}, | ||
{"linux", `/foo`, `bar`, `/foo/bar`, ``}, | ||
{"linux", `/foo`, `/bar`, `/bar`, ``}, |
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.
Since normaliseWorkdirUnix
replaces Windows path separators with Unix, how about tests for that?
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.
Added case {"linux",
\a,
b\c,
/a/b/c, ``},
e2c0405
to
d8b6a7f
Compare
Updated for PS E:\docker\build\lcow> docker run --rm --workdir /bin busybox ls -l sh
-rwxr-xr-x 385 root root 1049592 Aug 4 19:56 sh |
d8b6a7f
to
2c69572
Compare
config.WorkingDir = filepath.FromSlash(config.WorkingDir) // Ensure in platform semantics | ||
if !system.IsAbs(config.WorkingDir) { | ||
wdInvalid := false | ||
if runtime.GOOS == platform { |
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.
Is this a sufficient LCOW check? I think so, at least for now, but maybe system.LCOWSupported
is preferred.
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.
I could be more explicit, but in reality, here it's redundant. It can only be LCOW.
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.
LGTM
As discussed in #33854 there is no such thing as "build platform". Only platform for current stage (and maybe default platform for image access if maintainers can agree on it). So these should be used instead for detecting if conversion is needed. Ideally I would even like if this conversion only happens on starting a container instead of the builder but we can discuss that in another issue. OCI image spec doesn't seem to define anything about |
To be more accurate, your goal is that there shouldn't be such a thing as a "build platform". I don't necessarily disagree (entirely), but the fact is it's there presently, and the resolution of how the code base gets updated, if indeed to use
Yes, but after #33854 has been ratified and agreed.
Sure, that's for later and also orthogonal. But I have concerns about cache breaks if you are going to consider that. The builder has done normalization in this way since WS2016 TP4 days - a very long time. This PR doesn't change that, it just makes sure that the Windows daemon doesn't universally assume it's a full Windows path.
Again, if it doesn't, that is also orthogonal to this PR and something which needs addressing in the OCI docs rather than here. |
@@ -16,7 +17,7 @@ func TestNormaliseWorkdir(t *testing.T) { | |||
} | |||
|
|||
for _, test := range testCases { | |||
normalised, err := normaliseWorkdir(test.current, test.requested) | |||
normalised, err := normaliseWorkdir(runtime.GOOS, test.current, test.requested) |
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.
nit: normalize
(do we standardize on us eng?)
@@ -5,25 +5,31 @@ package dockerfile | |||
import "testing" | |||
|
|||
func TestNormaliseWorkdir(t *testing.T) { |
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.
"Normalize"
As discussed offline, both build and create paths will need to be updated based on the #33854 outcome and the current definitely isn't correct. LGTM to unblock |
Signed-off-by: John Howard <jhoward@microsoft.com>
2c69572
to
9fa4490
Compare
@johnstep Are we going to have a PR correcting the spelling errors before merging? |
@stevvooe I also prefer we standardize on language and locale. Is there official guidance for this somewhere? Can it be overridden on a file-by-file basis? @jhowardmsft, what is your take? |
I took care of it in #34602. |
Signed-off-by: John Howard jhoward@microsoft.com
WORKDIR in LCOW mode was being treated as a Windows path and not working -
/bin
was being translated toC:\bin
. This fixes it to use Unix semantics.@johnstep @dnephin PTAL
@gupta-ak - I left a
TODO
in there for the remote filesystem operation.