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 test setup to run on ARM instances #3904

Merged
merged 5 commits into from
Sep 23, 2024

Conversation

michel-laterman
Copy link
Contributor

What is the problem this PR solves?

Allow tests to run off arm platforms

How does this PR solve the problem?

Remove hard-coded amd64 values from test setup

How to test this PR locally

make test-int or make test-e2e

Related issues

Copy link
Contributor

mergify bot commented Sep 13, 2024

This pull request does not have a backport label. Could you fix it @michel-laterman? 🙏
To fixup this pull request, you need to add the backport labels for the needed
branches, such as:

  • backport-./d./d is the label to automatically backport to the 8./d branch. /d is the digit

Copy link
Contributor

mergify bot commented Sep 13, 2024

backport-8.x has been added to help with the transition to the new branch 8.x.
If you don't need it please use backport-skip label and remove the backport-8.x label.

@mergify mergify bot added the backport-8.x Automated backport to the 8.x branch with mergify label Sep 13, 2024
@@ -1,5 +1,6 @@
ARG GO_VERSION
FROM docker.elastic.co/beats-dev/golang-crossbuild:${GO_VERSION}-main-debian11

Choose a reason for hiding this comment

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

Speaking as someone seeing this for the first time, the fact that ARCH can be main is very surprising. Can we not use the built-in TARGETARCH and use main in the Dockerfile if the value is amd64?

Copy link

@andrzej-stencel andrzej-stencel Sep 16, 2024

Choose a reason for hiding this comment

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

Or not use the built-in TARGETARCH arg at all, as it seems misused in this case. Use GO_ARCH (in line with GO_VERSION) or another arbitrary name?

Copy link
Member

Choose a reason for hiding this comment

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

The main arch seems a bit weird actually...
@michel-laterman Does this come from some quirk on golang-crossbuild docker tags?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yep, it's defined in the crossbuild readme

Copy link
Member

Choose a reason for hiding this comment

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

Please see elastic/golang-crossbuild#446.

I recommend using the Debian-X version in the name of the Docker image tag. This might help with reproducibility.


That's how it's also done in Beats, see elastic/beats#34921

However in Elastic Agent -> https://github.com/elastic/elastic-agent/blob/d99b09b0769f6f34428321eedb00c0b4339c202b/dev-tools/mage/crossbuild.go#L243-L246 , I don't know the build system but it looks weird to me they use debian-8 but debian-10 in Beats.

Copy link

@swiatekm swiatekm Sep 17, 2024

Choose a reason for hiding this comment

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

Or not use the built-in TARGETARCH arg at all, as it seems misused in this case. Use GO_ARCH (in line with GO_VERSION) or another arbitrary name?

I wanted to use TARGETARCH, because it lets us actually build a multiplatform image. But it looks like there isn't a way to conditionally use main in the crossbuild image tag based on this. It'd be best if the crossbuild image was multiplatform as well - then this would be completely transparent, and we'd just do docker buildx build --platform=... in the Makefile.

But as this cannot be done, I'm ok with the previous approach of using a custom variable here.

Incidentally, what are the chances of making the crossbuild image multiplatform?

Copy link
Member

Choose a reason for hiding this comment

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

@v1v is there a specific reason why main is used instead of x86/amd64 ? I see the list of the images in golang-crossbuild README and the main arch sticks out while all the other archs follow more conventional naming (arm, mips, ppc etc.)

But at least I can see now why main is used as default arg here, to target x86/amd64 architecture

Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've changed the name variable name to SUFFIX to distance it from the TARGETARCH/ARCH concepts as it includes more information than just the architecture.
I also set it to use the same main-debian11 suffix as our other targets use.

I'm more then happy to change to TARGETARCH if the upstream sources support it.

@jlind23
Copy link
Contributor

jlind23 commented Sep 17, 2024

@michel-laterman I just looked at a slack conversation between @v1v and @jmlrt concluding that there was a recent change on the elasticsearch side that removed those images suffixed with the arch value.
IIUC we should just default to the multi arch one just like below:

docker pull docker.elastic.co/elasticsearch/elasticsearch:8.15.2-7f2cd899-SNAPSHOT
8.15.2-7f2cd899-SNAPSHOT: Pulling from elasticsearch/elasticsearch
b14b0d0a7610: Already exists
bc03f0deaf3c: Pull complete
9a114eab9584: Pull complete
4ca545ee6d5d: Pull complete
341b5ebe39a8: Pull complete
6b896993e0fc: Pull complete
301b398356a8: Pull complete
07428383d5cd: Pull complete
df1cde76a217: Pull complete
f7adb9f55788: Pull complete
Digest: sha256:6cbd256f19c67ee0e982064befb85b29770ec9bc71ab33d5bb623e9a2936d942
Status: Downloaded newer image for docker.elastic.co/elasticsearch/elasticsearch:8.15.2-7f2cd899-SNAPSHOT
docker.elastic.co/elasticsearch/elasticsearch:8.15.2-7f2cd899-SNAPSHOT

Copy link
Contributor

mergify bot commented Sep 19, 2024

This pull request is now in conflicts. Could you fix it @michel-laterman? 🙏
To fixup this pull request, you can check out it locally. See documentation: https://help.github.com/articles/checking-out-pull-requests-locally/

git fetch upstream
git checkout -b arm-test-fix upstream/arm-test-fix
git merge upstream/main
git push upstream arm-test-fix

@michel-laterman
Copy link
Contributor Author

buildkite test this

Copy link

Copy link
Member

@pchila pchila left a comment

Choose a reason for hiding this comment

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

LGTM

@michel-laterman michel-laterman merged commit 2df9042 into elastic:main Sep 23, 2024
8 checks passed
@michel-laterman michel-laterman deleted the arm-test-fix branch September 23, 2024 13:56
mergify bot pushed a commit that referenced this pull request Sep 23, 2024
Fix test setup to run on ARM instances

(cherry picked from commit 2df9042)
michel-laterman added a commit that referenced this pull request Sep 23, 2024
Fix test setup to run on ARM instances

(cherry picked from commit 2df9042)

Co-authored-by: Michel Laterman <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport-8.x Automated backport to the 8.x branch with mergify Team:Elastic-Agent-Control-Plane Label for the Agent Control Plane team tech debt
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants