Skip to content
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

🐛 Fix Architecture metadata in Dockerfiles for distroless base image references #7070

Merged
merged 1 commit into from
Aug 17, 2022

Conversation

chrischdi
Copy link
Member

What this PR does / why we need it:

References the correct architecture for the distroless base image. Before this commit, docker would have chosen the platform of the docker host.

Current main:

$ uname -m
arm64
$ ARCH=ppc64le REGISTRY=test make docker-build-core
$ docker inspect docker.io/test/cluster-api-controller-ppc64le:dev | grep Architecture
        "Architecture": "arm64",

WIth this commit:

$ uname -m
arm64
$ ARCH=ppc64le REGISTRY=test make docker-build-core
$ docker inspect docker.io/test/cluster-api-controller-ppc64le:dev | grep Architecture
        "Architecture": "ppc64le",

Note: I had to move the ARG ARCH above the first FROM, otherwise it is not set/empty in FROM lines.

Which issue(s) this PR fixes (optional, in fixes #<issue number>(, fixes #<issue_number>, ...) format, will close the issue(s) when PR gets merged):
Fixes #7055

@k8s-ci-robot k8s-ci-robot added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. labels Aug 17, 2022
@k8s-ci-robot
Copy link
Contributor

@chrischdi: This issue is currently awaiting triage.

If CAPI contributors determines this is a relevant issue, they will accept it by applying the triage/accepted label and provide further guidance.

The triage/accepted label can be added by org members by writing /triage accepted in a comment.

Instructions 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.

@k8s-ci-robot k8s-ci-robot added the size/S Denotes a PR that changes 10-29 lines, ignoring generated files. label Aug 17, 2022
@chrischdi
Copy link
Member Author

Looks like a goproxy flake.

/test pull-cluster-api-build-main

@chrischdi
Copy link
Member Author

/test pull-cluster-api-test-main

@sbueringer
Copy link
Member

@chrischdi Could it be that we're losing ARCH on the binary this way?

See:

#18 [builder 8/8] RUN --mount=type=cache,target=/root/.cache/go-build --mount=type=cache,target=/go/pkg/mod CGO_ENABLED=0 GOOS=linux GOARCH=${ARCH} go build -trimpath -ldflags "-X 'sigs.k8s.io/cluster-api/version.buildDate=2022-08-17T10:52:56Z' -X 'sigs.k8s.io/cluster-api/version.gitCommit=d01f02b3613e480b93a26d8574891846113c68c3' -X 'sigs.k8s.io/cluster-api/version.gitTreeState=clean' -X 'sigs.k8s.io/cluster-api/version.gitMajor=1' -X 'sigs.k8s.io/cluster-api/version.gitMinor=2' -X 'sigs.k8s.io/cluster-api/version.gitVersion=v1.2.0-beta.0.321-d01f02b3613e48' -X 'sigs.k8s.io/cluster-api/version.gitReleaseCommit=d55b8320aefaa288aa8cb476dc1347e91293e20e' -extldflags '-static'" -o manager .
https://storage.googleapis.com/kubernetes-jenkins/pr-logs/pull/kubernetes-sigs_cluster-api/7070/pull-cluster-api-e2e-main/1559858591521837056/build-log.txt

Especially that ldflags is resolved while arch is ${ARCH}

@sbueringer
Copy link
Member

Can we just set it both inside of the builder image and top-level?

@chrischdi
Copy link
Member Author

Great find 👍 That would have caused serious issues, thanks!

Setting at both levels seems to work greatly :-)

@sbueringer
Copy link
Member

Thx, looks great!

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Aug 17, 2022
Copy link
Contributor

@killianmuldoon killianmuldoon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/lgtm

@sbueringer
Copy link
Member

/approve

/cherry-pick release-1.2

@k8s-infra-cherrypick-robot

@sbueringer: once the present PR merges, I will cherry-pick it on top of release-1.2 in a new PR and assign it to you.

In response to this:

/approve

/cherry-pick release-1.2

Instructions 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.

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: sbueringer

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 /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Aug 17, 2022
@k8s-ci-robot k8s-ci-robot merged commit 09744f5 into kubernetes-sigs:main Aug 17, 2022
@k8s-ci-robot k8s-ci-robot added this to the v1.3 milestone Aug 17, 2022
@k8s-infra-cherrypick-robot

@sbueringer: #7070 failed to apply on top of branch "release-1.2":

Applying: Fix Architecture metadata in Dockerfiles for distroless base image references
Using index info to reconstruct a base tree...
M	Dockerfile
M	cmd/clusterctl/Dockerfile
M	test/extension/Dockerfile
M	test/infrastructure/docker/Dockerfile
Falling back to patching base and 3-way merge...
Auto-merging test/infrastructure/docker/Dockerfile
CONFLICT (content): Merge conflict in test/infrastructure/docker/Dockerfile
Auto-merging test/extension/Dockerfile
CONFLICT (content): Merge conflict in test/extension/Dockerfile
Auto-merging cmd/clusterctl/Dockerfile
CONFLICT (content): Merge conflict in cmd/clusterctl/Dockerfile
Auto-merging Dockerfile
CONFLICT (content): Merge conflict in Dockerfile
error: Failed to merge in the changes.
hint: Use 'git am --show-current-patch=diff' to see the failed patch
Patch failed at 0001 Fix Architecture metadata in Dockerfiles for distroless base image references
When you have resolved this problem, run "git am --continue".
If you prefer to skip this patch, run "git am --skip" instead.
To restore the original branch and stop patching, run "git am --abort".

In response to this:

/approve

/cherry-pick release-1.2

Instructions 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.

@sbueringer
Copy link
Member

@chrischdi Can you please open a cherry-pick PR against 1.2?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. lgtm "Looks good to me", indicates that a PR is ready to be merged. needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. size/S Denotes a PR that changes 10-29 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

bad architecture metadata in k8s.gcr.io images
5 participants