Skip to content

Warn when persistent disk filesystem is smaller than its partition - #465

Draft
neddp wants to merge 1 commit into
mainfrom
fix/warn-filesystem-smaller-than-partition
Draft

Warn when persistent disk filesystem is smaller than its partition#465
neddp wants to merge 1 commit into
mainfrom
fix/warn-filesystem-smaller-than-partition

Conversation

@neddp

@neddp neddp commented Aug 6, 2026

Copy link
Copy Markdown
Member

What is this change about?

When a persistent disk is resized, AdjustPersistentDiskPartitioning resizes the partition and grows the filesystem. If the partition resize succeeds but the filesystem grow does not complete, every subsequent deploy sees the partition already spanning the disk, takes the branch that only partitions and formats, and never revisits the filesystem - leaving it silently smaller than its partition with no indication anything is wrong.

This change adds a FilesystemNeedsGrow check (ext4) to the formatter. When the partition already matches the disk size, AdjustPersistentDiskPartitioning runs the check and logs a warning if the filesystem is smaller than its partition, surfacing the condition for operator follow-up.

Detection only - no automatic grow is attempted:

  • The filesystem is not mounted at this point (AdjustPersistentDiskPartitioning runs before MountPersistentDisk), so xfs_growfs, which requires a mounted filesystem, is not applicable.
  • The underlying cause often requires manual intervention (e.g. a filesystem flagged with errors that the kernel refuses to grow online).

FilesystemNeedsGrow compares the ext4 superblock size (dumpe2fs -h) against the block device size (blockdev --getsize64), using the same 100MB delta as SinglePartitionNeedsResize to avoid false positives from alignment rounding.

Please provide contextual information.

Found while investigating a resize2fs: Permission denied failure. Three nodes had pre-existing filesystem corruption. The partition resize succeeded, GrowFilesystem failed, and subsequent deploys silently succeeded - leaving those nodes with 98G filesystems on 1T volumes and no visible error.

What tests have you run against this PR?

  • Full platform and platform/disk unit test suites: 375 + 177 passed, 0 failed
  • New specs: FilesystemNeedsGrow for ext4 (smaller, already-full, command failures, missing superblock field, non-ext4); platform specs for the warn path (check invoked, no grow/mount, no deploy failure on mismatch or check error)

How should this change be described in bosh-agent release notes?

The agent now logs a warning when a persistent disk's filesystem is smaller than its partition (indicating a previous grow did not complete), instead of silently leaving it unresized.

Does this PR introduce a breaking change?

No. The change only adds a read-only check and a log warning. No behaviour change to partitioning, formatting, or mounting.

When a disk resize partitions successfully but the filesystem grow does
not complete, subsequent deploys detect the partition already spans the
disk and never revisit the filesystem — leaving it silently smaller than
its partition with no indication anything is wrong.

Add FilesystemNeedsGrow (ext4) to the formatter: it compares the ext4
superblock size (dumpe2fs) against the block device size (blockdev),
using the same 100MB delta as SinglePartitionNeedsResize. When the
partition already matches the disk, AdjustPersistentDiskPartitioning now
runs this check and logs a warning if the filesystem is smaller,
surfacing the condition for operator follow-up.

Detection only: the filesystem is not mounted at this point (so
xfs_growfs is not applicable) and the underlying cause often requires
manual intervention, so no automatic grow is attempted.
Copilot AI review requested due to automatic review settings August 6, 2026 06:30
@coderabbitai

coderabbitai Bot commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 27cded84-5c7d-49ac-8e1c-db683200294a

📥 Commits

Reviewing files that changed from the base of the PR and between 4f9ec7c and b22e742.

📒 Files selected for processing (6)
  • platform/disk/fakes/fake_formatter.go
  • platform/disk/formatter_interface.go
  • platform/disk/linux_formatter.go
  • platform/disk/linux_formatter_test.go
  • platform/linux_platform.go
  • platform/linux_platform_test.go

Walkthrough

The formatter contract now exposes filesystem growth checks, and the fake formatter records calls with configurable results and errors. The Linux formatter inspects ext4 metadata and block-device size, then applies a 100 MB growth threshold. Persistent disk partitioning invokes the check after formatting and logs warnings for inspection errors or incomplete growth without performing filesystem growth. Tests cover detection, parsing failures, non-ext4 filesystems, and partitioning behavior.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main change: warning when a persistent disk filesystem is smaller than its partition.
Description check ✅ Passed The description covers the change, context, tests, release notes, and breaking-change status; only optional tagging and AI feedback sections are omitted.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/warn-filesystem-smaller-than-partition

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
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Adds detection and operator-facing warnings for the case where a persistent disk partition already spans the disk, but the ext4 filesystem inside it remains smaller (e.g., after a prior grow attempt failed), preventing silent “stuck small filesystem” situations across subsequent deploys.

Changes:

  • Add FilesystemNeedsGrow (ext4-only) to the Linux disk formatter, comparing ext4 superblock size (dumpe2fs -h) vs block device size (blockdev --getsize64) with a 100MB tolerance.
  • Invoke the needs-grow check from AdjustPersistentDiskPartitioning when the partition does not need resizing, logging a warning (but not attempting to grow).
  • Add unit/spec coverage for the formatter check and the new warn-path behavior in the Linux platform.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
platform/linux_platform.go Calls FilesystemNeedsGrow on the non-resize path and logs warnings when mismatch is detected (or when the check fails).
platform/linux_platform_test.go Adds specs ensuring the new check is invoked and does not mount/grow/fail deployments.
platform/disk/linux_formatter.go Implements ext4-only needs-grow detection using blockdev + dumpe2fs.
platform/disk/linux_formatter_test.go Adds unit tests for needs-grow true/false and error cases.
platform/disk/formatter_interface.go Extends the Formatter interface with FilesystemNeedsGrow.
platform/disk/fakes/fake_formatter.go Updates fake formatter to implement the new interface method for tests.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +121 to +132
partitionSize, err := f.blockDeviceSize(partitionPath)
if err != nil {
return false, err
}

fsSize, err := f.ext4FilesystemSize(partitionPath)
if err != nil {
return false, err
}

return significantlySmallerThan(fsSize, partitionSize, ConvertFromMbToBytes(deltaSize)), nil
}
@github-project-automation github-project-automation Bot moved this from Inbox to Pending Merge | Prioritized in Foundational Infrastructure Working Group Aug 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Pending Merge | Prioritized

Development

Successfully merging this pull request may close these issues.

2 participants