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: use password while creating extension #36936

Merged
merged 1 commit into from
Oct 17, 2024
Merged

Conversation

AnaghHegde
Copy link
Member

Description

Use password while creating pg_trm extension on remote postgres.

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?

  • Yes
  • No

@AnaghHegde AnaghHegde self-assigned this Oct 17, 2024
@AnaghHegde AnaghHegde requested a review from abhvsn October 17, 2024 09:53
@github-actions github-actions bot added the Bug Something isn't working label Oct 17, 2024
Copy link
Contributor

coderabbitai bot commented Oct 17, 2024

Warning

.coderabbit.yaml has a parsing error

The CodeRabbit configuration file in this repository has a parsing error and default settings were used instead. Please fix the error(s) in the configuration file. You can initialize chat with CodeRabbit to get help with the configuration file.

💥 Parsing errors (1)
bad indentation of a mapping entry in ".coderabbit.yaml" (4:229)

 1 |  ... 
 2 |  ... 
 3 |  ... 
 4 |  ...  in a concise fashion. You don't elaborate unless specifically  ...
-----------------------------------------^
 5 |  ... 
 6 |  ... 
⚙️ Configuration instructions
  • 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
📝 Walkthrough

Walkthrough

The changes in this pull request involve modifications to the pg-utils.sh script, focusing on PostgreSQL database initialization and connection handling. The waitForPostgresAvailability function remains mostly unchanged, while the init_pg_db function has been updated to validate the PostgreSQL connection string, create the database and schema if necessary, and handle both local and remote PostgreSQL instances. Enhanced logging and user context management for the pg_trgm extension are also included.

Changes

File Path Change Summary
deploy/docker/fs/opt/appsmith/pg-utils.sh Modifications to waitForPostgresAvailability and init_pg_db functions for better connection handling, validation, and logging. Added support for remote PostgreSQL servers using PGPASSWORD. Updated command execution context for pg_trgm extension creation.

Possibly related PRs

Suggested labels

skip-changelog, ok-to-test

Suggested reviewers

  • abhvsn

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.

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

🧹 Outside diff range and nitpick comments (2)
deploy/docker/fs/opt/appsmith/pg-utils.sh (2)

Line range hint 70-106: Improved database initialization logic looks good.

The changes to the init_pg_db function enhance its robustness by checking for the existence of the database, schema, and user before creating them. The differentiation between local and remote PostgreSQL instances is also well-implemented.

Consider adding error checks after each psql command to ensure that the operations were successful. For example:

if ! psql -h "$PG_DB_HOST" -p "$PG_DB_PORT" -U postgres -d "postgres" -c "CREATE DATABASE $PG_DB_NAME;"; then
    echo "Failed to create database $PG_DB_NAME"
    exit 1
fi

This will help catch and report any issues during the initialization process.


137-140: Good addition of pg_trgm extension, but consider security and error handling.

The addition of the pg_trgm extension is beneficial for text search functionality. However, there are two points to consider:

  1. Security: Using PGPASSWORD in the command line can expose the password in process lists. Consider using a .pgpass file or connection service file for more secure authentication.

  2. Error Handling: Add error checking for the extension creation. For example:

if ! PGPASSWORD=$PG_DB_PASSWORD psql -h "$PG_DB_HOST" -p "$PG_DB_PORT" -U "$PG_DB_USER" -d "$PG_DB_NAME" -c "CREATE EXTENSION IF NOT EXISTS pg_trgm;"; then
    echo "Failed to create pg_trgm extension"
    exit 1
fi

This ensures that any issues during extension creation are caught and reported.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 765b1b3 and 9fc6f37.

📒 Files selected for processing (1)
  • deploy/docker/fs/opt/appsmith/pg-utils.sh (1 hunks)
🧰 Additional context used

@abhvsn abhvsn merged commit 44a9994 into release Oct 17, 2024
16 checks passed
@abhvsn abhvsn deleted the fix/password-pg-remote branch October 17, 2024 10:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants