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

Backport PR #2729 to release/v1.7 for Fix installation command for arm64 #2730

Conversation

vdaas-ci
Copy link
Collaborator

@vdaas-ci vdaas-ci 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.

* 🐛 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]>
Copy link

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

Deploying vald with  Cloudflare Pages  Cloudflare Pages

Latest commit: 659e1ef
Status: ✅  Deploy successful!
Preview URL: https://032f683e.vald.pages.dev
Branch Preview URL: https://backport-release-v1-7-bugfix-ja1q.vald.pages.dev

View logs

Copy link
Contributor

coderabbitai bot commented Nov 1, 2024

📝 Walkthrough

Walkthrough

The changes in this pull request involve modifications to several Makefiles to improve the installation processes for various tools, including helm-docs, yq, telepresence, kubectl, and KinD. A new variable, DARCH, is introduced across these files to replace occurrences of the architecture string aarch64 with arm64. This adjustment ensures that the correct architecture is used in download URLs, enhancing compatibility with different systems while maintaining the existing logic and structure of the Makefiles.

Changes

File Change Summary
Makefile.d/helm.mk Introduced DARCH variable to replace aarch64 with arm64 for helm-docs installation; updated download command accordingly.
Makefile.d/k8s.mk Added DARCH variable for telepresence installation; modified curl command to use DARCH instead of ARCH. Minor formatting adjustments made.
Makefile.d/kind.mk Updated architecture handling for KinD installation by replacing ARCH with DARCH in the download URL.
Makefile.d/tools.mk Introduced DARCH for kubectl installation to replace aarch64 with arm64 in the download URL construction.

Possibly related PRs

  • Fix installation command for arm64 #2729: This PR directly modifies the Makefile.d/helm.mk and related files to enhance the installation processes for helm-docs and yq by introducing architecture-specific handling, which aligns with the changes made in the main PR.

Suggested labels

type/bug, priority/medium, size/M, area/makefile, actions/backport/release/v1.7

Suggested reviewers

  • vankichi
  • kpango

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 Author

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: 2

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

74-75: LGTM! Architecture normalization looks good.

The changes correctly handle architecture name normalization for kubectl installation:

  • Converts aarch64 to arm64 using DARCH variable
  • Ensures consistent architecture naming in download URLs (x86_64 → amd64)
  • Maintains lowercase naming convention

Consider extracting the architecture normalization logic into a reusable variable at the top of the Makefile since similar patterns exist in other targets (e.g., go/install). This would improve maintainability:

# Add at the top of the file
NORMALIZED_ARCH := $(shell echo $(subst x86_64,amd64,$(subst aarch64,arm64,$(ARCH))) | tr '[:upper:]' '[:lower:]')

Then use $(NORMALIZED_ARCH) consistently across all download URLs.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between b8983ce and 659e1ef.

📒 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 (5)
Makefile.d/kind.mk (1)

22-23: LGTM: Architecture handling is correctly implemented.

The introduction of DARCH variable and the architecture substitution logic properly handles the conversion from aarch64 to arm64, fixing the installation command for ARM architectures while maintaining compatibility with other architectures.

Makefile.d/helm.mk (2)

31-32: LGTM: Correct architecture handling for helm-docs installation

The introduction of DARCH variable properly handles the architecture naming conversion from aarch64 to arm64, ensuring compatibility with helm-docs releases.


31-32: Verify architecture handling across all Makefiles

Let's verify if similar architecture conversion changes are needed in other Makefiles for consistency.

Also applies to: 160-160, 162-162

✅ Verification successful

Based on the search results, I can now provide a conclusive response about the architecture handling across the Makefiles:

Architecture handling is consistently implemented across Makefiles

The codebase already follows a consistent pattern for architecture handling:

  • All relevant Makefiles (helm.mk, tools.mk, minikube.mk, kind.mk, k8s.mk) use the same architecture conversion approach
  • The pattern $(subst aarch64,arm64,$(ARCH)) is consistently used where needed
  • Architecture-specific downloads properly handle both x86_64->amd64 and aarch64->arm64 conversions
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for other Makefiles that might need similar architecture handling updates

# Look for architecture-related patterns in Makefiles
echo "Searching for architecture-related patterns in Makefiles..."
rg -t make "aarch64|arm64|x86_64|amd64" .

# Look for download URLs in Makefiles that might need architecture handling
echo "Searching for download URLs that might need architecture handling..."
rg -t make "curl.*download.*\$(ARCH)" .

Length of output: 2087

Makefile.d/tools.mk (1)

74-75: Verify architecture handling consistency across Makefiles.

Let's ensure similar architecture normalization is applied consistently across all related Makefiles.

✅ Verification successful

Architecture normalization is consistently implemented across Makefiles

