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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: Update incorrect docker tagging and add fargate tag in deployment telemetry #33472

Merged
merged 5 commits into from
May 27, 2024

Conversation

trishaanand
Copy link
Contributor

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?

  • Yes
  • No

Copy link
Contributor

coderabbitai bot commented May 15, 2024

Walkthrough

Walkthrough

The recent changes to the generate-infra-details.sh script update default values for the cloud_provider and dep_tool variables, and introduce a new function check_for_fargate. These modifications aim to enhance the script's flexibility and capability to determine if the deployment environment is AWS Fargate based on specific conditions.

Changes

File Path Change Summary
deploy/docker/fs/opt/appsmith/generate-infra-details.sh - Default cloud_provider to "others(including local)" instead of "local".
- Default dep_tool to "likely docker" instead of "docker".
- Added check_for_fargate function to detect Fargate deployments.

Sequence Diagram(s) (Beta)

sequenceDiagram
    participant User
    participant Script

    User->>Script: Run generate-infra-details.sh
    Script->>Script: Set default cloud_provider to "others(including local)"
    Script->>Script: Set default dep_tool to "likely docker"
    Script->>Script: Call check_for_fargate()
    Script->>Script: Determine if Fargate deployment
    Script-->>User: Output deployment details

Recent Review Details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits Files that changed from the base of the PR and between 4c28d83 and 353a054.
Files selected for processing (1)
  • deploy/docker/fs/opt/appsmith/generate-infra-details.sh (2 hunks)
Additional Context Used
ShellCheck (5)
deploy/docker/fs/opt/appsmith/generate-infra-details.sh (5)

[info] 43-43: Note that A && B || C is not if-then-else. C may run when A is true.


[warning] 75-75: Quotes/backslashes will be treated literally. Use an array.


[warning] 78-78: Quotes/backslashes in this variable will not be respected.


[info] 78-78: Double quote to prevent globbing and word splitting.


[info] 78-78: Double quote to prevent globbing and word splitting.

Additional comments not posted (3)
deploy/docker/fs/opt/appsmith/generate-infra-details.sh (3)

35-35: Ensure consistency in the default value of dep_tool.

The change to the default value of dep_tool to "likely docker" is consistent with the PR's objectives to update Docker tagging.


60-65: Review the logic for determining if it's an ECS Fargate deployment.

-  if [[ $cloud_provider == "amazon" && $dep_tool == "likely docker" && $efs == "present" ]]; then
+  if [[ $cloud_provider == "amazon" && $dep_tool == "likely docker" && $efs == "present" ]]; then
    dep_tool="ecs-fargate"
-  fi
+  fi

The logical expression A && B || C is not equivalent to if-then-else. C may run when A is true. Ensure the logic correctly reflects the intended conditions for setting dep_tool to "ecs-fargate".

Likely invalid or redundant comment.


72-72: Verify the call to check_for_fargate in the main block.

Ensure that the function check_for_fargate is called correctly and only once in the main block to maintain the intended flow of the script.

Verification successful

The function check_for_fargate is correctly called once in the main block of the script.

  • Location: deploy/docker/fs/opt/appsmith/generate-infra-details.sh
Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify that the function `check_for_fargate` is called correctly and only once in the main block.

# Test: Search for the function call. Expect: Only one occurrence in the main block.
rg --type bash $'check_for_fargate'

Length of output: 63



Script:

#!/bin/bash
# Description: Verify that the function `check_for_fargate` is called correctly and only once in the main block.

# Test: Search for the function call. Expect: Only one occurrence in the main block.
rg --type sh $'check_for_fargate'

Length of output: 193



Script:

#!/bin/bash
# Description: Verify the context of the `check_for_fargate` function call to ensure it is in the main block.

# Extract 5 lines before and after the function call to check its context.
rg --type sh -C 5 $'check_for_fargate' deploy/docker/fs/opt/appsmith/generate-infra-details.sh

Length of output: 648


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>.
    • 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 generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @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.

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 as 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 full the 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 help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration 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.

@github-actions github-actions bot added the skip-changelog Adding this label to a PR prevents it from being listed in the changelog label May 15, 2024
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: 2

Out of diff range and nitpick comments (1)
deploy/docker/fs/opt/appsmith/generate-infra-details.sh (1)

Line range hint 68-68: Quotes/backslashes in this variable will not be respected. Double quote to prevent globbing and word splitting.

- echo $infra_json > $infra_file
+ echo "$infra_json" > "$infra_file"

deploy/docker/fs/opt/appsmith/generate-infra-details.sh Outdated Show resolved Hide resolved
@trishaanand trishaanand changed the title chore: Update deployment telemetry incorrect docker tagging and add fargate tag chore: Update incorrect docker tagging and add fargate tag in deployment telemetry May 15, 2024
@trishaanand
Copy link
Contributor Author

/build-deploy-preview skip-tests=true

Copy link

Deploying Your Preview: https://github.com/appsmithorg/appsmith/actions/runs/9096240170.
Workflow: On demand build Docker image and deploy preview.
skip-tests: true.
env: ``.
PR: 33472.
recreate: .

Copy link

Deploy-Preview-URL: https://ce-33472.dp.appsmith.com

sharat87
sharat87 previously approved these changes May 16, 2024
Copy link
Member

@sharat87 sharat87 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Left suggestions, but looks okay.

deploy/docker/fs/opt/appsmith/generate-infra-details.sh Outdated Show resolved Hide resolved
deploy/docker/fs/opt/appsmith/generate-infra-details.sh Outdated Show resolved Hide resolved
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

Out of diff range and nitpick comments (1)
deploy/docker/fs/opt/appsmith/generate-infra-details.sh (1)

Line range hint 68-68: Ensure special characters are handled properly when redirecting output to a file.

- echo $infra_json > $infra_file
+ echo "$infra_json" > "$infra_file"

@trishaanand trishaanand requested a review from sharat87 May 20, 2024 06:49
sharat87
sharat87 previously approved these changes May 21, 2024
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: 3

Outside diff range and nitpick comments (1)
deploy/docker/fs/opt/appsmith/generate-infra-details.sh (1)

Line range hint 74-74: Ensure proper handling of quotes and backslashes when writing JSON to a file.

- echo $infra_json > $infra_file
+ echo "$infra_json" > "$infra_file"

cloud_provider="digitalocean"
elif [[ $release_details == *"ecs"* ]];then
cloud_provider="alibaba"
elif [[ ! -z "${DYNO}" ]];then
Copy link
Contributor

@coderabbitai coderabbitai bot May 22, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Improve readability by using -n instead of ! -z.

-  elif [[ ! -z "${DYNO}" ]];then
+  elif [[ -n "${DYNO}" ]];then

Committable suggestion

鈥硷笍 IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.

Suggested change
elif [[ ! -z "${DYNO}" ]];then
elif [[ -n "${DYNO}" ]];then

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This as well please.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sharat87, the change to use -n instead of ! -z has been noted and is indeed a good improvement for readability. This change will make the condition more straightforward and easier to understand. Thank you for pointing this out!

If there's anything else you need, feel free to ask!

Comment on lines 56 to 61
## Check if its a fargate deployment
function check_for_fargate() {
if [[ $cloud_provider == "amazon" && $dep_tool == "likely docker" && $efs == "present" ]]; then
dep_tool="ecs-fargate"
fi
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The implementation of check_for_fargate correctly identifies Fargate deployments. Consider adding a comment explaining the conditions for clarity.

+  # Check if the deployment is on AWS Fargate
   if [[ $cloud_provider == "amazon" && $dep_tool == "likely docker" && $efs == "present" ]]; then
     dep_tool="ecs-fargate"
   fi

Committable suggestion

鈥硷笍 IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.

Suggested change
## Check if its a fargate deployment
function check_for_fargate() {
if [[ $cloud_provider == "amazon" && $dep_tool == "likely docker" && $efs == "present" ]]; then
dep_tool="ecs-fargate"
fi
}
## Check if its a fargate deployment
function check_for_fargate() {
# Check if the deployment is on AWS Fargate
if [[ $cloud_provider == "amazon" && $dep_tool == "likely docker" && $efs == "present" ]]; then
dep_tool="ecs-fargate"
fi
}

@trishaanand
Copy link
Contributor Author

/build-deploy-preview skip-tests=true

Copy link

Deploying Your Preview: https://github.com/appsmithorg/appsmith/actions/runs/9206524337.
Workflow: On demand build Docker image and deploy preview.
skip-tests: true.
env: ``.
PR: 33472.
recreate: .

Copy link

Deploy-Preview-URL: https://ce-33472.dp.appsmith.com

Comment on lines 14 to 20
cloud_provider="azure";
elif [[ $release_details == *"cloud"* ]];then
cloud_provider="gcp";
elif [[ $release_details == *"generic"* ]];then
cloud_provider="digitalocean"
elif [[ $release_details == *"ecs"* ]];then
cloud_provider="alibaba"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This if/elif chain is quickly getting out of hand. Can we add a comment to these with a full example string to help a bit please? Like:

Suggested change
cloud_provider="azure";
elif [[ $release_details == *"cloud"* ]];then
cloud_provider="gcp";
elif [[ $release_details == *"generic"* ]];then
cloud_provider="digitalocean"
elif [[ $release_details == *"ecs"* ]];then
cloud_provider="alibaba"
cloud_provider="azure";
elif [[ $release_details == *"cloud"* ]];then
# Example: abcd.cloud-magic.com
cloud_provider="gcp";
elif [[ $release_details == *"generic"* ]];then
# Example: generic-cant-be-bothered-to-name-better.com
cloud_provider="digitalocean"
elif [[ $release_details == *"ecs"* ]];then
cloud_provider="alibaba"

Can we fix the indentation as well please?

cloud_provider="digitalocean"
elif [[ $release_details == *"ecs"* ]];then
cloud_provider="alibaba"
elif [[ ! -z "${DYNO}" ]];then
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This as well please.

@@ -47,14 +53,21 @@ function get_current_time(){
currentTime="$(date -u -Iseconds)"
}

## Check if its a fargate deployment
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
## Check if its a fargate deployment
# Check if it's a ECS Fargate deployment

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/generate-infra-details.sh (2)

12-12: Update comments to reflect the new default values for cloud_provider.

Consider updating the example comments in the get_cloud_provider function to reflect the new default value of cloud_provider as "others(including local)" where applicable.

Also applies to: 15-15, 18-18, 21-22, 24-24, 26-26, 28-28


Line range hint 78-78: Handle quotes and backslashes correctly in JSON output.

- echo "$infra_json"
+ echo "$infra_json" | jq .

Ensure proper handling of quotes and backslashes in JSON output to prevent errors in data formatting.

@pratapaprasanna pratapaprasanna merged commit 921807d into release May 27, 2024
14 checks passed
@pratapaprasanna pratapaprasanna deleted the chore/update-deployment-local-tag branch May 27, 2024 11:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
skip-changelog Adding this label to a PR prevents it from being listed in the changelog
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants