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

refactor: remove sysctl dependency from start command #4068

Conversation

mircea-c
Copy link
Contributor

Overview

This change was prompted by an attempt to run the application in an unprivileged docker container based on a slim image. The absence of the sysctl command causes the application to fail the BBR check, even though that module is loaded and available.

The goals of this PR are:

  • allow the application to run the BBR check in a restricted environment such as a docker container
  • make the application distribution agnostic by removing the systemd dependency
  • remove an instance of process forking with exec

@mircea-c mircea-c requested a review from a team as a code owner November 28, 2024 18:24
@mircea-c mircea-c requested review from rach-id and ninabarbakadze and removed request for a team November 28, 2024 18:24
@celestia-bot celestia-bot requested a review from a team November 28, 2024 18:24
Copy link
Contributor

coderabbitai bot commented Nov 28, 2024

📝 Walkthrough

Walkthrough

The changes in this pull request focus on the start.go file within the cmd/celestia-appd/cmd package. The modifications include removing the import of the os/exec package and replacing the command execution method for checking the TCP congestion control algorithm with a direct file read operation from /proc/sys/net/ipv4/tcp_congestion_control. The error handling has been updated to reflect this change, while the overall logic for checking if BBR is enabled remains unchanged.

Changes

File Path Change Summary
cmd/celestia-appd/cmd/start.go Removed os/exec import; replaced exec.Command with os.ReadFile for checking BBR status; updated error handling accordingly.

Possibly related PRs

Suggested labels

WS: Maintenance 🔧, WS: V2 ✌️, WS: V3 3️⃣, external

Suggested reviewers

  • rootulp
  • evan-forbes
  • cmwaters
  • ninabarbakadze

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:

‼️ IMPORTANT
Auto-reply has been disabled for this repository in the CodeRabbit settings. The CodeRabbit bot will not respond to your replies unless it is explicitly tagged.

  • 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 (1)
cmd/celestia-appd/cmd/start.go (1)

598-606: Consider platform compatibility and error message clarity

While the implementation is functionally correct, there are a few considerations:

  1. The hardcoded path /proc/sys/net/ipv4/tcp_congestion_control makes this Linux-specific. Consider:

    • Adding a comment to document this limitation
    • Adding platform-specific checks for better error messages on non-Linux systems
  2. The error message could be more specific when the file read fails on non-Linux systems.

Consider this improvement:

 func checkBBR(command *cobra.Command) error {
+    // This check is Linux-specific as it relies on /proc filesystem
     file, err := os.ReadFile("/proc/sys/net/ipv4/tcp_congestion_control")
     if err != nil {
         fmt.Print(warning)
-        return fmt.Errorf("failed to read file '/proc/sys/net/ipv4/tcp_congestion_control' %w", err)
+        if os.IsNotExist(err) {
+            return fmt.Errorf("BBR check is only supported on Linux systems: %w", err)
+        }
+        return fmt.Errorf("failed to read TCP congestion control settings: %w", err)
     }
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 2ca0feb and 4403cd4.

📒 Files selected for processing (1)
  • cmd/celestia-appd/cmd/start.go (2 hunks)
🔇 Additional comments (1)
cmd/celestia-appd/cmd/start.go (1)

582-583: LGTM: Documentation update is clear and consistent

The addition of the alternative verification method using cat /proc/sys/net/ipv4/tcp_congestion_control provides users with a distribution-agnostic way to verify BBR status.

@celestia-bot celestia-bot requested review from a team and rootulp and removed request for a team December 2, 2024 18:16
Copy link
Member

@evan-forbes evan-forbes left a comment

Choose a reason for hiding this comment

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

nice! thanks for this @mircea-c

@evan-forbes evan-forbes added backport:v3.x PR will be backported automatically to the v3.x branch upon merging bug Something isn't working labels Dec 2, 2024
@evan-forbes evan-forbes enabled auto-merge (squash) December 2, 2024 18:21
@evan-forbes evan-forbes merged commit e52234f into celestiaorg:main Dec 2, 2024
29 checks passed
Copy link

gitpoap-bot bot commented Dec 2, 2024

Congrats, your important contribution to this open-source project has earned you a GitPOAP!

GitPOAP: 2024 Celestia Contributor:

GitPOAP: 2024 Celestia Contributor GitPOAP Badge

Head to gitpoap.io & connect your GitHub account to mint!

Learn more about GitPOAPs here.

mergify bot pushed a commit that referenced this pull request Dec 2, 2024
<!--
Please read and fill out this form before submitting your PR.

Please make sure you have reviewed our contributors guide before
submitting your
first PR.
-->

## Overview

<!--
Please provide an explanation of the PR, including the appropriate
context,
background, goal, and rationale. If there is an issue with this
information,
please provide a tl;dr and link the issue.
-->
This change was prompted by an attempt to run the application in an
unprivileged docker container based on a slim image. The absence of the
`sysctl` command causes the application to fail the BBR check, even
though that module is loaded and available.

The goals of this PR are:
- allow the application to run the BBR check in a restricted environment
such as a docker container
- make the application distribution agnostic by removing the `systemd`
dependency
- remove an instance of process forking with `exec`

(cherry picked from commit e52234f)
@mircea-c mircea-c deleted the refactor/remove-sysctl-dependency branch December 2, 2024 18:34
evan-forbes pushed a commit that referenced this pull request Dec 2, 2024
#4072)

## Overview


This change was prompted by an attempt to run the application in an
unprivileged docker container based on a slim image. The absence of the
`sysctl` command causes the application to fail the BBR check, even
though that module is loaded and available.

The goals of this PR are:
- allow the application to run the BBR check in a restricted environment
such as a docker container
- make the application distribution agnostic by removing the `systemd`
dependency
- remove an instance of process forking with `exec`
<hr>This is an automatic backport of pull request #4068 done by
[Mergify](https://mergify.com).

Co-authored-by: Mircea Colonescu <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport:v3.x PR will be backported automatically to the v3.x branch upon merging bug Something isn't working external
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants