Setting --arch should set the TARGETARCH build arg#5478
Setting --arch should set the TARGETARCH build arg#5478openshift-merge-bot[bot] merged 1 commit intocontainers:mainfrom
Conversation
|
Ephemeral COPR build failed. @containers/packit-build please check. |
tests/bud.bats
Outdated
| fi | ||
|
|
||
| assert "$output" =~ "image platform .* does not match the expected platform" \ | ||
| "With explicit --platform, buildah should warn about no variant" |
There was a problem hiding this comment.
This error description doesn't seem to match the error message it's checking against.
tests/bud.bats
Outdated
| assert "$output" !~ "missing .* build argument" \ | ||
| "With explicit --platform, buildah should not warn" | ||
| assert "$output" =~ "image platform .* does not match the expected platform" \ | ||
| "With explicit --platform, buildah should warn about no variant" |
There was a problem hiding this comment.
This error description doesn't seem to match the error message it's checking against.
pkg/parse/parse.go
Outdated
| return nil, fmt.Errorf("unable to parse platform: %w", err) | ||
| } | ||
| if os != "" || arch != "" || variant != "" { | ||
| if os != runtime.GOOS || arch != runtime.GOARCH || variant != "" { |
There was a problem hiding this comment.
Do the changes in this function affect test results?
There was a problem hiding this comment.
We are now defaulting the OS and ARCH and only care if the user changes the value to something different then the default
before on an linux/amd64 machine --platform=linux/amd64 --os=linux --arch=amd64 blue up, now it is allowed since it ultimately does what the user wanted.
If the user does
--platform=linux/amd64 --os=linux --arch=arm64 then the command will fail
There was a problem hiding this comment.
It doesn't check that the --platform and --arch/--os values agree. And what's the benefit of allowing some combinations of the flags? Why encourage people with "well, sometimes, it's allowed, in newer versions"?
There was a problem hiding this comment.
It checks if the --arch or --os changed values from the default.
Similar to --arch="" and --os="" in the old version would have been ignored.
I think we are arguing about a nothing burger, and will relent to make you happy, even though this is the corner case of all corner cases.
|
|
||
| run_buildah build $WITH_POLICY_JSON --arch amd64 -t source -f $containerfile | ||
| assert "$output" !~ "WARNING" \ | ||
| "With explicit --os (but no arch/variant), buildah should not warn about TARGETOS" |
There was a problem hiding this comment.
This error description doesn't seem to match the error message it's checking against.
1b80d3e to
bf4ada5
Compare
pkg/parse/parse_test.go
Outdated
| assert.NoError(t, err) | ||
| assert.Equal(t, sc, &types.SystemContext{ | ||
| BigFilesTemporaryDir: GetTempDir(), | ||
| OSChoice: "linux", |
There was a problem hiding this comment.
Should this be runtime.GOOS, too?
| derivedBuilder, err := buildah.NewBuilder(ctx, store, buildah.BuilderOptions{ | ||
| FromImage: buildahID, | ||
| }) | ||
| assert.NoErrorf(t, err, "creating a new Builder") |
There was a problem hiding this comment.
Ah, good catch. The require.NoErrorf() after the defer can be removed.
| "With explicit --platform, buildah should warn about pulling difference in platform" | ||
| assert "$output" =~ "TARGETOS=linux" " --platform TARGETOS set correctly" | ||
| assert "$output" =~ "TARGETARCH=amd64" " --platform TARGETARCH set correctly" | ||
| assert "$output" =~ "TARGETVARIANT=" " --platform TARGETVARIANT set correctly" |
There was a problem hiding this comment.
Is TARGETVARIANT not being set to "v2", per "--platform"?
There was a problem hiding this comment.
I think this reveals the fix just not being correct — the core issue is that the buildDockerfilesOnce code setting TARGET* expects SystemContext.*Choice to never be "", and that’s not how the values are set.
Compare more in #5543 (review)
tests/bud.bats
Outdated
| assert "$output" =~ "TARGETOS=linux" "--os TARGETOS set correctly" | ||
| assert "$output" =~ "TARGETARCH=amd64" "--os TARGETARCH set correctly" | ||
| assert "$output" =~ "TARGETVARIANT=" "--os TARGETVARIANT set correctly" | ||
| assert "$output" =~ "TARGETPLATFORM=linux/amd64" "--os TARGETPLATFORM set correctly" |
There was a problem hiding this comment.
Are these always going to be "amd64", or would "$(go env GOARCH)" be a better match?
|
Looks like this needs a refresh and test help @rhatdan |
|
@TomSweeneyRedHat @nalind @flouthoc @giuseppe @vrothberg PTAL this finally passes, and is a pretty ugly bug |
|
[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 |
Also fix a long standing FIXME in the test framework. Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
|
LGTM |
Also fix a long standing FIXME in the test framework.
What type of PR is this?
What this PR does / why we need it:
How to verify it
Which issue(s) this PR fixes:
Special notes for your reviewer:
Does this PR introduce a user-facing change?