-
Notifications
You must be signed in to change notification settings - Fork 787
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
Setting --arch should set the TARGETARCH build arg #5478
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This error description doesn't seem to match the error message it's checking against.
pkg/parse/parse.go
Outdated
@@ -555,7 +564,7 @@ func PlatformsFromOptions(c *cobra.Command) (platforms []struct{ OS, Arch, Varia | |||
if err != nil { | |||
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do the changes in this function affect test results?
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.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
@@ -218,6 +218,7 @@ func TestSystemContextFromFlagSet(t *testing.T) { | |||
assert.NoError(t, err) | |||
assert.Equal(t, sc, &types.SystemContext{ | |||
BigFilesTemporaryDir: GetTempDir(), | |||
OSChoice: "linux", |
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.
Should this be runtime.GOOS
, too?
@@ -3566,6 +3566,7 @@ func TestCommit(t *testing.T) { | |||
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is TARGETVARIANT not being set to "v2", per "--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.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 |
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
[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
Needs 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 <[email protected]>
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?