From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from gate001.proxmox.com (gate001.proxmox.com [IPv6:2a0f:8001:1:32::40]) by lore.proxmox.com (Postfix) with ESMTPS id 013711FF065 for ; Mon, 23 Nov 2026 03:04:02 +0100 (CET) Received: from gate001.proxmox.com (localhost.localdomain [127.0.0.1]) by gate001.proxmox.com (Proxmox) with ESMTP id EF5B4216B7; Mon, 23 Nov 2026 03:01:24 +0100 (CET) From: Thomas Lamprecht To: pve-devel@lists.proxmox.com Subject: [PATCH v4 manager 23/25] pvestatd: notify on NVMe over Fabrics namespaces as on multipath maps Date: Mon, 23 Nov 2026 02:48:00 +0100 Message-ID: <20261123020041.3728085-24-t.lamprecht@proxmox.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20261123020041.3728085-1-t.lamprecht@proxmox.com> References: <20261123020041.3728085-1-t.lamprecht@proxmox.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Bm-Milter-Handled: 55990f41-d878-4baa-be0a-ee34c49e34d2 X-Bm-Transport-Timestamp: 1795399250993 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.147 Adjusted score from AWL reputation of From: address DMARC_MISSING 0.1 Missing DMARC policy KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment (newer systems) RCVD_IN_DNSWL_MED -2.3 Sender listed at https://www.dnswl.org/, medium trust SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record Message-ID-Hash: MYTZ6LYXSKVRUJDLZQ5FTWS4EFMQ2UX7 X-Message-ID-Hash: MYTZ6LYXSKVRUJDLZQ5FTWS4EFMQ2UX7 X-MailFrom: t.lamprecht@proxmox.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.10 Precedence: list List-Id: Proxmox VE development discussion List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: The report of a node lists the namespaces of its NVMe over Fabrics storages next to the multipath maps, so the notifications about lost and restored paths cover them too. Name the storages of a namespace in them as for a map, also the one that has it as base volume. Maps and namespaces each count by their own source. A report whose namespaces could not be listed does not count for the absence of a namespace, so that it is not taken as gone, but still for that of a map, so that a failing query does not keep the alert of a removed map. A node that cannot query multipathd still notifies on its namespaces, as they do not depend on it. Signed-off-by: Thomas Lamprecht --- PVE/MultipathNotification.pm | 21 +++++++++++++-------- PVE/Service/pvestatd.pm | 16 +++++++++------- test/MultipathNotification_test.pl | 28 ++++++++++++++++++++++++---- 3 files changed, 46 insertions(+), 19 deletions(-) diff --git a/PVE/MultipathNotification.pm b/PVE/MultipathNotification.pm index 99c79405b..34719643c 100644 --- a/PVE/MultipathNotification.pm +++ b/PVE/MultipathNotification.pm @@ -8,7 +8,7 @@ use List::Util qw(max); use PVE::File qw(file_get_contents file_set_contents); # the fields of a LUN that a notification shows, kept across a restart of the daemon -my @KEEP = qw(wwid name state paths-active paths-expected paths-total storages vgname); +my @KEEP = qw(wwid name native state paths-active paths-expected paths-total storages vgname); sub new($class, $file) { my $notified = -e $file ? eval { decode_json(file_get_contents($file)) } : {}; @@ -95,17 +95,19 @@ sub flush($self, $notify) { # Takes a multipath report of this node. A change counts once two reports in a row show it. sub update($self, $report, $notify) { - my $usable = ref($report) eq 'HASH' && !$report->{error} && !$report->{'scope-unknown'}; - my $luns = $usable ? $report->{luns} : undef; - # without the hints of LVM, maps known only by their volume group can be left out - my $complete = $usable && !$report->{'vgs-unknown'}; + my $valid = ref($report) eq 'HASH'; + # Maps need multipathd, the namespaces of native NVMe multipath do not. Each row counts by its + # own source, so a node without multipathd still notifies on its namespaces. + my $maps = $valid && !$report->{error} && !$report->{'scope-unknown'}; + my $namespaces = $valid && !$report->{'namespaces-unknown'}; my $previous = $self->{previous}; my $current = $self->{previous} = {}; - if (!defined($luns)) { + if (!$maps && !$namespaces) { # problems confirmed before do not wait for a report that can confirm others flush($self, $notify); return; } + my $luns = [grep { $_->{native} ? $namespaces : $maps } ($report->{luns} // [])->@*]; my $notified = $self->{notified}; # a problem that is still to be notified comes before the recovery of its LUN @@ -142,9 +144,12 @@ sub update($self, $report, $notify) { } } } - # a LUN can be left out of a report that is not complete, which does not mean it is gone + # A LUN can be left out of a report that is not complete, which does not mean it is gone: + # without the hints of LVM, maps known only by their volume group, and after a failed query the + # NVMe namespaces. Each counts by its own source. for my $wwid (sort keys %$notified) { - next if exists($current->{$wwid}) || !$complete; + next if exists($current->{$wwid}); + next if $notified->{$wwid}->{native} ? !$namespaces : !$maps || $report->{'vgs-unknown'}; if (++$self->{absent}->{$wwid} < 2) { $pending{recovery} = 1; next; diff --git a/PVE/Service/pvestatd.pm b/PVE/Service/pvestatd.pm index 68d7f2e08..3d9842c86 100755 --- a/PVE/Service/pvestatd.pm +++ b/PVE/Service/pvestatd.pm @@ -814,7 +814,7 @@ my sub notify_multipath { my $scfg = PVE::Storage::storage_check_node($storage, $sid, $nodename, 1) // next; push $by_vg{ $scfg->{vgname} }->@*, $sid if defined($scfg->{vgname}); my $base = PVE::Multipath::parse_base_volume($scfg->{base}); - push $by_wwid{ $base->{wwid} }->@*, $sid if $base && $base->{kind} ne 'nvme'; + push $by_wwid{ $base->{wwid} }->@*, $sid if $base; } my $data = PVE::Notify::common_template_data(); @@ -862,29 +862,31 @@ my sub notify_multipath { my ($n, $noun) = @_; return $n == 1 ? "1 $noun" : "$n ${noun}s"; }; + my %kinds = map { ($_->{native} ? 'namespace' : 'LUN') => 1 } $data->{luns}->@*; + my $device = scalar(keys %kinds) == 1 ? (keys %kinds)[0] : 'SAN device'; if ($severity eq 'info') { if ($restored && $cleared) { $data->{event} = 'alerts resolved'; $data->{summary} = - $plural->($restored, 'LUN') + $plural->($restored, $device) . ' restored, ' . $plural->($cleared, 'alert') . ' cleared'; } elsif ($cleared) { $data->{event} = 'alert cleared'; - $data->{summary} = $plural->($cleared, 'LUN'); + $data->{summary} = $plural->($cleared, $device); } else { $data->{event} = 'paths restored'; - $data->{summary} = $plural->($restored, 'LUN'); + $data->{summary} = $plural->($restored, $device); } } else { $data->{event} = 'paths lost'; if ($failed && $degraded) { - $data->{summary} = $plural->($failed, 'LUN') . " failed, $degraded degraded"; + $data->{summary} = $plural->($failed, $device) . " failed, $degraded degraded"; } elsif ($failed) { - $data->{summary} = $plural->($failed, 'LUN') . ' failed'; + $data->{summary} = $plural->($failed, $device) . ' failed'; } else { - $data->{summary} = $plural->($degraded, 'LUN') . ' degraded'; + $data->{summary} = $plural->($degraded, $device) . ' degraded'; } } $data->{failed} = $failed if $failed; diff --git a/test/MultipathNotification_test.pl b/test/MultipathNotification_test.pl index f78a31e6e..f33515fdd 100755 --- a/test/MultipathNotification_test.pl +++ b/test/MultipathNotification_test.pl @@ -92,14 +92,34 @@ pass_with( ); $tracker = PVE::MultipathNotification->new($file); pass_with({}, [], 'notified LUNs left the report across a restart'); -pass_with({}, [], 'but an incomplete report does not count', 0); -pass_with( - {}, +pass_with({}, [], 'but a report without the hints of LVM does not count', 0); +report_with( + { luns => [], 'namespaces-unknown' => 1 }, [['info', 'c:gone', 'd:gone']], - 'two complete reports without them clear their alerts', + 'one without the NVMe namespaces does for maps, so two reports clear their alerts', ); pass_with({}, [], 'no duplicate removal'); +my $namespace = { n => { state => 'degraded', native => 1 } }; +pass_with($namespace, [], 'a namespace degrades'); +pass_with($namespace, [['warning', 'n:degraded']], 'which is notified'); +report_with({ luns => [], 'namespaces-unknown' => 1 }, [], 'a report without it does not count'); +report_with({ luns => [], 'namespaces-unknown' => 1 }, [], 'also not a second one'); +pass_with({}, [], 'but one without the hints of LVM does', 0); +pass_with({}, [['info', 'n:gone']], 'and with another one its alert is cleared'); + +my sub without_multipathd($state) { + return { + error => 'multipathd is not running', + luns => [{ wwid => 'm', state => $state, native => 1 }], + }; +} +report_with(without_multipathd('failed'), [], 'without multipathd, a namespace fails'); +report_with(without_multipathd('failed'), [['error', 'm:failed']], + 'which is notified all the same'); +report_with(without_multipathd('optimal'), [], 'it recovers'); +report_with(without_multipathd('optimal'), [['info', 'm:optimal']], 'which is notified too'); + pass_with($degraded, [], 'new incident'); $accept = 0; pass_with($degraded, [['warning', 'a:degraded']], 'enqueue fails');