api: smart: return unknown health instead of error message

In case of an error, the WebGUI expects the SMART data API endpoint to
return a health value, but it will return an error message directly. To
make this more user friendly, mask the error in the API handler.

Signed-off-by: Daniel Kral <d.kral@proxmox.com>
Link: https://lore.proxmox.com/20250415071123.36921-1-d.kral@proxmox.com
This commit is contained in:
Daniel Kral
2025-04-15 09:11:21 +02:00
committed by Thomas Lamprecht
parent 7b41368fc3
commit 0d2df3048a

View File

@ -216,7 +216,7 @@ __PACKAGE__->register_method({
my $disk = PVE::Diskmanage::verify_blockdev_path($param->{disk}); my $disk = PVE::Diskmanage::verify_blockdev_path($param->{disk});
my $result = PVE::Diskmanage::get_smart_data($disk, $param->{healthonly}); my $result = eval { PVE::Diskmanage::get_smart_data($disk, $param->{healthonly}) };
$result->{health} = 'UNKNOWN' if !defined $result->{health}; $result->{health} = 'UNKNOWN' if !defined $result->{health};
$result = { health => $result->{health} } if $param->{healthonly}; $result = { health => $result->{health} } if $param->{healthonly};