Skip to content

Commit

Permalink
Merge pull request #1549 from chef/zpool
Browse files Browse the repository at this point in the history
Properly detect NVME/XVD devices in ZFS zpools
  • Loading branch information
tas50 authored Oct 30, 2020
2 parents 3aa7e49 + 011804b commit 964c39a
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
2 changes: 1 addition & 1 deletion lib/ohai/plugins/zpools.rb
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ def gather_pool_info
# linux: http://rubular.com/r/J3wQC6E2lH
# solaris: http://rubular.com/r/FqOBzUQQ4p
# freebsd: http://rubular.com/r/RYkMNlytXl
when /^\s+((sd|c|ad|da)[-_a-zA-Z0-9]+)\s+([-_a-zA-Z0-9]+)\s+(\d+)\s+(\d+)\s+(\d+)$/
when /^\s+((sd|c|ad|da|nvme|xvd)[-_a-zA-Z0-9]+)\s+([-_a-zA-Z0-9]+)\s+(\d+)\s+(\d+)\s+(\d+)$/
logger.trace("Plugin Zpools: Parsing zpool status line: #{line.chomp}")
pools[pool][:devices][$1] = Mash.new
pools[pool][:devices][$1][:state] = $3
Expand Down
22 changes: 11 additions & 11 deletions spec/unit/plugins/zpools_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,12 @@
sdg ONLINE 0 0 0
sdh ONLINE 0 0 0
raidz2-1 ONLINE 0 0 0
sdi ONLINE 0 0 0
sdj ONLINE 0 0 0
sdk ONLINE 0 0 0
sdl ONLINE 0 0 0
sdm ONLINE 0 0 0
sdn ONLINE 0 0 0
nvme0n1 ONLINE 0 0 0
nvme1n1 ONLINE 0 0 0
nvme2n1 ONLINE 0 0 0
nvme3n1 ONLINE 0 0 0
nvme4n1 ONLINE 0 0 0
nvme5n1 ONLINE 0 0 0
EOST
end
let(:zpool_out) do
Expand All @@ -60,8 +60,8 @@
NAME STATE READ WRITE CKSUM
rpool ONLINE 0 0 0
mirror-0 ONLINE 0 0 0
sda ONLINE 0 0 0
sdb ONLINE 0 0 0
xvda ONLINE 0 0 0
xvdb ONLINE 0 0 0
errors: No known data errors
EOSR
Expand Down Expand Up @@ -117,10 +117,10 @@
expect(plugin[:zpools][:tank][:health]).to match("ONLINE")
end

it "Has the correct number of devices" do
it "Has the correct devices per zpool" do
plugin.run
expect(plugin[:zpools][:rpool][:devices].keys.size).to match(2)
expect(plugin[:zpools][:tank][:devices].keys.size).to match(12)
expect(plugin[:zpools][:rpool][:devices].keys).to match(%w{xvda xvdb})
expect(plugin[:zpools][:tank][:devices].keys).to match(%w{sdc sdd sde sdf sdg sdh nvme0n1 nvme1n1 nvme2n1 nvme3n1 nvme4n1 nvme5n1})
end

it "Won't have a version number" do
Expand Down

0 comments on commit 964c39a

Please sign in to comment.