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

[STAL-2781] Build release Linux binary on Ubuntu 20.04 #516

Merged
merged 1 commit into from
Oct 4, 2024

Conversation

jasonforal
Copy link
Collaborator

@jasonforal jasonforal commented Sep 27, 2024

What problem are you trying to solve?

We currently compile our Linux release binaries on GitHub's ubuntu-latest runner, which resolves to ubuntu 24.04. Because 24.04 uses a newer version of glibc, it compiles binaries that expect more recent versions of glibc (currently, v8 expects pthread_getattr_np@GLIBC_2.32). This leads to an error when trying to run the binary on older versions of Linux (specifically Ubuntu 20.04, which ships with glibc 2.31)

Image of a failed attempt to execute the binary on Ubuntu 20.04

What is your solution?

Building on Ubuntu 20.04 generates a binary that now expects glibc 2.2.5:

❯ greadelf -a datadog-static-analyzer-server | grep pthread_getattr_np
000003efe688  011700000006 R_X86_64_GLOB_DAT 0000000000000000 pthread_getattr_np@GLIBC_2.2.5 + 0

And thus the binaries now work on Ubuntu 20.04.

You can confirm that this modification to the release workflow functions correctly by looking at a pre-release that I just generated to test it:
image
image

We need to add an extra step to set up the container, as the base image is missing the packages that GitHub installs by default on a non-containerized runner (curl, gh, etc).

Alternatives considered

What the reviewer should know

  • I only modified the release.yml to build on Ubuntu 20.04 -- all of the integration tests will still build/run on ubuntu-latest (currently 24.04). Assuming glibc doesn't have forward-compatibility issues, this setup is fine.
  • glibc has backwards compatibility for the APIs we're using, so this runs on 22.04 (glibc 2.35), 24.04 (glibc 2.39)

@jasonforal jasonforal requested a review from a team as a code owner September 27, 2024 16:22
@jasonforal jasonforal requested review from jacobotb and juli1 and removed request for jacobotb September 27, 2024 16:22
@jasonforal
Copy link
Collaborator Author

Special thanks to @robertohuertasm for debugging this and identifying the solution

@robertohuertasm
Copy link
Member

Thank you @jasonforal for your nice words ❤️ and for your thorough work on this issue 🙌🏻 . It's always a pleasure to collaborate with you!

chmod go+r /etc/apt/keyrings/githubcli-archive-keyring.gpg
echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/githubcli-archive-keyring.gpg] https://cli.github.com/packages stable main" | tee /etc/apt/sources.list.d/github-cli.list > /dev/null
apt-get update
apt-get install gh -y
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why do we need this?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The gh CLI is needed to upload the artifact. A vanilla Ubuntu image doesn't come with this pre-installed

echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/githubcli-archive-keyring.gpg] https://cli.github.com/packages stable main" | tee /etc/apt/sources.list.d/github-cli.list > /dev/null
apt-get update
apt-get install gh -y
git config --global --add safe.directory $GITHUB_WORKSPACE
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why this too?

Copy link
Collaborator Author

@jasonforal jasonforal Oct 1, 2024

Choose a reason for hiding this comment

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

Same story -- Github's runners automatically have this configured, but that doesn't apply to a vanilla Ubuntu image. Without this, the job fails because of git throwing an unsafe repository error

Copy link
Collaborator

@juli1 juli1 left a comment

Choose a reason for hiding this comment

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

The code was released before for ubuntu 22.04 and we are now building for 20.04. Does it still work on 22.04?

@jasonforal
Copy link
Collaborator Author

Yes, for the APIs we're using, newer versions of glibc have backwards-compatibility. So it works on 22.04, 24.04, etc.

@jasonforal jasonforal merged commit f3f1dcb into main Oct 4, 2024
70 checks passed
@jasonforal jasonforal deleted the jf/STAL-2781 branch October 4, 2024 20:07
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.

3 participants