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

New cd images (ADX support and ARM64) #5254

Merged
merged 41 commits into from
Jan 25, 2024
Merged

New cd images (ADX support and ARM64) #5254

merged 41 commits into from
Jan 25, 2024

Conversation

tarakby
Copy link
Contributor

@tarakby tarakby commented Jan 19, 2024

Update the node software process after the latest crypto module changes:

  1. the crypto module has non-portable code that requires proper cross compilation when building for a different target
  2. the crypto module uses CPU's ADX instructions. If the target CPU does not support ADX, such code should be disabled.

In this PR:

  • fix a bug in a previous PR (commit) where the empty netgo tag was removed. This fixes the build without netgo.
  • rename the build that uses the local script arch and ADX detection to "native build". These builds assume the image is built and run on the same machine type (arch and cpu properties). This is the case of CI tests and integration tests for instance.
  • add new images to build production images with and without ADX code:
    • with ADX code: can only run on a machine with ADX support, this is the default case, and it offers optimal performance.
    • without ADX code: uses portable code and can run on all machines. The build requires adding a CGO flag, passed as an argument to Dockerfile. It offers slower performance.
  • add a new image for arm64 cross build. The build requires specifying the cross-compiler in CC. CC is passed to the Dockerfile as an argument.
  • add all new images build to cd.yml and add a step to install the cross-compilation tools (works only on Debian)
  • update builds.yml to use the new commands.
  • image names in Makefile use IMAGE_TAG only (which is derived from the short commits in most cases)

These are the images built in cd.yml (assumed to run on amd64):

  • with ADX code
  • with ADX code and without netgo.
  • without ADX code and without netgo.
  • arm64 images
    ( without ADX code and with netgo was skipped for now but can be added if needed. With the current PR, if we disable ADX, netgo has to be disabled too. This assumes that there are no machines that cannot run images with netgo disabled)
    builds.yml can generate the same images but the arm64 ones, because of the limitation of number of input boxes in githhub workflows.

@codecov-commenter
Copy link

codecov-commenter commented Jan 19, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (f0b7f2a) 55.61% compared to head (12d4b6c) 55.58%.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #5254      +/-   ##
==========================================
- Coverage   55.61%   55.58%   -0.03%     
==========================================
  Files        1002     1002              
  Lines       96600    96600              
==========================================
- Hits        53720    53695      -25     
- Misses      38820    38844      +24     
- Partials     4060     4061       +1     
Flag Coverage Δ
unittests 55.58% <ø> (-0.03%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@tarakby tarakby marked this pull request as ready for review January 19, 2024 22:49
@tarakby tarakby changed the title Tarak/new cd images New cd images (ADX support and ARM64) Jan 19, 2024
@@ -29,11 +29,17 @@ jobs:
- name: Authenticate docker with gcloud
run: |
gcloud auth configure-docker
- name: Install Tools
run: make install-cross-build-tools
Copy link
Contributor Author

Choose a reason for hiding this comment

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

needed for the arm cross-build

apt-get -y install apt-utils gcc-aarch64-linux-gnu

.PHONY: docker-native-build-collection
docker-native-build-collection:
Copy link
Contributor Author

@tarakby tarakby Jan 19, 2024

Choose a reason for hiding this comment

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

native builds detect whether the current machine supports ADX using crypto_adx_flag.mk

docker-build-collection-without-netgo:
docker build -f cmd/Dockerfile --build-arg TARGET=./cmd/collection --build-arg COMMIT=$(COMMIT) --build-arg VERSION=$(IMAGE_TAG_NO_NETGO) --build-arg GOARCH=$(GOARCH) --build-arg CGO_FLAG=$(CRYPTO_FLAG) --target production \
.PHONY: docker-build-collection-with-adx
docker-build-collection-with-adx:
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Optimal case (with ADX and with netgo) - this is called in CD.

Note that the image has the same "tag" as the native builds. Native builds (locally or CI) are not run in CD.

Copy link
Contributor

Choose a reason for hiding this comment

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

so the difference between this an docker-native-build-collection is that native allows overriding ADX while this doesn't?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This target hardcodes the arguments for a specific target (ideally I would want to hardcode GOARCH too, but left it in case we want to call it on ARM machines too).

docker-native-build-... set the arguments based on the host (detect ADX support, set ARCH)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

For better clarity and consistency, I hardcoded amd64 for production targets that are not natively built and not meant for arm d3b99bd (though I can revert it if needed)

Makefile Outdated Show resolved Hide resolved
Makefile Outdated Show resolved Hide resolved
Makefile Show resolved Hide resolved
Makefile Outdated Show resolved Hide resolved
docker-build-collection-without-netgo:
docker build -f cmd/Dockerfile --build-arg TARGET=./cmd/collection --build-arg COMMIT=$(COMMIT) --build-arg VERSION=$(IMAGE_TAG_NO_NETGO) --build-arg GOARCH=$(GOARCH) --build-arg CGO_FLAG=$(CRYPTO_FLAG) --target production \
.PHONY: docker-build-collection-with-adx
docker-build-collection-with-adx:
Copy link
Contributor

Choose a reason for hiding this comment

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

so the difference between this an docker-native-build-collection is that native allows overriding ADX while this doesn't?

Makefile Outdated Show resolved Hide resolved
@sjonpaulbrown
Copy link
Collaborator

@tarakby, using this branch, could you please run all of the workflows being modified so that we can verify the execution?

Also, as a general comment, I think we will need to update the following lines in the build workflow to use the new make targets

@sjonpaulbrown
Copy link
Collaborator

If the targets are changing, the following workflow will also need to be updated to align with the target changes.

This will need to be updated separately, but this will break BN2 until the workflow is updated.

tarakby and others added 3 commits January 22, 2024 21:20
Co-authored-by: Peter Argue <89119817+peterargue@users.noreply.github.com>
Copy link
Contributor

@peterargue peterargue left a comment

Choose a reason for hiding this comment

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

Thanks for adding support for ARM builds and unravelling our complex mess of a makefile.

I'm a little confused by all make target names, but I think the changes are correct, so I don't want to hold this up this PR over naming.

We should circle back and refactor the build system soon. It's become pretty complex.

@tarakby
Copy link
Contributor Author

tarakby commented Jan 24, 2024

@sjonpaulbrown, the PR is now ready.

@tarakby
Copy link
Contributor Author

tarakby commented Jan 24, 2024

I'm a little confused by all make target names, but I think the changes are correct, so I don't want to hold this up this PR over naming.
We should circle back and refactor the build system soon. It's become pretty complex.

Agree, the build system could be made simpler.

@@ -19,7 +19,9 @@ ifeq (${IMAGE_TAG},)
IMAGE_TAG := ${SHORT_COMMIT}
endif

IMAGE_TAG_NO_NETGO := $(IMAGE_TAG)-without-netgo
Copy link
Collaborator

Choose a reason for hiding this comment

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

Altering this tag name could impact partner automation. We will want to work with @vishalchangrani to ensure that the partners who rely on this know the image tag is changing.

@tarakby tarakby added this pull request to the merge queue Jan 25, 2024
Merged via the queue into master with commit 5006941 Jan 25, 2024
50 of 51 checks passed
@tarakby tarakby deleted the tarak/new-cd-images branch January 25, 2024 18:20
@tarakby tarakby restored the tarak/new-cd-images branch February 7, 2024 14:42
@tarakby tarakby mentioned this pull request Feb 7, 2024
2 tasks
@tarakby tarakby deleted the tarak/new-cd-images branch April 5, 2024 20:51
This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants