-
Notifications
You must be signed in to change notification settings - Fork 1.3k
local: fix platform-split=true option #6007
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
1707034
to
e30a4fc
Compare
@profnandaa Any idea what happened to the windows tests here? |
Taking a look rn. |
We missed that path that calls (dlv)
> github.com/moby/buildkit/exporter/local.(*localExporterInstance).Export.func2.1() C:/dev/core-containers/buildkit/exporter/local/export.go:128 (PC: 0x224b379)
123: }
124: if cleanup != nil {
125: defer cleanup()
126: }
127:
=> 128: if !e.opts.PlatformSplit {
129: // check for duplicate paths
130: err = outputFS.Walk(ctx, "", func(p string, entry os.DirEntry, err error) error {
131: if entry.IsDir() {
132: return nil
133: }
(dlv) p e.opts.PlatformSplit
true Cross-checking with the rest of the exporters then send a patch. Ref #4994 |
PFA the patch to your branch, ran on my fork here |
@profnandaa So previously this code path did not run for windows? |
Yes, did not run previously. |
db3590b
to
65f3ddc
Compare
@profnandaa This test failure looks related to this commit 30b572b
|
@crazy-max -- I doubt... I've tried to dig through to find where the failure is happening but can't find it since it fails just silently. Same happens even if I revert my change. Ran the debugger till
Any ideas? |
Hum wonder if it could be the folder name with os version 🤔 |
That was my first suspicion but |
@profnandaa Do the platform directories work correctly for wcow on multi-platform builds that don't require |
Since we don't have multi-platform build support yet, I'm unable to test this. I was just about to write to you that since this is actually not needed at the moment coz of the single-platform support, I suggest we skip the test on Windows for now; as I continue with the investigation. |
@tonistiigi -- this is besides our current issue. I just noticed that you cherry-picked a slightly older fix from my branch then (if you see the patch). I have done a refactor here to match, will be nice if you can pick that - profnandaa@780b19b |
@crazy-max @tonistiigi -- I think I've finally found where the bug is at last, in > github.com/tonistiigi/fsutil.(*subDirFS).Walk() C:/dev/core-containers/buildkit/vendor/github.com/tonistiigi/fsutil/fs.go:125 (PC: 0x1501600)
120: func (fs *subDirFS) Walk(ctx context.Context, target string, fn gofs.WalkDirFunc) error {
121: first, rest, _ := strings.Cut(target, string(filepath.Separator))
122:
123: for _, d := range fs.dirs {
124: if first != "" && first != d.Stat.Path {
=> 125: continue
126: }
127:
128: fi := &StatInfo{d.Stat.Clone()}
129: if !fi.IsDir() {
130: return errors.WithStack(&os.PathError{Path: d.Stat.Path, Err: syscall.ENOTDIR, Op: "walk subdir"})
(dlv) p first
"/"
(dlv) p rest
""
(dlv) p target
"/"
(dlv) p d.Stat.Path
"windows_amd64"
Exploring how best to fix... |
Looks like we'll have to fix from the err := s.fs.Walk(ctx, "/", func(path string, entry os.DirEntry, err error) error { Already diff --git a/vendor/github.com/tonistiigi/fsutil/send.go b/vendor/github.com/tonistiigi/fsutil/send.go
index e4a315638..6584ccef7 100644
--- a/vendor/github.com/tonistiigi/fsutil/send.go
+++ b/vendor/github.com/tonistiigi/fsutil/send.go
@@ -148,7 +148,7 @@ func (s *sender) sendFile(h *sendHandle) error {
func (s *sender) walk(ctx context.Context) error {
var i uint32 = 0
- err := s.fs.Walk(ctx, "/", func(path string, entry os.DirEntry, err error) error {
+ err := s.fs.Walk(ctx, string(filepath.Separator), func(path string, entry os.DirEntry, err error) error {
if err != nil {
return err
} |
Using "/" was causing a silent bug later on at `fs.go:121` that is expecting platform-specific separators. See discussion at moby/buildkit#6007 Fix this by using `\\` on Windows and `/` on unix. Signed-off-by: Anthony Nandaa <[email protected]>
|
||
expPlatform := runtime.GOOS + "_" + runtime.GOARCH | ||
_, err = os.Stat(filepath.Join(destDir, expPlatform+"/")) | ||
require.NoError(t, err) |
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.
how do we deal with the windows case where the build number is added to the os name? Unless you explicitly specify --opt platform=...
, eg.
#10 exporting to client directory
#10 copying files windows(10.0.22631)/amd64
#10 copying files windows(10.0.22631)/amd64 6.01MB 11.4s
#10 copying files windows(10.0.22631)/amd64 150.83MB 16.5s
#10 copying files windows(10.0.22631)/amd64 239.47MB 23.7s
#10 copying files windows(10.0.22631)/amd64 239.47MB 23.9s done
#10 DONE 24.2s
should we normalize that from the code?
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.
are these ()
invalid names for windows?
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.
they are not invalid, I think this change was brought in some time back here - containerd/platforms#6
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.
what do you think about this? profnandaa@3fc6393
Currently the option only worked when platform-split=false was set for multi-platform build but not for setting single platform build to use platform-split=true. Signed-off-by: Tonis Tiigi <[email protected]>
65f3ddc
to
31a8c4e
Compare
Rebased to include #6017 |
@crazy-max -- the failure now is coz the directory is named differently on windows with a |
I have updated the test to use @tonistiigi Feel free to squash with your commit.
I agree that it would be better to strip the os version but I think we should just change the key here: buildkit/exporter/local/export.go Line 184 in 25c7c80
Instead of We can look at this as follow-up. |
@crazy-max One last thing, can cherry pick this refactor instead? Tonis has picked a slightly older version from my branch, I'd thought he'll use my patch file. |
7c3c4fe
to
c818a97
Compare
Done, thanks! |
c818a97
to
d7f98a9
Compare
Signed-off-by: Anthony Nandaa <[email protected]>
Signed-off-by: Tonis Tiigi <[email protected]>
Signed-off-by: CrazyMax <[email protected]>
d7f98a9
to
db03322
Compare
@ArthurFlag Needs docs follow-up in https://docs.docker.com/build/exporters/local-tar/ with some examples as well similar to what we have in BuildKit README but with Buildx: https://github.com/moby/buildkit?tab=readme-ov-file#local-directory |
Currently the option only worked when platform-split=false was set for multi-platform build but not for setting single platform build to use platform-split=true.
docker/buildx#3215