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

AKS/EKS using Longhorn repo Manifests: Deploy MinIO/NFS for Backup Store Creation #2188

Merged
merged 3 commits into from
Dec 15, 2024

Conversation

roger-ryao
Copy link
Contributor

@roger-ryao roger-ryao commented Dec 11, 2024

Which issue(s) this PR fixes:

longhorn/longhorn#9955

What this PR does / why we need it:

This is to address the issues affecting the AKS and EKS Jenkins jobs after the merge of 39e61f5.

Special notes for your reviewer:

@yangchiu

Additional documentation or context

#2173

Summary by CodeRabbit

  • New Features
    • Introduced a new function for installing backup stores from the Longhorn repository, enhancing compatibility with different Kubernetes distributions.
  • Bug Fixes
    • Improved conditional logic for backup store installation based on Kubernetes distribution, ensuring the correct function is called.
    • Corrected a typo in the backup store function name for consistency and clarity.

@roger-ryao roger-ryao self-assigned this Dec 11, 2024
@roger-ryao roger-ryao requested a review from a team as a code owner December 11, 2024 13:49
Copy link

coderabbitai bot commented Dec 11, 2024

Walkthrough

The pull request modifies the longhorn-setup.sh script by adding a new function, install_backupstores_from_lh_repo, which installs backup stores from the Longhorn repository. This function creates Kubernetes resources for various backup stores based on the Kubernetes distribution specified. The main function now conditionally calls either the new function or the existing install_backupstores function, depending on whether the distribution is "eks" or "aks". Additionally, a typo in the function name has been corrected. The overall control flow and error handling of the script remain unchanged.

Changes

File Change Summary
test_framework/scripts/longhorn-setup.sh - Added function install_backupstores_from_lh_repo() for installing backup stores from Longhorn repository.
- Updated main function to conditionally call the new function based on TF_VAR_k8s_distro_name.
- Corrected function name from setup_azuitize_backup_store() to setup_azurite_backup_store().
pipelines/utilities/install_backupstores.sh - Corrected function name from setup_azuitize_backup_store() to setup_azurite_backup_store() in both declaration and invocation.

Possibly related PRs

Suggested reviewers

  • yangchiu

Poem

🐰 In the script where bunnies hop,
A new function makes the backup stop.
For EKS and AKS, it finds its way,
Installing stores, come what may!
With Longhorn's help, we cheer and play! 🎉


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. (Experiment)
  • @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.

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

🧹 Outside diff range and nitpick comments (1)
test_framework/scripts/longhorn-setup.sh (1)

572-576: Improve code readability and documentation.

The conditional logic for AKS/EKS needs better documentation and consistent indentation.

-      if [[ "${TF_VAR_k8s_distro_name}" == "eks" || "${TF_VAR_k8s_distro_name}" == "aks" ]]; then
-          install_backupstores_from_lh_repo
-      else
-          install_backupstores
-      fi
+    # AKS/EKS require backup store manifests from the main Longhorn repo
+    # due to differences in storage provisioning and networking
+    if [[ "${TF_VAR_k8s_distro_name}" == "eks" || "${TF_VAR_k8s_distro_name}" == "aks" ]]; then
+        install_backupstores_from_lh_repo
+    else
+        install_backupstores
+    fi
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between caaa648 and 0646ae6.

📒 Files selected for processing (1)
  • test_framework/scripts/longhorn-setup.sh (2 hunks)
🔇 Additional comments (1)
test_framework/scripts/longhorn-setup.sh (1)

572-576: Verify changes don't impact other distributions.

Let's verify that these changes only affect AKS/EKS and don't impact other distributions.

✅ Verification successful

Changes are safe and properly handle distribution-specific requirements

The verification shows that:

  1. The only difference between install_backupstores() and install_backupstores_from_lh_repo() is the source URL path (longhorn-tests vs longhorn repo), but they install the same components.
  2. The distribution-specific logic is consistently applied across multiple files, showing AKS/EKS are handled specially in various scenarios.
  3. Other distributions (rke, rke2, k3s) continue to use their existing paths unaffected by this change.
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check if the backup store installation changes affect other distributions

# Test 1: Check for any direct references to the old backup store URLs in other files
echo "Checking for references to old backup store URLs..."
rg -l "longhorn-tests/master/manager/integration/deploy/backupstores" --type bash

