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(ci): specify target machine architecture for binary build #525

Merged

Conversation

COLDTURNIP
Copy link
Contributor

Which issue(s) this PR fixes:

GHA segfault while linking libs during binary build on CI pipe.

What this PR does / why we need it:

Prevent link amd64 libs accidentally in arm64 build environment.

Special notes for your reviewer:

Additional documentation or context

Signed-off-by: Raphanus Lo <yunchang.lo@suse.com>
@COLDTURNIP COLDTURNIP requested a review from derekbit February 14, 2025 05:08
Copy link

coderabbitai bot commented Feb 14, 2025

Walkthrough

This pull request updates environment variable handling in two areas. In the Dockerfile.dapper, the DAPPER_ENV is modified to include an additional ARCHS variable, along with a minor formatting tweak in a RUN command. In the scripts/build, a hardcoded architecture array is replaced with a dynamic approach that utilizes the ARCHS variable, defaulting to detect the architecture via uname -m and providing an error message for unsupported values.

Changes

Files Change Summary
Dockerfile.dapper Added ARCHS to the DAPPER_ENV environment variable; added a newline before the final RUN command for improved formatting.
scripts/build Replaced hardcoded architecture array with a dynamic mechanism using ARCHS; incorporates runtime architecture detection via uname -m and error handling for unsupported architectures.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant BuildScript as scripts/build
    participant System

    User->>BuildScript: Execute build script (optionally sets ARCHS)
    alt ARCHS variable provided
        BuildScript->>BuildScript: Parse ARCHS variable into array
    else ARCHS not provided
        BuildScript->>System: Invoke uname -m to determine architecture
        System-->>BuildScript: Return architecture (amd64/arm64)
    end
    BuildScript->>System: Proceed with build using determined architecture(s)
Loading

Possibly related PRs

  • fix(ci): multiplatform build #524: Introduces TARGET_PLATFORMS for architecture handling, which aligns with the modifications made to support flexible architecture specification in this PR.

Suggested reviewers

  • derekbit

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR. (Beta)
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (1)
scripts/build (1)

23-38: LGTM! Architecture detection logic effectively prevents segfaults.

The dynamic architecture detection with fallback to uname -m ensures correct library linking by:

  • Supporting external architecture specification via ARCHS
  • Mapping system architectures to Go architectures (aarch64/arm64arm64, x86_64amd64)
  • Failing fast on unsupported architectures

Consider adding comments to explain the architecture mapping.

Adding comments would help explain why aarch64 is mapped to arm64 and x86_64 to amd64.

     case $(uname -m) in
+    # Map ARM architectures (aarch64 is the system name, arm64 is the Go name)
     aarch64 | arm64)
         ARCHS=(arm64)
         ;;
+    # Map x86 architectures (x86_64 is the system name, amd64 is the Go name)
     x86_64)
         ARCHS=(amd64)
         ;;
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 4555c06 and 3f7c412.

📒 Files selected for processing (2)
  • Dockerfile.dapper (2 hunks)
  • scripts/build (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (2)
  • GitHub Check: Build binaries
  • GitHub Check: Summary
🔇 Additional comments (3)
scripts/build (1)

39-41: LGTM! Build configuration prevents library linking issues.

The build configuration effectively prevents segfaults by:

  • Using CGO_ENABLED=0 for static linking
  • Setting architecture-specific GOARCH
  • Including version and git info in binary
Dockerfile.dapper (2)

9-9: LGTM! Environment variable addition enables architecture control.

Adding ARCHS to DAPPER_ENV allows specifying target architectures in the CI pipeline, which is essential for preventing segfaults during library linking.


34-34: LGTM!

@derekbit derekbit enabled auto-merge (rebase) February 14, 2025 05:48
@derekbit derekbit disabled auto-merge February 14, 2025 05:48
@derekbit derekbit merged commit db9ac57 into longhorn:master Feb 14, 2025
9 checks passed
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