Skip to content

HIGH: No disk space validation before OCI installation #4754

@e-gineer

Description

@e-gineer

Bug Description

The OCI installer (both DB and FDW) does not check available disk space before beginning installation. If the disk fills up during installation, the system can be left in a broken state with old files deleted but new files incomplete.

Severity: HIGH

Location

  • pkg/ociinstaller/db.go:16-41 (InstallDB function)
  • pkg/ociinstaller/fdw.go:18-45 (InstallFdw function)

Problem

The installation process requires significant disk space for:

  1. Downloading OCI image layers to temp directory
  2. Extracting/unzipping archives
  3. Moving files to final destination

Currently, there is no validation that sufficient disk space is available before starting. If disk fills up during any of these steps:

Result: System left in broken state without working database or FDW.

Impact

  • Severity: HIGH
  • User Impact: Database or FDW installation corrupted, system may be unrecoverable
  • Frequency: More common on systems with limited disk space or small partitions
  • Affected Operations: All OCI installations (DB, FDW, potentially plugins)

Example Scenario

  1. User has 500MB free disk space
  2. New DB version is 400MB compressed, 1.2GB uncompressed
  3. Installation begins:
    • Downloads 400MB to temp (100MB free remaining)
    • Attempts to extract 1.2GB (disk full error)
  4. Old DB files may be deleted, new files incomplete
  5. System cannot start database

Recommended Fix

Add disk space validation before installation:

func InstallDB(ctx context.Context, dblocation string) (string, error) {
    // Check available disk space BEFORE starting
    requiredSpace := estimateRequiredSpace(constants.PostgresImageRef)
    availableSpace, err := getAvailableDiskSpace(dblocation)
    if err != nil {
        return "", fmt.Errorf("could not check disk space: %w", err)
    }
    
    if availableSpace < requiredSpace {
        return "", fmt.Errorf(
            "insufficient disk space: need ~%s, have %s available", 
            humanize.Bytes(requiredSpace),
            humanize.Bytes(availableSpace),
        )
    }
    
    // Proceed with installation...
    tempDir := ociinstaller.NewTempDir(dblocation)
    // ...
}

Space estimate: ~2x archive size (for download + extraction, accounting for compression)

Benefits

  1. Fail fast with clear error message before partial installation
  2. Better UX - users know immediately if they need to free up space
  3. System safety - prevents corrupted installations
  4. Clear guidance - error message tells user exactly how much space needed

Related Tests

  • pkg/ociinstaller/db_test.go::TestInstallDB_DiskSpaceExhaustion_BugDocumentation

References

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workinginstallationissues related to db and steampipe installation

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions