fix: treat amd64 as equivalent to x86-64 for lifecycle binary selection#2544
Conversation
jjbustamante
left a comment
There was a problem hiding this comment.
Thanks for the fix! Two things to address before this can be merged:
1. DCO failure
The CI check is failing because your commit is missing the required Signed-off-by trailer. You can fix it by amending your commit:
git commit --amend --signoff
git push --force-with-leaseThe trailer should look like:
Signed-off-by: Your Name <your-email@example.com>
See the DCO app for more details.
2. Test coverage
The fix should be accompanied by a test. There are already tests following the exact same pattern in pkg/client/create_builder_test.go that you can use as a guide — specifically the arm64 case at line 616:
it("should download from predetermined uri for arm64", func() {
prepareFetcherWithBuildImage()
prepareFetcherWithRunImages()
opts.Config.Lifecycle.URI = ""
opts.Config.Lifecycle.Version = "3.4.5"
h.AssertNil(t, fakeBuildImage.SetArchitecture("arm64"))
mockDownloader.EXPECT().Download(
gomock.Any(),
"https://github.com/buildpacks/lifecycle/releases/download/v3.4.5/lifecycle-v3.4.5+linux.arm64.tgz",
).Return(
blob.NewBlob(filepath.Join("testdata", "lifecycle", "platform-0.4")), nil,
)
err := subject.CreateBuilder(context.TODO(), opts)
h.AssertNil(t, err)
})Please add the following two cases inside the same when("only lifecycle version is provided", ...) block, alongside the existing arm64 test:
Case 1 — amd64 maps to x86-64 with no warning:
it("should download x86-64 lifecycle when architecture is amd64", func() {
prepareFetcherWithBuildImage()
prepareFetcherWithRunImages()
opts.Config.Lifecycle.URI = ""
opts.Config.Lifecycle.Version = "3.4.5"
h.AssertNil(t, fakeBuildImage.SetArchitecture("amd64"))
mockDownloader.EXPECT().Download(
gomock.Any(),
"https://github.com/buildpacks/lifecycle/releases/download/v3.4.5/lifecycle-v3.4.5+linux.x86-64.tgz",
).Return(
blob.NewBlob(filepath.Join("testdata", "lifecycle", "platform-0.4")), nil,
)
err := subject.CreateBuilder(context.TODO(), opts)
h.AssertNil(t, err)
h.AssertNotContains(t, outBuf.String(), "failed to find a lifecycle binary")
})Case 2 — unknown architecture still emits a warning (regression guard):
it("should warn and default to x86-64 for unknown architecture", func() {
prepareFetcherWithBuildImage()
prepareFetcherWithRunImages()
opts.Config.Lifecycle.URI = ""
opts.Config.Lifecycle.Version = "3.4.5"
h.AssertNil(t, fakeBuildImage.SetArchitecture("riscv64"))
mockDownloader.EXPECT().Download(
gomock.Any(),
"https://github.com/buildpacks/lifecycle/releases/download/v3.4.5/lifecycle-v3.4.5+linux.x86-64.tgz",
).Return(
blob.NewBlob(filepath.Join("testdata", "lifecycle", "platform-0.4")), nil,
)
err := subject.CreateBuilder(context.TODO(), opts)
h.AssertNil(t, err)
h.AssertContains(t, outBuf.String(), "failed to find a lifecycle binary")
})The h.AssertContains / h.AssertNotContains helpers and outBuf are already available in the test file.
8952d45 to
6b96b4a
Compare
done |
Map amd64 architecture to x86-64 when constructing lifecycle binary download URLs to eliminate the spurious warning on standard AMD64 systems. Add tests for amd64 mapping and unknown architecture warning. Fixes buildpacks#2528 Signed-off-by: Onyx2406 <yashsancheti24@gmail.com>
6b96b4a to
c1956ba
Compare
Summary
amd64architecture tox86-64when constructing lifecycle binary download URLsubuntu-24.04)Motivation
Fixes #2528 — On AMD64 systems,
pack builder createemits a misleading warning:The correct binary was always downloaded since the default is
x86-64, but the warning is confusing becauseamd64andx86-64are the same architecture.Root Cause
uriFromLifecycleVersionchecksSupportedLinuxArchitecture(architecture)which only recognizesarm64,ppc64le, ands390x. When the architecture isamd64, it falls to the warning branch even though lifecycle releases name x86-64 binaries asx86-64.Changes
pkg/client/create_builder.go: Normalizeamd64→x86-64before the architecture check, and also acceptx86-64as a valid architecture alongside those fromSupportedLinuxArchitectureTest plan
amd64architecture → no warning, downloadsx86-64binaryx86-64architecture → no warning, downloadsx86-64binaryarm64,ppc64le,s390x→ unchanged behavior