-
Notifications
You must be signed in to change notification settings - Fork 4.3k
fix: recreate dp was failing due to network restrictions #41264
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
Conversation
WalkthroughReplaces external MongoDB drop via public URL with in-cluster execution using kubectl exec to run mongosh inside the target pod, leveraging APPSMITH_DB_URL. Adds echo logs and comments. Retains subsequent cleanup steps and finalizers in the reset sequence. Changes
Sequence Diagram(s)sequenceDiagram
autonumber
actor Dev as Script Runner
participant Sh as deploy_preview.sh
participant K8s as Kubernetes API
participant Pod as Appsmith Pod
participant Mongo as MongoDB
Dev->>Sh: Run preview reset
Sh->>K8s: kubectl exec into target pod
K8s->>Pod: Start shell session
Note right of Pod: Execute mongosh using APPSMITH_DB_URL
Pod->>Mongo: Drop database
Mongo-->>Pod: Drop result
Pod-->>Sh: Exec exit status
Sh-->>Dev: Echo logs and proceed with remaining cleanup/finalizers
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Poem
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✨ Finishing touches
🧪 Generate unit tests
Tip 👮 Agentic pre-merge checks are now available in preview!Pro plan users can now enable pre-merge checks in their settings to enforce checklists before merging PRs.
Please see the documentation for more information. Example: reviews:
pre_merge_checks:
custom_checks:
- name: "Undocumented Breaking Changes"
mode: "warning"
instructions: |
Pass/fail criteria: All breaking changes to public APIs, CLI flags, environment variables, configuration keys, database schemas, or HTTP/GraphQL endpoints must be documented in the "Breaking Change" section of the PR description and in CHANGELOG.md. Exclude purely internal or private changes (e.g., code not exported from package entry points or explicitly marked as internal). Please share your feedback with us on this Discord post. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pod_name="$(kubectl get pods -n "$NAMESPACE" -o json | jq -r '.items[0].metadata.name')" | ||
# execute this db.dropDatabase() from the k8s cluster because there's network restrictions on Atlas cluster. | ||
# The \$ is used to escape the $ character in the APPSMITH_DB_URL environment variable so it's interpolated inside the kubectl exec command. | ||
kubectl exec "$pod_name" -n "$NAMESPACE" -- bash -c "mongosh \$APPSMITH_DB_URL --eval 'db.dropDatabase()'" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Quote the DB URL before passing it to mongosh
.
APPSMITH_DB_URL
contains multiple &
query parameters. When bash -c
expands the current string, those &
characters background the preceding command and treat the remainder (minPoolSize=...
) as separate shell commands, so mongosh
never executes with the full URL and the drop fails. Wrap the variable in quotes inside the remote command.
- kubectl exec "$pod_name" -n "$NAMESPACE" -- bash -c "mongosh \$APPSMITH_DB_URL --eval 'db.dropDatabase()'"
+ kubectl exec "$pod_name" -n "$NAMESPACE" -- bash -c "mongosh \"\$APPSMITH_DB_URL\" --eval 'db.dropDatabase()'"
🤖 Prompt for AI Agents
In scripts/deploy_preview.sh around line 56, the kubectl exec remote command
passes $APPSMITH_DB_URL unquoted so embedded & characters break the shell; fix
by ensuring the DB URL is quoted inside the remote bash -c string so the entire
URL is delivered as a single argument to mongosh (i.e., wrap the variable in
double quotes inside the inner command and escape those quotes so the remote
shell sees them), leaving the rest of the command unchanged.
This PR has not seen activitiy for a while. It will be closed in 7 days unless further activity is detected. |
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=""
🔍 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?
Summary by CodeRabbit