Files
steampipe/pkg/ociinstaller
Nathan Wallace f15764e506 Disk space validation before OCI installation closes #4754 (#4895)
* Add test for #4754: Disk space validation before OCI installation

* Fix #4754: Add disk space validation before OCI installation

This commit adds disk space validation to prevent partial installations
that can leave the system in a broken state when disk space is exhausted.

Changes:
- Added diskspace.go with disk space checking utilities
- getAvailableDiskSpace: Uses unix.Statfs to check available space
- estimateRequiredSpace: Estimates required space (2GB for DB/FDW)
- validateDiskSpace: Validates sufficient space is available
- Updated InstallDB to check disk space before installation
- Updated InstallFdw to check disk space before installation

The validation fails fast with a clear error message indicating:
- How much space is required
- How much space is available
- The path being checked

This prevents installations from starting when insufficient space exists,
avoiding corrupted/incomplete installations.

* Reduce disk space requirement from 2GB to 1GB based on actual image sizes

The previous 2GB estimate was based on inflated size assumptions. After
measuring actual OCI image sizes:
- DB image: 37 MB compressed (not 400 MB)
- FDW image: 91 MB compressed (not part of previous estimate)
- Total compressed: ~128 MB
- Uncompressed: ~350-450 MB
- Peak usage: ~530 MB

Updated to 1GB which still provides ~50% safety buffer while being more
realistic for constrained environments (Docker containers, CI/CD, edge
devices).

Updated comments with actual measured sizes from current images:
- ghcr.io/turbot/steampipe/db:14.19.0
- ghcr.io/turbot/steampipe/fdw:2.1.3

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>

* Further reduce disk space requirement from 1GB to 500MB

The 1GB estimate still provides excessive buffer beyond the actual measured
peak usage of ~530 MB. Reducing to 500MB:

- Better balances safety against false rejections
- Avoids blocking installations with 600-700 MB available
- Matches the actual measured peak usage
- Will catch the primary failure case (truly insufficient disk)
- May fail if filesystem overhead exceeds expectations, but this is
  acceptable to maximize compatibility with constrained environments

Updated test expectations to match the new 500MB requirement.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>

---------

Co-authored-by: Claude <noreply@anthropic.com>
2025-11-16 16:18:17 -05:00
..