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

Remove our copy of the wait-for-it script #8572

Merged
merged 1 commit into from
Oct 22, 2024

Conversation

SpecLad
Copy link
Contributor

@SpecLad SpecLad commented Oct 21, 2024

Motivation and context

Nowadays it's available from the Ubuntu repositories, so install it from there. This declutters our root directory a bit, plus it makes enumerating 3rd-party dependencies easier.

How has this been tested?

Manual testing.

Checklist

  • I submit my changes into the develop branch
  • [ ] I have created a changelog fragment
  • [ ] I have updated the documentation accordingly
  • [ ] I have added tests to cover my changes
  • [ ] I have linked related issues (see GitHub docs)
  • [ ] I have increased versions of npm packages if it is necessary
    (cvat-canvas,
    cvat-core,
    cvat-data and
    cvat-ui)

License

  • I submit my code changes under the same MIT License that covers the project.
    Feel free to contact the maintainers if that's a concern.

Summary by CodeRabbit

  • New Features

    • Introduced a new build process for dependencies, enhancing installation efficiency.
    • Added support for the wait-for-it utility for service readiness checks.
  • Bug Fixes

    • Replaced the deprecated wait-for-it.sh script with a direct call to wait-for-it, ensuring reliable service checks.
  • Chores

    • Updated various environment variables and arguments in the Dockerfile to streamline configuration.
  • Refactor

    • Improved the structure of the backend_entrypoint.sh and wait_for_deps.sh scripts for better clarity and performance.

Nowadays it's available from the Ubuntu repositories, so install it from
there. This declutters our root directory a bit, plus it makes enumerating
3rd-party dependencies easier.
Copy link
Contributor

coderabbitai bot commented Oct 21, 2024

Walkthrough

The changes primarily involve modifications to the Dockerfile and related scripts to enhance the build process and streamline service dependency checks. The Dockerfile now includes multiple build stages for installing packages, compiling OpenH264 and FFmpeg, and setting up the Smokescreen project. Additionally, the wait-for-it.sh script has been removed, and its functionality has been integrated directly into the backend_entrypoint.sh and wait_for_deps.sh scripts, which now utilize the wait-for-it command directly.

Changes

File Change Summary
Dockerfile Updated package installations, added build stages for OpenH264 and FFmpeg, and set new ARGs.
backend_entrypoint.sh Replaced calls to wait-for-it.sh with wait-for-it command in wait_for_db and cmd_init.
wait-for-it.sh Deleted; previously used to check TCP host availability.
wait_for_deps.sh Updated to replace calls to ~/wait-for-it.sh with wait-for-it for service checks.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant Backend
    participant Database
    participant Redis

    User->>Backend: Start Application
    Backend->>Backend: Check PostgreSQL with wait-for-it
    Backend->>Database: Connect to PostgreSQL
    Backend->>Backend: Check Redis (in-memory) with wait-for-it
    Backend->>Redis: Connect to Redis (in-memory)
    Backend->>Backend: Check Redis (on-disk) with wait-for-it
    Backend->>Redis: Connect to Redis (on-disk)
    Backend->>User: Application Ready
Loading

🐰 In a world of code and lines,
A rabbit hops through build designs.
With wait-for-it now in play,
Our services are here to stay!
No more scripts to slow the pace,
Just smooth deployments, quick embrace!
🐇


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.

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

Copy link

sonarcloud bot commented Oct 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: 1

🧹 Outside diff range and nitpick comments (2)
wait_for_deps.sh (1)

14-16: LGTM! Consider adding comments for improved readability.

The changes align well with the PR objectives by removing the internal copy of the wait-for-it script and using the system-wide version. The functionality remains the same, which is good.

Consider adding brief comments before each wait-for-it call to improve readability. For example:

+# Wait for PostgreSQL
 wait-for-it "${CVAT_POSTGRES_HOST}:${CVAT_POSTGRES_PORT:-5432}" -t 0
+# Wait for Redis in-memory
 wait-for-it "${CVAT_REDIS_INMEM_HOST}:${CVAT_REDIS_INMEM_PORT}" -t 0
+# Wait for Redis on-disk
 wait-for-it "${CVAT_REDIS_ONDISK_HOST}:${CVAT_REDIS_ONDISK_PORT}" -t 0

This small change would make the script's purpose even clearer at a glance.

backend_entrypoint.sh (1)

22-22: LGTM! Consider refactoring for DRY principle.

The change from ~/wait-for-it.sh to wait-for-it is consistent with the previous modification and aligns with the PR objective.

Consider refactoring the wait-for-it calls into a separate function to reduce code duplication. For example:

wait_for_service() {
    local host="$1"
    local port="$2"
    wait-for-it "${host}:${port}" -t 0
}

# Usage in wait_for_db function
wait_for_service "${CVAT_POSTGRES_HOST}" "${CVAT_POSTGRES_PORT:-5432}"

# Usage in cmd_init function
wait_for_service "${CVAT_REDIS_INMEM_HOST}" "${CVAT_REDIS_INMEM_PORT:-6379}"

This refactoring would make the script more maintainable and easier to update if changes to the wait-for-it usage are needed in the future.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 329e94d and 320d034.

📒 Files selected for processing (4)
  • Dockerfile (2 hunks)
  • backend_entrypoint.sh (2 hunks)
  • wait-for-it.sh (0 hunks)
  • wait_for_deps.sh (1 hunks)
💤 Files with no reviewable changes (1)
  • wait-for-it.sh
🧰 Additional context used
🔇 Additional comments (4)
wait_for_deps.sh (1)

14-16: Verify system-wide availability of wait-for-it

The changes assume that wait-for-it is available in the system PATH. To ensure smooth operation after these changes:

  1. Confirm that the Dockerfile or the environment where this script runs installs the wait-for-it package.
  2. Verify that the wait-for-it command is available in the PATH when this script is executed.
  3. Check that no other files in the project still reference the old ~/wait-for-it.sh script.

Run the following script to verify these points:

backend_entrypoint.sh (1)

Line range hint 1-72: Summary: Successful migration to system wait-for-it command.

The changes in this file successfully replace the local wait-for-it.sh script with the system wait-for-it command. This aligns perfectly with the PR objective of removing the project's internal copy of the wait-for-it script. The modifications maintain the existing functionality while simplifying the project structure and improving dependency management.

These changes, combined with the updates in the Dockerfile to install the wait-for-it package, effectively streamline the project setup without compromising its operational integrity.

Dockerfile (2)

137-137: ⚠️ Potential issue

Verify the availability of 'wait-for-it' in Ubuntu 22.04 repositories

You've added wait-for-it to the list of packages in the apt-get install command. Please confirm that wait-for-it is available in the Ubuntu 22.04 repositories under this package name. If it's not available, the build process may fail.

Run the following script to check if wait-for-it is available:

#!/bin/bash
# Description: Verify if 'wait-for-it' is available in Ubuntu 22.04 repositories

# Update package lists
apt-get update

# Search for the 'wait-for-it' package
apt-cache search '^wait-for-it$'

196-196: ⚠️ Potential issue

Ensure scripts reference the system-installed 'wait-for-it' command

Since you're no longer copying wait-for-it.sh into the image, make sure all scripts that previously referenced ./wait-for-it.sh are updated to use the wait-for-it command installed by the package manager.

Run the following script to find any remaining references to ./wait-for-it.sh:

✅ Verification successful

Verification Successful: No references to ./wait-for-it.sh found in the codebase.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Find occurrences of './wait-for-it.sh' in the codebase

# Search recursively for 'wait-for-it.sh' references
rg './wait-for-it\.sh'

Length of output: 118


Script:

#!/bin/bash
# Description: Find occurrences of './wait-for-it.sh' in the codebase

# Search recursively for 'wait-for-it.sh' references
rg './wait-for-it\.sh'

Length of output: 24

backend_entrypoint.sh Show resolved Hide resolved
@codecov-commenter
Copy link

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 74.26%. Comparing base (329e94d) to head (320d034).
Report is 2 commits behind head on develop.

Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #8572      +/-   ##
===========================================
- Coverage    74.29%   74.26%   -0.03%     
===========================================
  Files          403      403              
  Lines        43287    43287              
  Branches      3914     3914              
===========================================
- Hits         32159    32149      -10     
- Misses       11128    11138      +10     
Components Coverage Δ
cvat-ui 78.73% <ø> (-0.06%) ⬇️
cvat-server 70.47% <ø> (ø)

@SpecLad SpecLad merged commit 1d4632c into cvat-ai:develop Oct 22, 2024
34 checks passed
@SpecLad SpecLad deleted the devendor-wait-for-it branch October 22, 2024 11:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants