Skip to content

fix: use explicit blkid checks to correctly detect empty partitions#263

Merged
derekbit merged 1 commit into
longhorn:mainfrom
bachmanity1:fix/12599
Feb 6, 2026
Merged

fix: use explicit blkid checks to correctly detect empty partitions#263
derekbit merged 1 commit into
longhorn:mainfrom
bachmanity1:fix/12599

Conversation

@bachmanity1
Copy link
Copy Markdown
Contributor

Which issue(s) this PR fixes:

Issue longhorn/longhorn#12599

What this PR does / why we need it:

Special notes for your reviewer:

Additional documentation or context

Signed-off-by: bachmanity1 <bachmanity138@gmail.com>
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR refines how Longhorn detects whether a block device is "in use" by making blkid checks explicit for filesystems and partition tables, improving detection of truly empty devices/partitions.

Changes:

  • Introduced hasFilesystem and hasPartitionTable helpers that call blkid with -s TYPE and -s PTTYPE respectively and interpret their outputs.
  • Updated IsBlockDeviceInUse to rely on these helpers, returning true only if a filesystem or partition table is actually detected.

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

Copy link
Copy Markdown
Member

@COLDTURNIP COLDTURNIP left a comment

Choose a reason for hiding this comment

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

LGTM

Comment thread pkg/util/device.go
@derekbit derekbit merged commit 8c1c33c into longhorn:main Feb 6, 2026
12 of 14 checks passed
@bachmanity1 bachmanity1 deleted the fix/12599 branch February 6, 2026 23:33
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.

6 participants