Skip to content

feat: add disk space check to requirements recipe - #41

Merged
konradmichalik merged 4 commits into
mainfrom
feat/add-disk-space-check-with-low-space-warning
Sep 7, 2026
Merged

feat: add disk space check to requirements recipe#41
konradmichalik merged 4 commits into
mainfrom
feat/add-disk-space-check-with-low-space-warning

Conversation

@konradmichalik

Copy link
Copy Markdown
Contributor

Summary

  • Add a new requirements:check:disk_space subtask that checks free disk space on the webspace path and, when reachable, the database's data directory
  • Reports WARN/FAIL based on two configurable used-space thresholds, consistent with the existing requirement checks
  • Extract a shared runMysqlQuery() helper to avoid duplicating the mysql CLI invocation between the new check and the existing database grants check

Changes

  • deployer/requirements/task/check_disk_space.php - new task: checks webspace path via df, and the database data directory via SHOW VARIABLES LIKE 'datadir' when the DB host is local
  • deployer/requirements/functions.php - adds checkDiskSpaceAtPath(), formatKilobytes(), and the shared runMysqlQuery() helper
  • deployer/requirements/task/check_database_grants.php - reuse runMysqlQuery() instead of duplicating the mysql CLI invocation
  • deployer/requirements/config/set.php - new requirements_check_disk_space_enabled, requirements_disk_space_warn_percent (80), requirements_disk_space_fail_percent (95), requirements_disk_space_webspace_path (defaults to deploy_path) settings
  • deployer/requirements/task/requirements.php - wire the new subtask into requirements:check
  • deployer/requirements/task/list.php - list the disk space thresholds in requirements:list
  • autoload.php - require the new task file
  • docs/REQUIREMENTS.md - document the new check, its thresholds, and how to wire it as a deploy-blocking hook

Test Plan

  • Run dep requirements:check [host] against a real target and confirm the "Disk space: webspace" row reports plausible OK/WARN/FAIL values
  • Verify the "Disk space: database" row appears when the DB host is 127.0.0.1/localhost, and is SKIPped with a clear reason otherwise
  • Run dep requirements:list [host] and confirm the Disk Space section renders

Closes #38

@coderabbitai

coderabbitai Bot commented Sep 7, 2026

Copy link
Copy Markdown

Important

  • 🔍 Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Team

Run ID: 7e97c71f-ee8e-45c5-b7fb-9fae575ba714


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

Comment @coderabbitai help to get the list of available commands.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟡 Changes recommended

The new DB datadir detection can mis-parse MySQL output when warnings are present, which can cause incorrect/failed disk checks on real targets.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Pull request overview

Adds a new disk space requirement check to the Deployer “requirements” recipe, covering both the webspace filesystem and (when the DB host is local) the database data directory, and refactors MySQL CLI invocation into a shared helper.

Changes:

  • Introduces requirements:check:disk_space to report OK/WARN/FAIL based on configurable used-space thresholds.
  • Adds shared helpers in deployer/requirements/functions.php for disk-space checking, formatting, and MySQL query execution.
  • Wires the new check into requirements:check, requirements:list, autoloading, and documentation/config defaults.
File summaries
File Description
docs/REQUIREMENTS.md Documents the new disk space check behavior, thresholds, and configuration example.
deployer/requirements/task/requirements.php Adds requirements:check:disk_space to the main requirements check sequence.
deployer/requirements/task/list.php Displays disk space thresholds/details in requirements:list.
deployer/requirements/task/check_disk_space.php Implements the new disk space check task (webspace + conditional DB datadir).
deployer/requirements/task/check_database_grants.php Reuses the new shared runMysqlQuery() helper for grants checks.
deployer/requirements/functions.php Adds runMysqlQuery(), checkDiskSpaceAtPath(), and formatKilobytes().
deployer/requirements/config/set.php Adds disk space configuration defaults and enable/disable flag.
autoload.php Ensures the new disk space task file is loaded.
Review details
  • Files reviewed: 8/8 changed files
  • Comments generated: 2
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread deployer/requirements/functions.php Outdated
Comment thread deployer/requirements/task/check_disk_space.php Outdated
@konradmichalik
konradmichalik merged commit a633e40 into main Sep 7, 2026
2 checks passed
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.

Add disk space check with low-space warning

2 participants