From bde2554782398deec6eaae5fe36b04b5cabb9930 Mon Sep 17 00:00:00 2001 From: Goutham Pratapa Date: Wed, 25 Jun 2025 19:22:07 +0530 Subject: [PATCH] =?UTF-8?q?refactor:=20enhance=20deploy=5Fpreview.sh=20for?= =?UTF-8?q?=20idempotent=20Helm=20repo=20addition=E2=80=A6=20(#41043)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit … and plugin management ### Changes Made - Updated Helm repo addition to be idempotent, preventing errors if the repo is already added. - Added logic to check for the existence of the mapkubeapis plugin before attempting installation, improving script robustness. - Enhanced error handling for optional commands to ensure the deployment process continues smoothly even if certain steps fail. These improvements streamline the deployment process and enhance the reliability of the script. ## Description > [!TIP] > _Add a TL;DR when the description is longer than 500 words or extremely technical (helps the content, marketing, and DevRel team)._ > > _Please also include relevant motivation and context. List any dependencies that are required for this change. Add links to Notion, Figma or any other documents that might be relevant to the PR._ Fixes #`Issue Number` _or_ Fixes `Issue URL` > [!WARNING] > _If no issue exists, please create an issue first, and check with the maintainers if the issue is valid._ ## Automation /ok-to-test tags="" ### :mag: Cypress test results > [!CAUTION] > If you modify the content in this section, you are likely to disrupt the CI result for your PR. ## Communication Should the DevRel and Marketing teams inform users about this change? - [ ] Yes - [ ] No --- scripts/deploy_preview.sh | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/scripts/deploy_preview.sh b/scripts/deploy_preview.sh index 31cafef1bb..26cdd33124 100755 --- a/scripts/deploy_preview.sh +++ b/scripts/deploy_preview.sh @@ -66,12 +66,24 @@ kubectl create secret docker-registry "$SECRET" \ --docker-password="$DOCKER_HUB_ACCESS_TOKEN" \ -n "$NAMESPACE" || true -# Add Helm repo and deploy -AWS_REGION=us-east-2 helm repo add appsmith-ee "$HELMCHART_URL" +# Add Helm repo (idempotent) +AWS_REGION=us-east-2 helm repo add appsmith-ee "$HELMCHART_URL" || echo "Helm repo already added." helm repo update -helm plugin install https://github.com/helm/helm-mapkubeapis -n "$NAMESPACE" || true -helm mapkubeapis "$CHARTNAME" -n "$NAMESPACE" -helm show chart appsmith-ee/$HELMCHART + +# Attempt to install the plugin only if it's not installed +if ! helm plugin list | grep -q mapkubeapis; then + echo "Installing mapkubeapis plugin..." + helm plugin install https://github.com/helm/helm-mapkubeapis || echo "Plugin installation failed, continuing..." +else + echo "mapkubeapis plugin already installed." +fi + +# Run mapkubeapis (safe to fail) +echo "Running helm mapkubeapis (optional)..." +helm mapkubeapis "$CHARTNAME" -n "$NAMESPACE" || echo "mapkubeapis failed, continuing..." + +# Show chart metadata +helm show chart appsmith-ee/$HELMCHART || echo "helm show chart failed (non-blocking)." echo "Deploying Appsmith Helm chart..." helm upgrade -i "$CHARTNAME" "appsmith-ee/$HELMCHART" -n "$NAMESPACE" --create-namespace --recreate-pods \