The verification shows consistent architecture handling patterns across the relevant Makefiles:

  • tools.mk, kind.mk, helm.mk, and k8s.mk all implement the same DARCH variable with identical subst aarch64,arm64,$(ARCH) normalization
  • The changes align with the PR objectives of fixing installation commands for arm64 architecture
  • The implementation is uniform across the build system, ensuring consistent architecture handling
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check architecture handling in other Makefiles
# Expected: Similar DARCH variable usage or architecture normalization

echo "Checking architecture handling patterns in Makefiles:"
rg -l "aarch64|arm64|x86_64|amd64" "Makefile.d/"

echo -e "\nChecking specific architecture conversion patterns:"
rg "subst.*aarch64.*arm64" "Makefile.d/"

Length of output: 923

Makefile.d/k8s.mk (1)

537-537: LGTM! Architecture string normalization looks good.

The changes correctly handle architecture string normalization by:

  1. Converting aarch64 to arm64
  2. Converting x86_64 to amd64
  3. Ensuring consistent lowercase architecture strings

This fix ensures the telepresence installation works correctly across different architectures.

Also applies to: 539-539

Comment on lines +22 to +23
$(eval DARCH := $(subst aarch64,arm64,$(ARCH)))
curl -fsSL https://github.com/kubernetes-sigs/kind/releases/download/v$(KIND_VERSION)/kind-$(OS)-$(subst x86_64,amd64,$(shell echo $(DARCH) | tr '[:upper:]' '[:lower:]')) -o $(BINDIR)/kind
Copy link
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Consider improving readability of the download command.

The current implementation works correctly but could be more maintainable. Consider breaking down the architecture transformations into separate variables.

Here's a suggested refactor:

-	$(eval DARCH := $(subst aarch64,arm64,$(ARCH)))
-	curl -fsSL https://github.com/kubernetes-sigs/kind/releases/download/v$(KIND_VERSION)/kind-$(OS)-$(subst x86_64,amd64,$(shell echo $(DARCH) | tr '[:upper:]' '[:lower:]')) -o $(BINDIR)/kind
+	$(eval DARCH := $(subst aarch64,arm64,$(ARCH)))
+	$(eval NORMALIZED_ARCH := $(subst x86_64,amd64,$(shell echo $(DARCH) | tr '[:upper:]' '[:lower:]')))
+	curl -fsSL https://github.com/kubernetes-sigs/kind/releases/download/v$(KIND_VERSION)/kind-$(OS)-$(NORMALIZED_ARCH) -o $(BINDIR)/kind

This change:

  1. Separates architecture normalization into a dedicated variable
  2. Makes the curl command more readable
  3. Maintains the same functionality while being easier to maintain
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
$(eval DARCH := $(subst aarch64,arm64,$(ARCH)))
curl -fsSL https://github.com/kubernetes-sigs/kind/releases/download/v$(KIND_VERSION)/kind-$(OS)-$(subst x86_64,amd64,$(shell echo $(DARCH) | tr '[:upper:]' '[:lower:]')) -o $(BINDIR)/kind
$(eval DARCH := $(subst aarch64,arm64,$(ARCH)))
$(eval NORMALIZED_ARCH := $(subst x86_64,amd64,$(shell echo $(DARCH) | tr '[:upper:]' '[:lower:]')))
curl -fsSL https://github.com/kubernetes-sigs/kind/releases/download/v$(KIND_VERSION)/kind-$(OS)-$(NORMALIZED_ARCH) -o $(BINDIR)/kind

@@ -156,8 +157,9 @@ yq/install: $(BINDIR)/yq

$(BINDIR)/yq:
mkdir -p $(BINDIR)
$(eval DARCH := $(subst aarch64,arm64,$(ARCH)))
Copy link
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Consider standardizing architecture name conversions

While the current implementation works correctly, the architecture name conversions are handled differently between helm-docs and yq installations. Consider standardizing this approach for better maintainability.

You could extract the architecture conversions into a reusable variable at the top of the Makefile:

+ # Architecture name mappings
+ NORMALIZED_ARCH := $(subst x86_64,amd64,$(subst aarch64,arm64,$(ARCH)))

- $(eval DARCH := $(subst aarch64,arm64,$(ARCH)))
- && 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)_$(shell echo $(NORMALIZED_ARCH) | tr '[:upper:]' '[:lower:]') -o $(BINDIR)/yq \

This would:

  1. Centralize architecture name mappings
  2. Reduce redundancy
  3. Make future architecture additions easier to manage

Also applies to: 162-162

@kpango kpango merged commit dc10b82 into release/v1.7 Nov 1, 2024
156 of 163 checks passed
@kpango kpango deleted the backport/release/v1.7/bugfix/Makefile/fix-installation-for-arm64 branch November 1, 2024 17:06
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.

3 participants