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 installation command for arm64 #2729

Merged
merged 3 commits into from
Nov 1, 2024

Conversation

vankichi
Copy link
Contributor

@vankichi vankichi commented Nov 1, 2024

Description

SSIA

Related Issue

Versions

  • Vald Version: v1.7.13
  • Go Version: v1.23.2
  • Rust Version: v1.81.0
  • Docker Version: v27.3.1
  • Kubernetes Version: v1.31.1
  • Helm Version: v3.16.2
  • NGT Version: v2.2.4
  • Faiss Version: v1.9.0

Checklist

Special notes for your reviewer

Summary by CodeRabbit

  • New Features

    • Enhanced architecture handling for the installation of helm-docs, yq, telepresence, kubectl, and kind, ensuring compatibility across different systems.
    • Introduced a new variable DARCH to dynamically adjust architecture strings based on the system architecture.
  • Bug Fixes

    • Improved download URLs for binaries to reflect the correct architecture, preventing potential installation issues.

Copy link
Contributor

coderabbitai bot commented Nov 1, 2024

📝 Walkthrough
📝 Walkthrough

Walkthrough

This pull request introduces modifications to several Makefile scripts, enhancing the installation processes for various tools by improving architecture handling. A new variable, DARCH, is introduced to accommodate different architectures, particularly converting aarch64 to arm64. This change affects the construction of download URLs for tools like helm-docs, yq, telepresence, kind, and kubectl, ensuring that the correct binaries are fetched based on the system architecture.

Changes

File Change Summary
Makefile.d/helm.mk Added architecture handling for helm-docs and yq; introduced DARCH variable for URL construction.
Makefile.d/k8s.mk Enhanced architecture handling for telepresence; introduced DARCH variable for URL construction.
Makefile.d/kind.mk Defined DARCH for kind/install target; modified curl command to use DARCH for URL construction.
Makefile.d/tools.mk Updated architecture handling for kubectl; introduced DARCH for URL construction.

Possibly related PRs

  • Multi-PF build for example-client image #2713: The changes in this PR introduce a new variable platforms for multi-architecture builds, which aligns with the introduction of the DARCH variable in the main PR for architecture-specific handling in installation processes.

Suggested labels

priority/low, type/refactoring, size/L

Suggested reviewers

  • kmrmt
  • hlts2

📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between e233512 and f117d00.