# Test 2: Check for any other conditional logic based on k8s distribution
echo "Checking for other k8s distribution-specific logic..."
rg "TF_VAR_k8s_distro_name.*==" --type bash

Length of output: 415


Script:

#!/bin/bash
# Let's try without the --type bash flag since it's not recognized
# and use more specific search patterns

# Check for references to old backup store URLs
echo "Checking for references to old backup store URLs..."
rg "longhorn-tests/master/manager/integration/deploy/backupstores"

# Check for k8s distribution-specific logic
echo "Checking for k8s distribution-specific logic..."
rg "TF_VAR_k8s_distro_name.*=="

# Let's also check the implementation of both backup store installation functions
echo "Checking backup store installation functions..."
rg -A 10 "install_backupstores\(\)" 
rg -A 10 "install_backupstores_from_lh_repo\(\)"

Length of output: 8989

Comment on lines 347 to 357
install_backupstores_from_lh_repo(){
MINIO_BACKUPSTORE_URL="https://raw.githubusercontent.com/longhorn/longhorn/master/deploy/backupstores/minio-backupstore.yaml"
NFS_BACKUPSTORE_URL="https://raw.githubusercontent.com/longhorn/longhorn/master/deploy/backupstores/nfs-backupstore.yaml"
CIFS_BACKUPSTORE_URL="https://raw.githubusercontent.com/longhorn/longhorn/master/deploy/backupstores/cifs-backupstore.yaml"
AZURITE_BACKUPSTORE_URL="https://raw.githubusercontent.com/longhorn/longhorn/master/deploy/backupstores/azurite-backupstore.yaml"
kubectl create -f ${MINIO_BACKUPSTORE_URL} \
-f ${NFS_BACKUPSTORE_URL} \
-f ${CIFS_BACKUPSTORE_URL} \
-f ${AZURITE_BACKUPSTORE_URL}
setup_azuitize_backup_store
}
Copy link

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Consider refactoring to eliminate code duplication.

The new function is almost identical to install_backupstores. Consider refactoring both functions to use a common implementation with configurable base URLs.

-install_backupstores_from_lh_repo(){
-  MINIO_BACKUPSTORE_URL="https://raw.githubusercontent.com/longhorn/longhorn/master/deploy/backupstores/minio-backupstore.yaml"
-  NFS_BACKUPSTORE_URL="https://raw.githubusercontent.com/longhorn/longhorn/master/deploy/backupstores/nfs-backupstore.yaml"
-  CIFS_BACKUPSTORE_URL="https://raw.githubusercontent.com/longhorn/longhorn/master/deploy/backupstores/cifs-backupstore.yaml"
-  AZURITE_BACKUPSTORE_URL="https://raw.githubusercontent.com/longhorn/longhorn/master/deploy/backupstores/azurite-backupstore.yaml"
-  kubectl create -f ${MINIO_BACKUPSTORE_URL} \
-                 -f ${NFS_BACKUPSTORE_URL} \
-                 -f ${CIFS_BACKUPSTORE_URL} \
-                 -f ${AZURITE_BACKUPSTORE_URL}
-  setup_azuitize_backup_store
-}

