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 HEALTHCHECK #78

Merged
merged 5 commits into from
Jul 15, 2024
Merged

Fix HEALTHCHECK #78

merged 5 commits into from
Jul 15, 2024

Conversation

svengo
Copy link
Owner

@svengo svengo commented Jul 14, 2024

  • add config.sh with configuration defaults
  • rename docker-entry-point.sh to entry-point.sh
  • add healthcheck.sh
  • remove checking http://localhost:${DIRPORT}/tor/server/authority
  • fixes Healthcheck not working #77

Summary by CodeRabbit

  • New Features

    • Introduced default environment variables to simplify configuration.
    • Added a health check script to verify Tor service connectivity.
  • Improvements

    • Updated Dockerfile to streamline container setup and health check process.
    • Enhanced entry-point script to manage Tor configurations and permissions more effectively.

Copy link
Contributor

coderabbitai bot commented Jul 14, 2024

Warning

Rate limit exceeded

@svengo has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 18 minutes and 24 seconds before requesting another review.

How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

Commits

Files that changed from the base of the PR and between 7c76621 and b433e93.

Walkthrough

The changes focus on updating file copies, configuring environment variables, and improving the health check in the Docker setup for a Tor service. The Dockerfile now properly copies necessary scripts, a new config.sh sets default environment variables, entry-point.sh handles Tor configurations, and healthcheck.sh ensures the service's connectivity is verified.

Changes

File Change Summary
Dockerfile Updated to copy config.sh, entry-point.sh, and healthcheck.sh. Added HEALTHCHECK command to verify connectivity.
config.sh Introduced with default environment variables for various ports and Tor settings.
entry-point.sh Added logic to set up default Tor configurations, permissions, and handle missing torrc. Executes the appropriate command based on the input argument.
healthcheck.sh Updated with functionality to verify connectivity to a Tor service using a specified port.

Sequence Diagram(s)

sequenceDiagram
    participant Dockerfile
    participant config.sh
    participant entry-point.sh
    participant healthcheck.sh
    participant Tor Service

    Dockerfile->>config.sh: COPY config.sh
    Dockerfile->>entry-point.sh: COPY entry-point.sh
    Dockerfile->>healthcheck.sh: COPY healthcheck.sh
    config.sh->>entry-point.sh: Set environment variables
    entry-point.sh->>Tor Service: Configure and start Tor
    healthcheck.sh->>Tor Service: Verify connectivity
    Tor Service->>healthcheck.sh: Respond with status
Loading

Assessment against linked issues

Objective Addressed Explanation
Healthcheck not working (#77)

Poem

In Docker's world, scripts now align,
Configs and checks, all in fine.
Ports and policies, set with care,
Tor's health ensured, a breeze of air.
A rabbit's joy, in code so bright,
Connectivity strong, all through the night.
🐇✨


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.
    • @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 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 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.

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.

healthcheck.sh Outdated
source /config.sh

# check health
su-exec tor echo quit | curl -sS telnet://localhost:${ORPORT} || exit 1

Check notice

Code scanning / Shellcheck (reported by Codacy)

Double quote to prevent globbing and word splitting. Note

Double quote to prevent globbing and word splitting.
@@ -0,0 +1,7 @@
export ORPORT="${ORPORT:-9001}"

Check warning

Code scanning / Shellcheck (reported by Codacy)

Tips depend on target shell and yours is unknown. Add a shebang or a 'shell' directive. Warning

Tips depend on target shell and yours is unknown. Add a shebang or a 'shell' directive.
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: 5

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 2137219 and 5020c22.

Files selected for processing (4)
  • Dockerfile (1 hunks)
  • config.sh (1 hunks)
  • entry-point.sh (1 hunks)
  • healthcheck.sh (1 hunks)
Additional context used
Shellcheck
healthcheck.sh

[warning] 5-5: In POSIX sh, 'source' in place of '.' is undefined.

(SC3046)

config.sh

[error] 1-1: Tips depend on target shell and yours is unknown. Add a shebang or a 'shell' directive.

(SC2148)

entry-point.sh

[warning] 5-5: In POSIX sh, 'source' in place of '.' is undefined.

(SC3046)

GitHub Check: Codacy Static Code Analysis
healthcheck.sh

[warning] 8-8: healthcheck.sh#L8
Double quote to prevent globbing and word splitting.

Dockerfile

[failure] 82-82: Dockerfile#L82
By not specifying a USER, a program in the container may run as 'root'. This is a security hazard.

GitHub Check: Shellcheck (reported by Codacy)
healthcheck.sh

[notice] 8-8:
Double quote to prevent globbing and word splitting.

config.sh

[warning] 1-1:
Tips depend on target shell and yours is unknown. Add a shebang or a 'shell' directive.

GitHub Check: Semgrep (reported by Codacy)
Dockerfile

[failure] 82-82:
By not specifying a USER, a program in the container may run as 'root'. This is a security hazard.

Additional comments not posted (15)
healthcheck.sh (6)

1-1: LGTM!

The shebang line is correct and necessary for script execution.


2-2: LGTM!

The set -e command ensures that the script stops on errors, which is a good practice for health check scripts.


3-3: LGTM!

The empty line improves readability.


4-4: LGTM!

The comment indicates the start of the default configuration section and provides useful information.


6-6: LGTM!

The empty line improves readability.


7-7: LGTM!

The comment indicates the start of the health check section and provides useful information.

config.sh (6)

2-2: LGTM!

The line sets a default value for DIRPORT if it is not already set.


3-3: LGTM!

The line sets a default value for EXITPOLICY if it is not already set.


4-4: LGTM!

The line sets a default value for CONTROLPORT if it is not already set.


5-5: LGTM!

The line sets a default value for HASHEDCONTROLPASSWORD if it is not already set.


6-6: LGTM!

The line sets a default value for NICKNAME if it is not already set.


7-7: LGTM!

The line sets a default value for CONTACTINFO if it is not already set.

Dockerfile (3)

74-74: LGTM!

The line copies config.sh into the container, which is necessary for the container to have access to the configuration file.


75-75: LGTM!

The line copies entry-point.sh into the container, which is necessary for the container to have access to the entry point script.


76-76: LGTM!

The line copies healthcheck.sh into the container, which is necessary for the container to have access to the health check script.

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

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 5020c22 and b4afabb.

Files selected for processing (1)
  • Dockerfile (1 hunks)
Files skipped from review as they are similar to previous changes (1)
  • Dockerfile

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

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between b4afabb and 7c76621.

Files selected for processing (3)
  • config.sh (1 hunks)
  • entry-point.sh (1 hunks)
  • healthcheck.sh (1 hunks)
Files skipped from review as they are similar to previous changes (1)
  • config.sh
Additional context used
Shellcheck
healthcheck.sh

[warning] 6-6: In POSIX sh, 'source' in place of '.' is undefined.

(SC3046)

entry-point.sh

[warning] 6-6: In POSIX sh, 'source' in place of '.' is undefined.

(SC3046)

Additional comments not posted (3)
healthcheck.sh (2)

6-6: Use POSIX compliant command.

The use of source is not POSIX compliant. Use . instead.

- source /config.sh
+ . /config.sh
Tools
Shellcheck

[warning] 6-6: In POSIX sh, 'source' in place of '.' is undefined.

(SC3046)


9-9: Quote the command to prevent globbing and word splitting.

The command should be quoted to prevent globbing and word splitting.

- su-exec tor echo quit | curl -sS "telnet://localhost:${ORPORT}" || exit 1
+ su-exec tor echo quit | curl -sS "telnet://localhost:${ORPORT}" || exit 1
entry-point.sh (1)

6-6: Use POSIX compliant command.

The use of source is not POSIX compliant. Use . instead.

- source /config.sh
+ . /config.sh
Tools
Shellcheck

[warning] 6-6: In POSIX sh, 'source' in place of '.' is undefined.

(SC3046)

@svengo svengo merged commit 690775b into main Jul 15, 2024
5 of 7 checks passed
@svengo svengo deleted the healthcheck branch July 15, 2024 14:26
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.

Healthcheck not working
1 participant