📒 Files selected for processing (1)
  • Makefile.d/helm.mk (2 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • Makefile.d/helm.mk

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 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.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

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.

@vdaas-ci
Copy link
Collaborator

vdaas-ci commented Nov 1, 2024

[CHATOPS:HELP] ChatOps commands.

  • 🙆‍♀️ /approve - approve
  • 🍱 /format - format codes and add licenses
  • /gen-test - generate test codes
  • 🏷️ /label - add labels
  • 🔚 2️⃣ 🔚 /label actions/e2e-deploy - run E2E deploy & integration test

Copy link
Contributor

@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: 3

🧹 Outside diff range and nitpick comments (1)
Makefile.d/tools.mk (1)

74-78: LGTM! Architecture handling looks correct.

The implementation properly handles the conversion from aarch64 to arm64 for kubectl installation, which aligns with the PR objective.

Consider consolidating the architecture conversion logic since similar conversions exist in other targets (e.g., go/install). You could create a reusable variable at the top of the Makefile:

# At the top of the file or in a common include
NORMALIZED_ARCH := $(subst x86_64,amd64,$(subst aarch64,arm64,$(ARCH)))

# Then use it in the targets
$(BINDIR)/kubectl:
	curl -fsSL "https://dl.k8s.io/release/$(KUBECTL_VERSION)/bin/$(OS)/$(NORMALIZED_ARCH)/kubectl" -o $(BINDIR)/kubectl
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 467ab10 and f15bfc6.

📒 Files selected for processing (4)
  • Makefile.d/helm.mk (2 hunks)
  • Makefile.d/k8s.mk (1 hunks)
  • Makefile.d/kind.mk (1 hunks)
  • Makefile.d/tools.mk (1 hunks)
🔇 Additional comments (6)
Makefile.d/kind.mk (1)

21-26: Verify arm64 binary availability.

The changes assume the availability of arm64 binaries for KinD. Let's verify this assumption.

✅ Verification successful

Let me verify the actual release assets for KinD v0.20.0 to ensure we're using the correct binary name.


arm64 binary availability verified for KinD

The changes are correct. The KinD v0.20.0 release includes the kind-linux-arm64 binary, confirming that the Makefile's arm64 architecture handling is properly implemented. The binary naming convention in the Makefile matches the actual release assets.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the availability of arm64 binaries for the specified KIND_VERSION

# Test: Check if the arm64 binary exists
KIND_VERSION=$(grep "KIND_VERSION" .env 2>/dev/null || echo "0.20.0")
HTTP_CODE=$(curl -s -o /dev/null -w "%{http_code}" \
  "https://github.com/kubernetes-sigs/kind/releases/download/v${KIND_VERSION}/kind-linux-arm64")

if [ "$HTTP_CODE" = "200" ]; then
  echo "✅ arm64 binary is available for KinD v${KIND_VERSION}"
else
  echo "❌ arm64 binary not found for KinD v${KIND_VERSION}"
fi

Length of output: 316


Script:

#!/bin/bash
# Check the actual release assets for KinD v0.20.0
curl -s https://api.github.com/repos/kubernetes-sigs/kind/releases/tags/v0.20.0 | jq -r '.assets[].name'

Length of output: 334

Makefile.d/helm.mk (2)

30-35: LGTM: Architecture handling for helm-docs looks correct.

The architecture conversion from aarch64 to arm64 is properly implemented and matches helm-docs release naming convention.

Let's verify the helm-docs release artifacts naming:

#!/bin/bash
# Description: Verify helm-docs release artifacts naming convention
# Expected: Should show releases containing "arm64" not "aarch64"

curl -s https://api.github.com/repos/norwoodj/helm-docs/releases/latest | \
  grep -i "browser_download_url.*linux.*" | \
  cut -d '"' -f 4

162-168: 🛠️ Refactor suggestion

Simplify architecture handling in yq installation.

While the current implementation works, it can be simplified to improve maintainability and reduce complexity.

Consider this cleaner approach:

 $(BINDIR)/yq:
 	$(eval DARCH :=$(ARCH))
 ifeq ($(ARCH),aarch64)
 	$(eval DARCH = $(shell echo arm64))
 endif
+ifeq ($(DARCH),x86_64)
+	$(eval DARCH = amd64)
+endif
 	mkdir -p $(BINDIR)
 	cd $(TEMP_DIR) \
-	    && curl -fsSL https://github.com/mikefarah/yq/releases/download/$(YQ_VERSION)/yq_$(OS)_$(subst x86_64,amd64,$(shell echo $(DARCH) | tr '[:upper:]' '[:lower:]')) -o $(BINDIR)/yq \
+	    && curl -fsSL https://github.com/mikefarah/yq/releases/download/$(YQ_VERSION)/yq_$(OS)_$(DARCH) -o $(BINDIR)/yq \
 	    && chmod a+x $(BINDIR)/yq

This change:

  1. Handles architecture conversion in a consistent way with helm-docs
  2. Removes nested shell commands
  3. Simplifies the URL construction

Let's verify the yq release artifacts naming:

Makefile.d/tools.mk (1)

74-78: Verify architecture handling in other installation commands.

While the kubectl installation now correctly handles arm64, let's verify if other tools in the Makefile need similar updates for proper arm64 support.

✅ Verification successful

Architecture handling is already consistent across tool installations

The verification shows that architecture handling is already properly implemented across the Makefile:

  • All direct binary downloads (kubectl, telepresence, yq, kind, minikube) consistently handle the aarch64/arm64 conversion
  • The Go installation also handles the architecture conversion correctly
  • Other tools like kube-linter use OS-only downloads or different installation methods
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check architecture handling in other tool installation commands
# Look for direct architecture references or download URLs that might need arm64 support

# Search for architecture-related patterns
echo "Searching for architecture-related patterns..."
rg -n "aarch64|arm64|x86_64|amd64|\$(ARCH)" Makefile.d/

# Search for download URLs that might need architecture handling
echo "Searching for download URLs..."
rg -n "curl.*download|wget.*download" Makefile.d/

Length of output: 3293

Makefile.d/k8s.mk (2)

536-539: LGTM: Architecture conversion logic is correct.

The code correctly handles the conversion of aarch64 to arm64 for telepresence installation. This is a common requirement as some tools use different naming conventions for ARM architectures.


536-542: Verify the telepresence installation across architectures.

The changes look good, but it's important to verify that the installation works correctly across different architectures.

✅ Verification successful

Architecture handling in telepresence installation looks correct

The implementation correctly handles the architecture transformations:

  • Converts aarch64 to arm64 using DARCH variable
  • Transforms x86_64 to amd64 using subst function
  • Properly handles arm64 without modification
  • Ensures lowercase conversion for all architectures using tr '[:upper:]' '[:lower:]'
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify telepresence installation URL construction for different architectures

# Test: Check if the URL is correctly constructed for different architectures
echo "Testing URL construction for different architectures:"
echo "aarch64 -> arm64:"
make -n telepresence/install ARCH=aarch64 | grep "curl.*telepresence"
echo "x86_64 -> amd64:"
make -n telepresence/install ARCH=x86_64 | grep "curl.*telepresence"
echo "arm64 (no conversion needed):"
make -n telepresence/install ARCH=arm64 | grep "curl.*telepresence"

Length of output: 703


Script:

#!/bin/bash
# Let's verify the Makefile content directly to analyze the architecture handling

# First, let's look at the telepresence installation target and its dependencies
echo "=== Checking telepresence installation target ==="
cat Makefile.d/k8s.mk | grep -A 10 "telepresence/install:"

# Let's also check if there are any other architecture-related transformations
echo -e "\n=== Checking other architecture transformations ==="
cat Makefile.d/k8s.mk | grep -B 2 -A 2 "DARCH"

Length of output: 1219

Makefile.d/kind.mk Outdated Show resolved Hide resolved
Makefile.d/kind.mk Show resolved Hide resolved
Makefile.d/k8s.mk Show resolved Hide resolved
@vankichi vankichi force-pushed the bugfix/Makefile/fix-installation-for-arm64 branch from f15bfc6 to b380aae Compare November 1, 2024 05:12
Copy link

cloudflare-workers-and-pages bot commented Nov 1, 2024

Deploying vald with  Cloudflare Pages  Cloudflare Pages

Latest commit: f117d00
Status: ✅  Deploy successful!
Preview URL: https://c4ba00d3.vald.pages.dev
Branch Preview URL: https://bugfix-makefile-fix-installa.vald.pages.dev

View logs

@github-actions github-actions bot added size/S and removed size/S labels Nov 1, 2024
coderabbitai[bot]
coderabbitai bot previously approved these changes Nov 1, 2024
kpango
kpango previously approved these changes Nov 1, 2024
Signed-off-by: vankichi <[email protected]>
@github-actions github-actions bot added size/S and removed size/S labels Nov 1, 2024
coderabbitai[bot]
coderabbitai bot previously approved these changes Nov 1, 2024
Makefile.d/helm.mk Outdated Show resolved Hide resolved
Signed-off-by: vankichi <[email protected]>
@vankichi vankichi requested a review from kmrmt November 1, 2024 06:58
@vankichi vankichi requested a review from kpango November 1, 2024 06:59
@kpango kpango merged commit 25c2220 into main Nov 1, 2024
156 of 161 checks passed
@kpango kpango deleted the bugfix/Makefile/fix-installation-for-arm64 branch November 1, 2024 09:13
vdaas-ci pushed a commit that referenced this pull request Nov 1, 2024
* 🐛 Fix installation command for arm64

Signed-off-by: vankichi <[email protected]>

* 🐛 Fix typo

Signed-off-by: vankichi <[email protected]>

* 🐛 Fix

Signed-off-by: vankichi <[email protected]>

---------

Signed-off-by: vankichi <[email protected]>
kpango pushed a commit that referenced this pull request Nov 1, 2024
* 🐛 Fix installation command for arm64



* 🐛 Fix typo



* 🐛 Fix



---------

Signed-off-by: vankichi <[email protected]>
Co-authored-by: Kiichiro YUKAWA <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants