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

resolve [Bug]: Duplicate setting up of custom CA certificates #32417 #36871

Closed
wants to merge 5 commits into from

Conversation

Rudraksh2003
Copy link

@Rudraksh2003 Rudraksh2003 commented Oct 14, 2024

#32417

Description

Tip

This PR removes redundant loading of custom CA certificates in the entrypoint.sh script and includes a backup of the original script for reference. We want to avoid writing to the root file system unnecessarily, so the check_setup_custom_ca_certificates function has been removed, and the setup-custom-ca-certificates function will be used moving forward.

Motivation: Removing this redundancy improves security and maintainability by ensuring we don't write to the OS's trust store inappropriately. It also simplifies the code.

Fixes #32417

Changes:

  1. Removed redundant function: Removed the check_setup_custom_ca_certificates function.
  2. Retained the second function: Kept the setup-custom-ca-certificates function to handle custom CA certificates properly.
  3. Backup of entrypoint.sh: Created a backup of the original entrypoint.sh file as entrypoint.sh.bak.

No dependencies required for this change.
Links to documentation:

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

#32417

Summary by CodeRabbit

  • New Features

    • Enhanced setup for custom CA certificates, improving security and configuration.
    • Improved initialization processes for MongoDB and PostgreSQL, ensuring more robust database connections.
    • Added logging and error handling for better troubleshooting.
  • Bug Fixes

    • Resolved issues related to Redis compatibility checks.
  • Documentation

    • Updated export section to include the new ENV_PATH constant for better configuration management.

Copy link
Contributor

coderabbitai bot commented Oct 14, 2024

Walkthrough

The pull request modifies the entrypoint.sh script for the Appsmith application, focusing on the setup and initialization processes. It removes the deprecated check_setup_custom_ca_certificates function and introduces setup-custom-ca-certificates, which improves custom CA certificate handling. Additionally, the script enhances environment setup, database initialization, and error handling, particularly for MongoDB and PostgreSQL. A new constant, ENV_PATH, is added to constants.js, ensuring better configuration management.

Changes

File Path Change Summary
deploy/docker/fs/opt/appsmith/entrypoint.sh Removed check_setup_custom_ca_certificates, added setup-custom-ca-certificates, and numerous other functions for improved initialization and error handling.
deploy/docker/fs/opt/appsmith/utils/bin/constants.js Added ENV_PATH constant and ensured a newline at the end of the file.

Assessment against linked issues

Objective Addressed Explanation
Remove check_setup_custom_ca_certificates function (32417)

Possibly related PRs

Suggested labels

skip-changelog, ok-to-test

Suggested reviewers

  • sharat87
  • pratapaprasanna
  • abhvsn
  • AnaghHegde

🌟 In the land of code where functions play,
A script was polished, brightening the way.
Custom certs now handled with care,
Mongo and Postgres, a robust affair.
With constants added, the flow is clear,
In the realm of Appsmith, we cheer! 🎉


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

🧹 Outside diff range and nitpick comments (3)
deploy/docker/fs/opt/appsmith/entrypoint.sh (1)

Line range hint 310-310: Typographical Error in Logging Statement

There's a small typographical error in the tlog statement within the setup-custom-ca-certificates function. You've added an extra period at the end of the string, which might result in unnecessary punctuation in the logs. Let's correct this to maintain clear and professional log messages.

Apply this diff to fix the typo:

     if [[ -n "$(ls "$stacks_ca_certs_path"/*.pem 2>/dev/null)" ]]; then
-      tlog "Looks like you have some '.pem' files in your 'ca-certs' folder. Please rename them to '.crt' to be picked up automatically.".
+      tlog "Looks like you have some '.pem' files in your 'ca-certs' folder. Please rename them to '.crt' to be picked up automatically."
     fi
deploy/docker/fs/opt/appsmith/entrypoint.sh.bak (2)

151-153: Use [[ -n ]] instead of [[ ! -z ]] for string non-emptiness checks

In the setup_backend_heap_arg function (lines 151-153), it's more conventional and readable in Bash scripting to use [[ -n ${maximum_heap} ]] when checking if a string is not empty, rather than [[ ! -z ${maximum_heap} ]].

Apply this change:

- if [[ ! -z ${maximum_heap} ]]; then
+ if [[ -n ${maximum_heap} ]]; then
      export APPSMITH_JAVA_HEAP_ARG="-Xmx${maximum_heap}m"
  fi

159-172: Correct typos in comments for clarity

There are typos in the comments between lines 159 and 172:

  • Line 159: "# Check for enviroment vairalbes" should be "# Check for environment variables".
  • Lines 161, 165, 170: "If this field is empty is might cause application crash" should be "If this field is empty, it might cause an application crash".

Correcting these typos will improve the readability and professionalism of the code.

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between ee6178b and b92dbab.

📒 Files selected for processing (3)
  • deploy/docker/fs/opt/appsmith/entrypoint.sh (1 hunks)
  • deploy/docker/fs/opt/appsmith/entrypoint.sh.bak (1 hunks)
  • deploy/docker/fs/opt/appsmith/utils/bin/constants.js (1 hunks)
🧰 Additional context used
🔇 Additional comments (6)
deploy/docker/fs/opt/appsmith/utils/bin/constants.js (3)

Line range hint 7-7: Class, let's examine the new constant on the board!

Alright, students, we have a new addition to our constants family. The ENV_PATH is joining us today, pointing to "/appsmith-stacks/configuration/docker.env". This path seems to be where our Docker environment configuration will reside. Remember, clear and descriptive constants like this make our code more readable and maintainable. Good job!


29-29: Pop quiz: What's new in our exports?

Can anyone spot the change in our module.exports? That's right, we've added ENV_PATH to the list! This is crucial, class. By exporting this constant, we're making it available for other parts of our application to use. It's like sharing our knowledge with the rest of the school!


Line range hint 1-29: Class dismissed with a gold star!

Excellent work on this file, dear students! The addition of the ENV_PATH constant and its proper export align perfectly with our lesson plan (PR objectives) of improving configuration management. This change will help our school (application) run more smoothly by providing a clear path to our Docker environment configuration. Keep up the good work!

deploy/docker/fs/opt/appsmith/entrypoint.sh (2)

495-495: Well Done Incorporating the New Function Call

Excellent job adding the call to setup-custom-ca-certificates! This ensures that custom CA certificates are properly configured during the application's startup process. Keep up the good work in maintaining clean and efficient code.


Line range hint 1-600: Let's Verify the Removal of Deprecated Function References

It's important to ensure that all references to the deprecated check_setup_custom_ca_certificates function are fully removed from the codebase. This will help prevent any unintended calls to a non-existent function, which could cause runtime errors.

Please run the following script to check for any remaining references:

✅ Verification successful

Great effort in running the initial search! It looks like we encountered an issue with the file type specification. Let’s adjust the command to correctly target shell scripts and ensure we thoroughly check for any lingering references.

[/run_scripts]


Fantastic effort so far! It appears we need to adjust our search approach to thoroughly check for any lingering references to the deprecated check_setup_custom_ca_certificates function. Let's refine our command to ensure we examine all shell scripts effectively.

[/run_scripts]


✅ Verified: No References to check_setup_custom_ca_certificates Found

Excellent job! I've confirmed that there are no remaining references to the deprecated check_setup_custom_ca_certificates function in the codebase. This ensures that there will be no unintended runtime errors related to this function.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Search the codebase for any residual references to `check_setup_custom_ca_certificates`.

rg --type shell 'check_setup_custom_ca_certificates'

Length of output: 82


Script:

#!/bin/bash
# Description: Search the codebase for any residual references to `check_setup_custom_ca_certificates`.

rg --type sh 'check_setup_custom_ca_certificates'

Length of output: 49


Script:

#!/bin/bash
# Description: Search the codebase for any residual references to `check_setup_custom_ca_certificates` within all .sh files.

rg 'check_setup_custom_ca_certificates' --glob '*.sh'

Length of output: 53

deploy/docker/fs/opt/appsmith/entrypoint.sh.bak (1)

496-544: Review the execution flow in the main section

In the main section of the script (lines 496-544), ensure that the functions are called in the correct order and that all necessary initializations are performed before the application starts. Pay special attention to dependencies between services such as MongoDB, Redis, and Postgres.

Consider reviewing the execution sequence to confirm that all services are correctly initialized and ready before the main application starts.

Copy link

This PR has not seen activitiy for a while. It will be closed in 7 days unless further activity is detected.

@github-actions github-actions bot added the Stale label Oct 21, 2024
@Rudraksh2003
Copy link
Author

Rudraksh2003 commented Oct 24, 2024

Dear @sharat87 sir & @pratapaprasanna sir,

I hope you're doing well! I noticed that my pull request (PR #36871 ) hasn't seen any recent activity and is scheduled to be closed in 7 days. Could you kindly review it when you have a moment and let me know if any additional changes are needed? I believe it adds value to the project, and I'm happy to make further adjustments if required.

Thank you for your time and consideration!

Best regards,
Rudraksh Laddha

@github-actions github-actions bot removed the Stale label Oct 25, 2024
Copy link

github-actions bot commented Nov 2, 2024

This PR has not seen activitiy for a while. It will be closed in 7 days unless further activity is detected.

@github-actions github-actions bot added the Stale label Nov 2, 2024
@sharat87
Copy link
Member

sharat87 commented Nov 6, 2024

Hey @Rudraksh2003, thank you for working on this. However, this change needs some extensive testing in whether custom CA certificates are still working fine in the various components of Appsmith, like the backend server. Caddy, RTS, Keycloak, etc. That's where majority of the effort lies, and that's why the linked issue doesn't have the Good first issue label on it. In light of that, I won't be able to approve this today. Please consider only picking up issues that have the Good first issue label on them, and also drop a comment on the issue sharing that you're working on it, before reaching out with a PR. It helps avoid situations like this.

Thanks again and hope to see more contributions from you in the future!

@sharat87 sharat87 closed this Nov 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Bug]: Duplicate setting up of custom CA certificates
2 participants