lnd icon indicating copy to clipboard operation
lnd copied to clipboard

Add Critical Logging for Low Disk Space Condition

Open arnav-makkar opened this issue 8 months ago • 10 comments

Change Description

Fixes #6693

This PR enhances disk space monitoring by introducing critical logging when free disk space drops below 5% ensuring timely alerts for potential storage issues.

Changes Introduced:

  • A check was added to detect when free disk space is less than 5%.
  • Logs a critical message with the exact percentage of remaining free space.

For example, if only 4% of disk space is available, the log will output: CRITICAL: Disk space critically low: 4.0% free space remaining

Why This Change?

  • Helps in proactive monitoring and prevention of storage-related failures.
  • Ensures system administrators receive urgent alerts before running out of space.

Testing & Verification:

  • Manually tested by simulating different free space conditions.
  • Verified that logs appear correctly when threshold conditions are met.

This is my first open-source PR, and I'm excited to contribute! Feedback is welcome. 🚀

arnav-makkar avatar Mar 20 '25 14:03 arnav-makkar

[!IMPORTANT]

Review skipped

Auto reviews are limited to specific labels.

:label: Labels to auto review (1)
  • llm-review

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ 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 generate docstrings to generate docstrings for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai plan to trigger planning for file edits and PR creation.
  • @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.

coderabbitai[bot] avatar Mar 20 '25 14:03 coderabbitai[bot]

Logging with log.Critical will cause lnd to shut down. Is that the intended behavior?

guggero avatar Mar 20 '25 16:03 guggero

I realized I’d misunderstood the issue initially and have swapped Criticalf for Errorf, which seems better suited for managing these errors without escalating them to critical status. With this change, the node now logs a warning when available disk space drops below a threshold—say, 5%—and only shuts down if it falls below the required minimum.

On top of that, I’ve taken a stab at addressing the file descriptor concern raised in #6693. I’ve added a new file to check for available file descriptors, with the program exiting if none are free. This should help catch the problem early and keep things stable.

@guggero, whenever you’ve got a moment, I’d appreciate your take on this—especially if you think my approach misses the mark or could be improved. Let me know what you think.

Thank you

arnav-makkar avatar Mar 20 '25 18:03 arnav-makkar

I'll take a look some time next week. In the meantime, please take a look at https://github.com/lightningnetwork/lnd/blob/master/docs/code_contribution_guidelines.md and https://github.com/lightningnetwork/lnd/blob/master/docs/code_formatting_rules.md.

guggero avatar Mar 20 '25 18:03 guggero

@arnav-makkar, the PR should be submitted as a final version ready for review. Currently, the code isn’t compiling and needs to be fixed before it can be properly reviewed. Keep up the good work! :wink:

MPins avatar Apr 01 '25 16:04 MPins

Hi @MPins, Thank you for your suggestions. I’ll integrate your feedback and ensure my code adheres to the contribution guidelines. I appreciate your insights and will share the final version once I’ve completed the updates and performed the necessary checks. Thanks again for your support

arnav-makkar avatar Apr 01 '25 16:04 arnav-makkar

Hi @MPins, Thank you for your suggestions. I’ll integrate your feedback and ensure my code adheres to the contribution guidelines. I appreciate your insights and will share the final version once I’ve completed the updates and performed the necessary checks. Thanks again for your support

hey @arnav-makkar I'm currently reviewing your PR, and to get a deeper understanding of your changes, I checked out your fork and attempted to build the code locally. However, I ran into an issue where healthcheck.CheckFileDescriptors() in server.go is throwing an “undefined” error during build. I’ve verified that the function exists in healthcheck/fdcheck.go and that the package is properly imported. I'm working on WSL (Ubuntu), so I’m wondering—did you encounter this as well, or could this be environment-specific

Lokeshranjan8 avatar Apr 07 '25 11:04 Lokeshranjan8

  • in the server.go file ....The warning threshold for disk space is hardcoded; consider making it configurable or documenting it.

@AbhinavAnand241201 feedback comments like this are provided inline. Please refer to other pr reviews to learn how the reviews are submitted on specific code change suggestions.

saubyk avatar Apr 16 '25 14:04 saubyk

@arnav-makkar, remember to re-request review from reviewers when ready

lightninglabs-deploy avatar Jun 04 '25 20:06 lightninglabs-deploy

!lightninglabs-deploy mute

saubyk avatar Jun 04 '25 21:06 saubyk

Closing due to inactivity

saubyk avatar Sep 24 '25 01:09 saubyk