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(greptimedb-cluster): e2e failed and release cluster chart to ACR failed #185

Merged
merged 3 commits into from
Oct 28, 2024

Conversation

zyy17
Copy link
Collaborator

@zyy17 zyy17 commented Oct 28, 2024

Summary by CodeRabbit

  • New Features
    • Introduced a new optional input parameter for the GitHub Actions workflow to control the release of Helm charts to Azure Container Registry (ACR).
    • Enhanced deployment scripts to manage dependencies and specify chart paths for the greptimedb cluster and operator.
  • Bug Fixes
    • Improved handling of directories in the chart release script to ensure only relevant packaged charts are processed.

Copy link
Contributor

coderabbitai bot commented Oct 28, 2024

Caution

Review failed

The pull request is closed.

Walkthrough

This pull request introduces changes to three scripts and a GitHub Actions workflow. A new input parameter, release-charts-to-acr, is added to the workflow, enabling optional control over releasing Helm charts to Azure Container Registry. Additionally, modifications are made to deployment functions in greptimedb-cluster.sh to handle dependencies and specify chart paths. The release-charts-to-acr.sh script is updated to process chart files directly from the charts directory and refine the handling of packaged chart files.

Changes

File Change Summary
.github/workflows/release.yaml - Added input parameter release-charts-to-acr under workflow_dispatch, default 'false'.
- Added conditional execution for release-charts-to-acr job based on input or push event.
scripts/e2e/greptimedb-cluster.sh - Updated deploy_greptimedb_cluster and deploy_greptimedb_operator functions to specify chart paths.
scripts/release/release-charts-to-acr.sh - Modified directory loop to process files directly in charts directory.
- Updated handling of chart packaging and dependency updates, excluding certain packaged files.

Possibly related PRs

Suggested reviewers

  • daviderli614

Poem

🐰 In the meadow where the charts do play,
A new path for releases has come our way.
With ACR in sight, we hop with glee,
Helm charts in hand, as happy as can be!
So let’s package and push, make it a delight,
For every bunny knows, it’s a wonderful sight! 🌼


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.

@zyy17 zyy17 requested a review from daviderli614 October 28, 2024 06:26
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: 4

🧹 Outside diff range and nitpick comments (6)
scripts/release/release-charts-to-acr.sh (3)

Line range hint 13-18: Verify the repository URL replacement in Chart.yaml.

The sed command hardcodes the OCI registry URL, which differs from the variable $OCI_REGISTRY_URL defined at the top of the script. This could cause issues if the registry URL needs to change.

Apply this diff to use the variable:

-      sed -i 's|https://grafana.github.io/helm-charts|oci://greptime-registry.cn-hangzhou.cr.aliyuncs.com/charts|g' "$dir/Chart.yaml"
+      sed -i "s|https://grafana.github.io/helm-charts|oci://${OCI_REGISTRY_URL}/charts|g" "$dir/Chart.yaml"

Line range hint 28-31: Add error handling for helm push command.

The script should verify the success of the helm push command and handle potential failures.

Apply this diff to add error handling:

     echo "Package $chart_name to $packaged_file and push to oci://$OCI_REGISTRY_URL/$OCI_NAMESPACE/$chart_name ..."

     # Push the packaged chart to the OCI repository, handling the output path.
-    helm push "${packaged_file}" "oci://$OCI_REGISTRY_URL/$OCI_NAMESPACE"
+    if ! helm push "${packaged_file}" "oci://$OCI_REGISTRY_URL/$OCI_NAMESPACE"; then
+      echo "Error: Failed to push chart ${packaged_file} to registry"
+      exit 1
+    fi

Line range hint 1-33: Consider adding script initialization checks and cleanup procedures.

To improve script robustness, consider:

  1. Adding checks for required tools (helm, sed) at script start
  2. Implementing cleanup of temporary packaged files after successful push
  3. Adding a trap handler for cleanup on script interruption

Here's a template for the initialization section:

# Add at the beginning of the script
set -euo pipefail

# Check required tools
command -v helm >/dev/null 2>&1 || { echo "helm is required but not installed"; exit 1; }
command -v sed >/dev/null 2>&1 || { echo "sed is required but not installed"; exit 1; }

# Cleanup function
cleanup() {
    echo "Cleaning up temporary files..."
    find "$CHARTS_DIR" -type f -name "*.tgz" -delete
}

# Set trap
trap cleanup EXIT
.github/workflows/release.yaml (2)

8-12: Consider enhancing the input parameter description.

The description could be more specific to help users understand what "ACR" stands for.

       release-charts-to-acr:
-        description: Release the Helm charts to ACR
+        description: Release the Helm charts to Azure Container Registry (ACR)
         required: false
         default: 'false'

Line range hint 71-73: Improve GitHub Pages deployment wait mechanism.

The current approach of using sleep 300 is not reliable and wastes CI minutes. Consider using GitHub's deployment API to check the actual deployment status.

Replace the sleep with a more robust solution:

-      # TODO(zyy17): Maybe it's not a elegant way to wait for GitHub Pages to update. For many scenarios, waiting for 5 minutes is enough.
-      - name: Wait for deployment of GitHub Pages
-        run: |
-          sleep 300
+      - name: Wait for GitHub Pages deployment
+        uses: actions/github-script@v6
+        with:
+          script: |
+            const owner = context.repo.owner;
+            const repo = context.repo.repo;
+            let deployed = false;
+            
+            while (!deployed) {
+              const deployments = await github.rest.repos.listDeployments({
+                owner,
+                repo,
+                environment: 'github-pages'
+              });
+              
+              if (deployments.data.length > 0) {
+                const status = await github.rest.repos.listDeploymentStatuses({
+                  owner,
+                  repo,
+                  deployment_id: deployments.data[0].id
+                });
+                
+                if (status.data.length > 0 && status.data[0].state === 'success') {
+                  deployed = true;
+                }
+              }
+              
+              if (!deployed) {
+                await new Promise(resolve => setTimeout(resolve, 10000));
+              }
+            }
scripts/e2e/greptimedb-cluster.sh (1)

Line range hint 1-1: Consider improving script robustness with proper error handling.

The script could benefit from these improvements:

  1. Add trap for cleanup on script exit
  2. Clean up port-forwarding output file

Add these lines near the start of the script:

 #!/usr/bin/env bash
 
 set -e
+set -o pipefail
+
+# Ensure cleanup runs on script exit
+trap cleanup EXIT
+
+# Clean up any existing port-forward output file
+rm -f /tmp/connections.out

And update the cleanup function:

 function cleanup() {
   echo "Cleaning up..."
   pkill -f "kubectl port-forward"
+  rm -f /tmp/connections.out
 }
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 29f8a7e and c6d1e30.

📒 Files selected for processing (3)
  • .github/workflows/release.yaml (2 hunks)
  • scripts/e2e/greptimedb-cluster.sh (2 hunks)
  • scripts/release/release-charts-to-acr.sh (2 hunks)
🔇 Additional comments (2)
scripts/release/release-charts-to-acr.sh (1)

7-7: Verify the impact of the directory iteration pattern change.

The change from "$CHARTS_DIR"/*/ to "$CHARTS_DIR"/* means the script will now process all items in the charts directory, not just subdirectories. This could potentially process files that shouldn't be processed.

✅ Verification successful

Directory iteration pattern change is safe

The verification shows that the charts directory contains only three subdirectories (greptimedb-cluster, greptimedb-operator, greptimedb-standalone), each containing a Chart.yaml file. There are no files at the root level that could be incorrectly processed by the new iteration pattern. The change from "$CHARTS_DIR"/*/ to "$CHARTS_DIR"/* is safe in this context.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check for any unexpected files in the charts directory that might be processed
# Expected: Only directories and valid Helm charts

echo "Listing all items in charts directory:"
ls -la charts/

echo -e "\nVerifying all items are valid Helm charts:"
for item in charts/*; do
  if [ -f "$item" ]; then
    echo "WARNING: Found file at root level: $item"
  elif [ -d "$item" ]; then
    if [ ! -f "$item/Chart.yaml" ]; then
      echo "WARNING: Directory without Chart.yaml: $item"
    fi
  fi
done

Length of output: 995

scripts/e2e/greptimedb-cluster.sh (1)

55-58: LGTM: Explicit dependency handling is good.

The addition of explicit dependency handling through Grafana repo addition and dependency building is a good practice that helps prevent deployment failures.

scripts/release/release-charts-to-acr.sh Outdated Show resolved Hide resolved
.github/workflows/release.yaml Show resolved Hide resolved
scripts/e2e/greptimedb-cluster.sh Show resolved Hide resolved
scripts/e2e/greptimedb-cluster.sh Show resolved Hide resolved
@zyy17 zyy17 force-pushed the fix/release-failed branch from c6d1e30 to e69d345 Compare October 28, 2024 06:36
@zyy17 zyy17 merged commit 17ec847 into GreptimeTeam:main Oct 28, 2024
2 checks passed
@zyy17 zyy17 deleted the fix/release-failed branch October 28, 2024 06:38
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