+install_backupstores() {
+  local base_url="${1:-https://raw.githubusercontent.com/longhorn/longhorn-tests/master/manager/integration/deploy/backupstores}"
+  
+  # Use arrays for better maintainability
+  local manifests=(
+    "minio-backupstore.yaml"
+    "nfs-backupstore.yaml" 
+    "cifs-backupstore.yaml"
+    "azurite-backupstore.yaml"
+  )
+  
+  local kubectl_args=""
+  for manifest in "${manifests[@]}"; do
+    kubectl_args="${kubectl_args} -f ${base_url}/${manifest}"
+  done
+
+  if ! kubectl create ${kubectl_args}; then
+    echo "Error: Failed to create backup stores"
+    return 1
+  fi
+
+  setup_azuitize_backup_store
+}
+
+# Wrapper for backward compatibility
+install_backupstores_from_lh_repo() {
+  install_backupstores "https://raw.githubusercontent.com/longhorn/longhorn/master/deploy/backupstores"
+}
📝 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
install_backupstores_from_lh_repo(){
MINIO_BACKUPSTORE_URL="https://raw.githubusercontent.com/longhorn/longhorn/master/deploy/backupstores/minio-backupstore.yaml"
NFS_BACKUPSTORE_URL="https://raw.githubusercontent.com/longhorn/longhorn/master/deploy/backupstores/nfs-backupstore.yaml"
CIFS_BACKUPSTORE_URL="https://raw.githubusercontent.com/longhorn/longhorn/master/deploy/backupstores/cifs-backupstore.yaml"
AZURITE_BACKUPSTORE_URL="https://raw.githubusercontent.com/longhorn/longhorn/master/deploy/backupstores/azurite-backupstore.yaml"
kubectl create -f ${MINIO_BACKUPSTORE_URL} \
-f ${NFS_BACKUPSTORE_URL} \
-f ${CIFS_BACKUPSTORE_URL} \
-f ${AZURITE_BACKUPSTORE_URL}
setup_azuitize_backup_store
}
install_backupstores() {
local base_url="${1:-https://raw.githubusercontent.com/longhorn/longhorn-tests/master/manager/integration/deploy/backupstores}"
# Use arrays for better maintainability
local manifests=(
"minio-backupstore.yaml"
"nfs-backupstore.yaml"
"cifs-backupstore.yaml"
"azurite-backupstore.yaml"
)
local kubectl_args=""
for manifest in "${manifests[@]}"; do
kubectl_args="${kubectl_args} -f ${base_url}/${manifest}"
done
if ! kubectl create ${kubectl_args}; then
echo "Error: Failed to create backup stores"
return 1
fi
setup_azuitize_backup_store
}
# Wrapper for backward compatibility
install_backupstores_from_lh_repo() {
install_backupstores "https://raw.githubusercontent.com/longhorn/longhorn/master/deploy/backupstores"
}

Copy link
Member

@yangchiu yangchiu left a comment

Choose a reason for hiding this comment

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

What about GKE? Does GKE support deploy backup stores on the control plane?

test_framework/scripts/longhorn-setup.sh Outdated Show resolved Hide resolved
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

🧹 Outside diff range and nitpick comments (1)
test_framework/scripts/longhorn-setup.sh (1)

572-576: Fix indentation for consistency.

The indentation of this conditional block is inconsistent with the surrounding code. Consider adjusting the indentation to match the parent if block's style.

-      if [[ "${TF_VAR_k8s_distro_name}" == "eks" || "${TF_VAR_k8s_distro_name}" == "aks" ]]; then
-          install_backupstores_from_lh_repo
-      else
-          install_backupstores
-      fi
+    if [[ "${TF_VAR_k8s_distro_name}" == "eks" || "${TF_VAR_k8s_distro_name}" == "aks" ]]; then
+      install_backupstores_from_lh_repo
+    else
+      install_backupstores
+    fi
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 0646ae6 and 0088559.

📒 Files selected for processing (2)
  • pipelines/utilities/install_backupstores.sh (1 hunks)
  • test_framework/scripts/longhorn-setup.sh (2 hunks)
🔇 Additional comments (3)
pipelines/utilities/install_backupstores.sh (2)

10-10: LGTM: Function name corrected.

The typo in the function name has been fixed from setup_azuitize_backup_store to setup_azurite_backup_store.


13-13: LGTM: Function declaration updated.

The function declaration has been correctly renamed from setup_azuitize_backup_store to setup_azurite_backup_store.

test_framework/scripts/longhorn-setup.sh (1)

347-357: 🛠️ Refactor suggestion

Consider refactoring to eliminate code duplication.

The new function install_backupstores_from_lh_repo is nearly identical to install_backupstores, with the only difference being the source URLs. Consider refactoring both functions to use a common implementation with configurable base URLs.

@roger-ryao
Copy link
Contributor Author

What about GKE? Does GKE support deploy backup stores on the control plane?

GKE has its own independent longhorn-setup.sh, so I didn't update it initially.
You can refer the script here: https://github.com/longhorn/longhorn-tests/blob/master/pipelines/gke/scripts/longhorn-setup.sh#L141-L146

@roger-ryao roger-ryao requested review from yangchiu and a team December 13, 2024 02:18
Copy link
Member

@yangchiu yangchiu left a comment

Choose a reason for hiding this comment

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

LGTM

@yangchiu yangchiu merged commit c8516c1 into longhorn:master Dec 15, 2024
6 of 7 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