-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
auto-detect build runtime arch #2256
Conversation
If the user hasn't explictyly set GOARCH, don't default to amd64. This way, a user has to expliciltly cross-compile, instead of needing to know to set GOARCH on build for a native arch that isn't amd64. Signed-off-by: Christy Norman <christy@linux.vnet.ibm.com>
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 shows perfect fine for me 👍
The CI will check this command for all types. See here
So, since it passed all still working.
Just a nit.: It is missing an entry in the CHANGELOG.
Could you please add it?
The code to explicitly set GOARCH to amd64 has been around for awhile, and I'm not sure of the origins of that. If I had to guess, the originial reasoning is that Obviously that isn't always true (like in your case), but if we make this change, we could break a lot of other users that build from one architecture and target another for their operator deployments. /hold @AlexNPavel @hasbro17 @estroz any thoughts on this? |
@joelanford @clnperez yes that is why |
Ditto to not breaking existing behavior if we can mitigate this by setting |
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.
Could please you check the review comments?
Hm. So -- when you do the build on a non-AMD arch, you still get the outer container for the arch you're on b/c the UBI images are using manifest lists. How would, for example, you keep from getting an arm image with a AMD binary? IOW -- what is the build procedure/use-case we'd be breaking exactly? |
Oops. Typo there ^ (edited). ARM image with an AMD binary. |
@clnperez users may not be building the operator binary on an amd64 system (operator-sdk builds directly on the host), so following current workflows after changing to the suggested behavior could cause runtime errors when running the binary in a container created from the default base image. We currently provide the ability to set |
@estroz I guess I'm trying to say that the default base image isn't an x86 one per se, so I don't think that this is actually going to break anything.
That |
@clnperez That's a good point. There are possibilities for how things may already be broken.
Either way, I think I'm convinced that users are already broken or are just getting lucky. Does anyone see something I don't? This is yet another reason why I'm a fan of ditching the In the meantime, perhaps the best option would be to use Go's default GOARCH handling. I'm pretty sure the logic that's in this PR would be identical to the logic the Thoughts? |
If we just delte those lines, that would probably be fine. I think you could still override by setting GOARCH on a build if someone wanted to cross-compile. |
Considering that users have been "broken" since we switched base images, and multi-arch support in UBI and eventually the docker cli, the only way to get expected behavior is to delete GOARCH setting logic (as @clnperez suggested). Users should rely on existing go binary configuration. |
I don't know if there actually was a breakage, but if alpine was not a multi-arch image, and UBI was, then we introduced the possibility of building an amd64 binary into a non-amd64 image.
Just everything else that's in the base image, e.g. |
@joelanford you mean this bin from the ubi base?
(this is on my power vm, so it pulled down the power ubi image) |
Was this what you were thinking @joelanford #2268 ? |
@clnperez: PR needs rebase. 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. |
If the user hasn't explictyly set GOARCH, don't default to amd64. This
way, a user has to expliciltly cross-compile, instead of needing to know
to set GOARCH on build for a native arch that isn't amd64 (the current behaviour).
Signed-off-by: Christy Norman christy@linux.vnet.ibm.com
Description of the change:
use the go runtime's goarch instead of a potentially (probably) un-set local environment variable
Motivation for the change:
an internal build team was getting a ppc64le docker image with an x86 binary inside and was super confused :D