fix #6389: api: disks: zfs: parse the message of hot spares in use

Hot spares have no error counters in the output of 'zpool status', so a
spare that is in use only has a message after its state:

  nvme10n1      INUSE     currently in use

The parser took the three words of that message as READ, WRITE and
CKSUM counters, so the API returned zero for all of them and lost the
message, while logging warnings like:

  Argument "currently" isn't numeric in addition (+)

As 'zpool status' is called with '-p', the counters are always plain
numbers, so only accept digits for them. This way, the message of a
spare in use ends up in 'msg', like for any other vdev.

Signed-off-by: Michal Fox <me@dualfroz.com>
This commit is contained in:
dualfroz committed 2026-10-02 16:17:54 +02:00
1 parent 6320a3a111
commit 467e6d641e
2 files changed
+104 -1

No files matched your search

+1 -1
View File
@@ -245,7 +245,7 @@ __PACKAGE__->register_method({
$config = 1;
} elsif (
$config
&& $line =~ m/^(\s+)(\S+)\s*(\S+)?(?:\s+(\S+)\s+(\S+)\s+(\S+))?\s*(.*)$/
&& $line =~ m/^(\s+)(\S+)\s*(\S+)?(?:\s+(\d+)\s+(\d+)\s+(\d+))?\s*(.*)$/
) {
my ($space, $name, $state, $read, $write, $cksum, $msg) =
($1, $2, $3, $4, $5, $6, $7);