Skip to content

Commit

Permalink
Merge pull request #2749 from mhashizume/FACT-3140/main/sles-lsblk-fixup
Browse files Browse the repository at this point in the history
Add error handling for older lsblk
  • Loading branch information
joshcooper authored Aug 29, 2024
2 parents b6cf607 + f0d4066 commit 8fadeeb
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion lib/facter/resolvers/partitions.rb
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,8 @@ def populate_from_lsblk(partition_name, blkid_and_lsblk)
return {} unless available?('lsblk', blkid_and_lsblk)

lsblk_version_raw = Facter::Core::Execution.execute('lsblk --version 2>&1', logger: log)
lsblk_version = lsblk_version_raw.match(/ \d\.\d+/)[0].to_f
# Return if the version of lsblk is too old (< 2.22) to support the --version flag
lsblk_version_raw.match?(/ \d\.\d+/) ? lsblk_version = lsblk_version_raw.match(/ \d\.\d+/)[0].to_f : (return {})

# The -p/--paths option was added in lsblk 2.23, return early and fall back to blkid with earlier versions
return {} if lsblk_version < 2.23
Expand Down

0 comments on commit 8fadeeb

Please sign in to comment.