dispatcher: honor default builtin-args while processing FROM --platform=#224
Conversation
While processing inline `--platform=` in FROM , imagebuilder ignores default builtinArgs so for example if user wants to use inbuilt default arg `FROM --platform=$BUILDPLATFORM` it should automatically replace it with default value of BUILDPLATFORM. Signed-off-by: Aditya R <arajan@redhat.com>
|
@flouthoc: all tests passed! Full PR test history. Your PR dashboard. DetailsInstructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. I understand the commands that are listed here. |
|
LGTM |
| return fmt.Errorf("Windows does not support FROM scratch") | ||
| } | ||
| } | ||
| defaultArgs := envMapAsSlice(builtinBuildArgs) |
There was a problem hiding this comment.
Are the default values all correct when --platform is specified differently for different stages?
There was a problem hiding this comment.
@nalind mostly we only use $BUILDPLATFORM or $TARGETPLATFORM in inline platform syntax so yes default values are correct for different stages. However there is still a small issue with the way buildah populates $TARGETPLATFORM but its a small fix on buildah side not on imagebuilder side and might not be relevant to this PR.
There was a problem hiding this comment.
Created a PR in buildah which exercises this and fixes $TARGETPLATFORM issue: containers/buildah#3899
There was a problem hiding this comment.
What about the dockerclient client?
There was a problem hiding this comment.
@nalind For dockerclient we are already setting args correctly so $BUILDPLATFORM will be set correctly but other options like $TARGETPLATFORM will be only exercised by docker deamon if "features": { "buildkit": true } is enabled on the server side. So if docker daemon is running without buildkit certain things will be no-op but I think imagebuilder can not help a lot in such cases.
There was a problem hiding this comment.
@nalind For
dockerclientwe are already setting args correctly so$BUILDPLATFORMwill be set correctly but other options like$TARGETPLATFORMwill be only exercised by docker deamon if"features": { "buildkit": true }is enabled on the server side. So if docker daemon is running without buildkit certain things will beno-opbut I think imagebuilder can not help a lot in such cases.
Its pretty much like above everything works fine except its just that $TARGETPLATFORM might be no-op depending upon the fact if dockerserver supports buildkit or not but I also think this part might be out of the scope of this PR itself.
But PR only talks about implementation of FROM --platform= which works fine for dockerclient and we added implementation for dockerclient here: #212
There was a problem hiding this comment.
The docker daemon doesn't evaluate the Dockerfile, we do.
There was a problem hiding this comment.
The docker daemon doesn't evaluate the Dockerfile, we do.
Oh my bad i mixed things, if we use TARGETPLATFORM as -build-arg with imagebuilder it will work but we can't expect $TARGETPLATFORM to get correctly populated cause we don't have cli arg like buildah build --platform or docker build --platform in imagebuilder to correctly set the value of TARGETPLATFORM correct me if i got this wrong.
So its just that with imagebuilder it is expected from user to set the value of TARGETGETPLATFORM using -build-arg otherwise there is no way set the correct value of TARGETPLATFORM and default value is always https://github.com/openshift/imagebuilder/blob/master/dispatchers.go#L35
I have a feeling that this is just expected behavior and I'm overthinking this.
There was a problem hiding this comment.
Wouldn't TAGETGETPLATFORM just default to the local platform then?
|
LGTM |
|
@nalind Could PTAL again. |
|
/approve |
|
@nalind @rhatdan Performed conformance test on this PR with with and without below diff I got same output as: https://pastebin.com/raw/mrb63TWE diff --git a/dockerclient/conformance_test.go b/dockerclient/conformance_test.go
index 66508f3..5585c9c 100644
--- a/dockerclient/conformance_test.go
+++ b/dockerclient/conformance_test.go
@@ -142,7 +142,7 @@ func TestCopyFrom(t *testing.T) {
e.Out, e.ErrOut = out, out
b := imagebuilder.NewBuilder(nil)
dockerfile := fmt.Sprintf(`
- FROM busybox AS base
+ FROM --platform=$BUILDPLATFORM busybox AS base
RUN %s
FROM busybox
%sTwo tests always fail for me even on the
|
|
A |
|
Thanks @nalind after Output: https://pastebin.com/raw/HVGGGAya Independent run for go test -v -tags conformance -timeout 3h ./dockerclient -run=TestConformanceInternal/novolume
=== RUN TestConformanceInternal
=== RUN TestConformanceInternal/novolume
conformance_test.go:1068: conformance-dockerbuild-28-docker-0-5 and conformance-dockerbuild-28-direct-0-5 differ at var/lib/not-in-this-image/:
&tar.Header{Typeflag:0x35, Name:"var/lib/not-in-this-image/", Linkname:"", Size:0, Mode:17389, Uid:0, Gid:0, Uname:"", Gname:"", ModTime:time.Date(1, time.January, 1, 0, 0, 0, 0, time.UTC), AccessTime:time.Date(1, time.January, 1, 0, 0, 0, 0, time.UTC), ChangeTime:time.Date(1, time.January, 1, 0, 0, 0, 0, time.UTC), Devmajor:0, Devminor:0, Xattrs:map[string]string(nil), PAXRecords:map[string]string(nil), Format:2}
&tar.Header{Typeflag:0x35, Name:"var/lib/not-in-this-image/", Linkname:"", Size:0, Mode:16877, Uid:0, Gid:0, Uname:"", Gname:"", ModTime:time.Date(1, time.January, 1, 0, 0, 0, 0, time.UTC), AccessTime:time.Date(1, time.January, 1, 0, 0, 0, 0, time.UTC), ChangeTime:time.Date(1, time.January, 1, 0, 0, 0, 0, time.UTC), Devmajor:0, Devminor:0, Xattrs:map[string]string(nil), PAXRecords:map[string]string(nil), Format:2}
conformance_test.go:1068: conformance-dockerbuild-28-docker-0-5 and conformance-dockerbuild-28-direct-0-5 differ at var/lib/:
&tar.Header{Typeflag:0x35, Name:"var/lib/", Linkname:"", Size:0, Mode:17389, Uid:0, Gid:0, Uname:"", Gname:"", ModTime:time.Date(1, time.January, 1, 0, 0, 0, 0, time.UTC), AccessTime:time.Date(1, time.January, 1, 0, 0, 0, 0, time.UTC), ChangeTime:time.Date(1, time.January, 1, 0, 0, 0, 0, time.UTC), Devmajor:0, Devminor:0, Xattrs:map[string]string(nil), PAXRecords:map[string]string(nil), Format:2}
&tar.Header{Typeflag:0x35, Name:"var/lib/", Linkname:"", Size:0, Mode:16877, Uid:0, Gid:0, Uname:"", Gname:"", ModTime:time.Date(1, time.January, 1, 0, 0, 0, 0, time.UTC), AccessTime:time.Date(1, time.January, 1, 0, 0, 0, 0, time.UTC), ChangeTime:time.Date(1, time.January, 1, 0, 0, 0, 0, time.UTC), Devmajor:0, Devminor:0, Xattrs:map[string]string(nil), PAXRecords:map[string]string(nil), Format:2}
conformance_test.go:1083: a(conformance-dockerbuild-28-docker-0-5)=map[] b(conformance-dockerbuild-28-direct-0-5)=map[] diff=map[var/lib/:[<0 dtrwxr-xr-x> <0 drwxr-xr-x>] var/lib/not-in-this-image/:[<0 dtrwxr-xr-x> <0 drwxr-xr-x>]]
conformance_test.go:946: 28: full Docker build was not equivalent to squashed image metadata /tmp/dockerbuild-conformance-1936807101/Dockerfile
=== RUN TestConformanceInternal/novolumenorun
--- FAIL: TestConformanceInternal (38.38s)
--- FAIL: TestConformanceInternal/novolume (23.33s)
--- PASS: TestConformanceInternal/novolumenorun (15.05s)
FAIL
FAIL github.com/openshift/imagebuilder/dockerclient 38.386s
FAIL
make: *** [Makefile:10: test-conformance] Error 1 |
|
That's... is docker setting the sticky bit on those directories? Is this a difference in behavior between docker-with-buildkit and docker-without-buildkit? |
|
Was failing for me irrespective of the buildkit but i can confirm again. |
|
It was my docker version updating it fixed for both buildkit and regular docker. |
|
Passes now $ sudo go test -v -tags conformance -timeout 3h ./dockerclient -run=TestConformanceInternal/novolume
=== RUN TestConformanceInternal
=== RUN TestConformanceInternal/novolume
=== RUN TestConformanceInternal/novolumenorun
--- PASS: TestConformanceInternal (9.63s)
--- PASS: TestConformanceInternal/novolume (6.67s)
--- PASS: TestConformanceInternal/novolumenorun (2.96s)
PASS
ok github.com/openshift/imagebuilder/dockerclient 9.630s |
|
/lgtm |
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: flouthoc, rhatdan The full list of commands accepted by this bot can be found here. The pull request process is described here DetailsNeeds approval from an approver in each of these files:
Approvers can indicate their approval by writing |
Use imagebuilder which sets correct behaviour for default builtinargs while processing inline `FROM --platform=` after openshift/imagebuilder#224 Signed-off-by: Aditya R <arajan@redhat.com>
Use imagebuilder which sets correct behaviour for default builtinargs while processing inline `FROM --platform=` after openshift/imagebuilder#224 Signed-off-by: Aditya R <arajan@redhat.com>
Use imagebuilder which sets correct behaviour for default builtinargs while processing inline `FROM --platform=` after openshift/imagebuilder#224 Signed-off-by: Aditya R <arajan@redhat.com>
Use imagebuilder which sets correct behaviour for default builtinargs while processing inline `FROM --platform=` after openshift/imagebuilder#224 Signed-off-by: Aditya R <arajan@redhat.com>
Use imagebuilder which sets correct behaviour for default builtinargs while processing inline `FROM --platform=` after openshift/imagebuilder#224 Signed-off-by: Aditya R <arajan@redhat.com>
|
This patch introduces tests that fail on arm64, armhf and armel with: On arm64: on armel: On armhf: |
While processing inline
--platform=inFROM, imagebuilder ignoresdefault builtinArgs so for example if user wants to use inbuilt default arg
FROM --platform=$BUILDPLATFORMit should automatically replace it withdefault value of BUILDPLATFORM.
Fixes