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

Release workflow: Use GH Action for packaging sources, cross-compile addr2line on host #44

Merged
merged 3 commits into from
Jun 1, 2023

Conversation

qmonnet
Copy link
Contributor

@qmonnet qmonnet commented May 31, 2023

Follow-up to #42.

This PR updates the release workflow to use a dedicated GitHub Action for packaging the source files for retsnoop and its submodules. Contrarily to the previous commands, this Action should take into account the export-ignore directives from the .gitattributes files. Although it may not show immediately for the libbpf submodule, because we need libbpf/libbpf@3f591a6 to be synced before that.

When testing the change above, I observed that the job for building the arm64 binary would no longer pass. This is due to the Rust registry index update getting OOM-killed in the Docker container that we use to cross-compile. I'm not sure what caused this change, but I found a way to address it: by cross-compiling addr2line directly on the host, we solve the memory issue, and we cut down the duration of the job from ~20 to ~6 minutes.

Instead of re-implementing source packaging for multiple projects, we've
come up with a dedicated GitHub Action. Let's use it for the release
workflow.

This Action should take into account the export-ignore rules from
.gitattributes, modulo some adjustment that was just merged into libbpf
and has not been propagated to retsnoop's submodules yet. In the
meantime, this means that we have no difference with the previous
behaviour, where the release workflow would ignore these exclusion rules
anyway.

Signed-off-by: Quentin Monnet <quentin@isovalent.com>
This commit contains a few clean-ups for the release GitHub Workflow:

- Mention arch in arch-specific workflow steps
- Add string to grep in "file"'s output to matrix directly, instead of
  crafting environment variables
- Miscellaneous indent and spacing nits

No functional change.

Signed-off-by: Quentin Monnet <quentin@isovalent.com>
Although the release workflow used to succeed, the arm64 is now failing
because the update for Cargo's registry index gets OOM-killed, when
happening in the Docker container we use for cross-compiling. I'm not
sure what caused that change, but this is something we want to address.

I tested several options: using the "sparse" protocol to download less
data for the index, or using the git CLI to update it ("cargo update
--config net.git-fetch-with-cli=true"), which is supposed to require
less memory. None of these solutions was enough. I managed to fix the
workflow by: 1) running "cargo update" ouside of the container, 2)
mounting Cargo's home directory into the container:

  docker run --platform linux/arm64 --rm -v $(pwd):/build \
      -v ${HOME}/.cargo/git:/usr/local/cargo/git \
      -v ${HOME}/.cargo/registry:/usr/local/cargo/registry \
      ubuntu:22.04 \
      ...

and 3) running another "cargo update" inside of the container (using
sparse and git CLI for both updates).

This solution seems heavy and not optimal, and the job would still take
around 20 minutes to complete.

Instead, we can build addr2line outside of the container, directly on
the runner. This is not super-clean in the sense that part of retsnoop
is cross-compiled on the host, and another part of it inside of the
container; also, we set "CARGO=true" in the container to avoid
re-triggering a build. But it works, and it's efficient: the job now
lasts about 6 minutes.

Signed-off-by: Quentin Monnet <quentin@isovalent.com>
@anakryiko
Copy link
Owner

This is awesome, @qmonnet! Thanks so much for doing this! I've updated libbpf and bpftool deps in #45, so everything should be in order for the next release. I'll let you know how it goes next time!

@anakryiko anakryiko merged commit 2ab0379 into anakryiko:master Jun 1, 2023
@qmonnet qmonnet deleted the pr/srcs-pkg-gh-action branch June 1, 2023 19:36
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.

2 participants