public inbox for pve-devel@lists.proxmox.com
 help / color / mirror / Atom feed
From: Thomas Lamprecht <t.lamprecht@proxmox.com>
To: pve-devel@lists.proxmox.com
Subject: [PATCH v8 storage 15/43] api: multipath: add the cluster-wide health status
Date: Thu, 19 Nov 2026 20:46:20 +0100	[thread overview]
Message-ID: <20261119194655.3163258-16-t.lamprecht@proxmox.com> (raw)
In-Reply-To: <20261119194655.3163258-1-t.lamprecht@proxmox.com>

Combine the reports of the nodes into one view: the state of each node,
and per LUN the state of its map on each node with the worst known one
as summary. A report older than three minutes, or of an offline node, is
ignored.

A node should have a LUN if an explicit entry, the iSCSI storage that
requests the map or a shared LVM storage on the LUN covers the node.
If such a node does not report the LUN, the LUN counts as missing
there. It counts as unknown if the node has no current report or no
usable multipath. The same holds if the node left maps out because it
does not know their volume groups, and knows the LUN only through the
volume group of a storage. Nodes also report the number of paths they
expect for each map, so that a map with fewer paths can show how many
are missing.

Each LUN also names the enabled iSCSI storage with multipath that
requests its map. This tells a map without an explicit entry apart
from one that nothing in Proxmox VE asked for. Storage admins can read
the status as well, as they need the initiator names for the access
rules on the array.

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
---
 src/PVE/API2/Multipath.pm           | 181 ++++++++++++++++++++++++++-
 src/PVE/Multipath/Status.pm         | 116 +++++++++++++++++
 src/test/run_multipath_api_tests.pl | 185 +++++++++++++++++++++++++++-
 3 files changed, 480 insertions(+), 2 deletions(-)

diff --git a/src/PVE/API2/Multipath.pm b/src/PVE/API2/Multipath.pm
index 027ad98b..2b31f851 100644
--- a/src/PVE/API2/Multipath.pm
+++ b/src/PVE/API2/Multipath.pm
@@ -10,6 +10,7 @@ use PVE::RESTHandler;
 use PVE::Tools qw(extract_param);
 
 use PVE::Multipath::Config;
+use PVE::Multipath::Status;
 
 use base qw(PVE::RESTHandler);
 
@@ -60,7 +61,185 @@ __PACKAGE__->register_method({
         links => [{ rel => 'child', href => "{name}" }],
     },
     code => sub {
-        return [map { +{ name => $_ } } qw(overrides wwid)];
+        return [map { +{ name => $_ } } qw(overrides status wwid)];
+    },
+});
+
+my $state_schema = {
+    type => 'string',
+    enum => ['optimal', 'degraded', 'failed', 'missing', 'unknown'],
+};
+my $lun_node_schema = {
+    type => 'object',
+    additionalProperties => 0,
+    properties => {
+        state => {
+            $state_schema->%*,
+            description => "The health of the map on the node from its paths, 'missing' if the"
+                . " node should have the map but does not list it, or 'unknown' if the node has no"
+                . " current report that covers the map.",
+        },
+        name => {
+            type => 'string',
+            optional => 1,
+            description => 'The name of the map on the node, if it differs from the WWID.',
+        },
+        size => {
+            type => 'integer',
+            minimum => 0,
+            optional => 1,
+            description => 'The size of the map in bytes.',
+        },
+        'paths-active' => {
+            type => 'integer',
+            minimum => 0,
+            optional => 1,
+            description => 'The number of active paths of the map whose checker state is ready,'
+                . ' ghost, or not reported.',
+        },
+        'paths-total' => {
+            type => 'integer',
+            minimum => 0,
+            optional => 1,
+            description => 'The number of paths of the map.',
+        },
+        'paths-expected' => {
+            type => 'integer',
+            minimum => 0,
+            optional => 1,
+            description => 'The number of paths the LUN should have on the node: the highest of'
+                . ' the count of its multipath entry and, for each managed iSCSI storage of the'
+                . ' LUN, the number of its portals.',
+        },
+    },
+};
+my $node_schema = {
+    type => 'object',
+    additionalProperties => 0,
+    properties => {
+        state => {
+            type => 'string',
+            enum => ['ok', 'unavailable', 'no-report'],
+            description => "'ok' if the node has a current report, 'unavailable' if its report"
+                . " has an 'error', or 'no-report' if the node is offline or its last report is"
+                . " missing or older than three minutes.",
+        },
+        time => {
+            type => 'integer',
+            optional => 1,
+            description => 'The time of the last report of the node (seconds since the UNIX'
+                . ' epoch).',
+        },
+        'other-maps' => {
+            type => 'integer',
+            minimum => 1,
+            optional => 1,
+            description => 'The number of multipath maps that the node leaves out of its LUN'
+                . ' list. It lists the maps that Proxmox VE manages and the ones it knows to be the'
+                . ' base volume of a storage or to hold its volume group.',
+        },
+        error => {
+            type => 'string',
+            optional => 1,
+            description => 'Why the node cannot report its multipath maps, for example because'
+                . ' multipathd is not running.',
+        },
+        'apply-error' => {
+            type => 'string',
+            optional => 1,
+            description => 'The error of the last attempt of the node to apply the cluster-wide'
+                . ' multipath configuration, for example a WWID that multipath refuses or a'
+                . ' failed reload of multipathd.',
+        },
+        'iscsi-initiator-name' => {
+            type => 'string',
+            optional => 1,
+            description => 'The iSCSI initiator name of the node.',
+        },
+    },
+};
+
+__PACKAGE__->register_method({
+    name => 'status',
+    path => 'status',
+    method => 'GET',
+    description => "Report the multipath health of each LUN on each node, and as summary the"
+        . " worst known state among the nodes that should see or report the LUN. Nodes whose"
+        . " state is unknown are not counted.",
+    # Storage administrators need path health and initiator names to configure SAN target ACLs.
+    permissions => {
+        check => [
+            'or', ['perm', '/', ['Sys.Audit']], ['perm', '/storage', ['Datastore.Allocate']],
+        ],
+    },
+    parameters => {
+        additionalProperties => 0,
+        properties => {},
+    },
+    returns => {
+        type => 'object',
+        properties => {
+            luns => {
+                type => 'array',
+                description =>
+                    "One entry per LUN, identified by its WWID, with the state of its"
+                    . " map on each node and the overall cluster state.",
+                items => {
+                    type => 'object',
+                    additionalProperties => 0,
+                    properties => {
+                        wwid => { type => 'string', description => 'The LUN WWID.' },
+                        explicit =>
+                            { type => 'boolean', description => 'An explicit entry exists.' },
+                        name => {
+                            type => 'string',
+                            optional => 1,
+                            description =>
+                                'The alias of the explicit entry, or else the name of'
+                                . ' the map on a node if it differs from the WWID.',
+                        },
+                        'used-by-storage' => {
+                            type => 'string',
+                            optional => 1,
+                            description =>
+                                'The storage that uses the LUN: as its base volume or through'
+                                . ' the volume group on it, or as an iSCSI storage that serves'
+                                . ' the LUNs of its target as images.',
+                        },
+                        'multipath-storage' => {
+                            type => 'string',
+                            optional => 1,
+                            description => 'The storage that requests the map of the LUN.',
+                        },
+                        size => {
+                            type => 'integer',
+                            minimum => 0,
+                            optional => 1,
+                            description =>
+                                'The size of the LUN in bytes, as a node reports it.',
+                        },
+                        state => {
+                            $state_schema->%*,
+                            description => "The worst state of the LUN among its nodes, or"
+                                . " 'unknown' if no node's state is known.",
+                        },
+                        nodes => {
+                            type => 'object',
+                            description => "Map health keyed by node name.",
+                            additionalProperties => $lun_node_schema,
+                        },
+                    },
+                },
+            },
+            nodes => {
+                type => 'object',
+                description => "The multipath status of each cluster node, keyed by node name.",
+                additionalProperties => $node_schema,
+            },
+        },
+    },
+    code => sub {
+        return PVE::Multipath::Status::cluster_status();
     },
 });
 
diff --git a/src/PVE/Multipath/Status.pm b/src/PVE/Multipath/Status.pm
index 006f57a7..ff79d613 100644
--- a/src/PVE/Multipath/Status.pm
+++ b/src/PVE/Multipath/Status.pm
@@ -8,11 +8,22 @@ use PVE::Cluster;
 use PVE::INotify;
 
 use PVE::Multipath;
+use PVE::Multipath::Config;
 use PVE::Multipath::Generator;
 
 my $json = JSON->new->utf8->canonical;
 my $KEY = 'multipath';
 
+sub worst_state(@states) {
+    my %rank = (unknown => -1, optimal => 0, degraded => 1, missing => 2, failed => 3);
+    my $worst = 'unknown';
+    for my $state (@states) {
+        $worst = $state
+            if defined($state) && exists($rank{$state}) && $rank{$state} > $rank{$worst};
+    }
+    return $worst;
+}
+
 sub publish($report) {
     my $node = PVE::INotify::nodename();
     my $now = time();
@@ -84,6 +95,8 @@ sub update_node_status() {
             $lun->{size} = $map->{size} if defined($map->{size});
             $lun->{name} = $map->{name} if defined($map->{name}) && $map->{name} ne $wwid;
             $lun->{storages} = $info->{storages} if $info->{storages};
+            $lun->{'paths-expected'} = $info->{'paths-expected'}
+                if defined($info->{'paths-expected'});
             $lun->{vgname} = $vg if defined($vg);
             push $report->{luns}->@*, $lun;
         }
@@ -110,4 +123,107 @@ sub update_node_status() {
     warn "multipath: cannot publish node status - $@" if $@;
 }
 
+sub cluster_status() {
+    require PVE::Storage;
+
+    my $cfg = PVE::Multipath::Config::read_config();
+    my $storage = PVE::Storage::config();
+    my $all_nodes = PVE::Cluster::get_nodelist();
+    my $members = PVE::Cluster::get_members();
+    my $raw = PVE::Cluster::get_node_kv($KEY);
+    my (%nodes, %luns, %expected, %observed, %vg_owner);
+    # the nodes that list a map because the configuration names it for them
+    my (%managed, %unhinted);
+    my $storage_nodes = sub($scfg) {
+        return $scfg->{nodes} && $scfg->{nodes}->%* ? [keys $scfg->{nodes}->%*] : $all_nodes;
+    };
+    # only an enabled iSCSI storage with the option requests the maps of its LUNs, on its nodes
+    my %current = map { $_ => 1 } @$all_nodes;
+    my $requests_maps = sub($sid, $node = undef) {
+        my $scfg = defined($sid) ? $storage->{ids}->{$sid} : undef;
+        my $requests = $scfg && $scfg->{type} eq 'iscsi' && $scfg->{'managed-multipath'};
+        return 0 if !$requests || $scfg->{disable};
+        my @nodes = grep { $current{$_} } $storage_nodes->($scfg)->@*;
+        return defined($node) ? !!grep({ $_ eq $node } @nodes) : !!@nodes;
+    };
+    for my $wwid (PVE::Multipath::Config::wwid_list($cfg)->@*) {
+        my $entry = $cfg->{ids}->{$wwid};
+        $luns{$wwid} = { wwid => $wwid, explicit => 1 };
+        $luns{$wwid}->{name} = $entry->{alias} if defined($entry->{alias});
+        $expected{$wwid}->{$_} = $managed{$wwid}->{$_} = 1 for $storage_nodes->($entry)->@*;
+    }
+    for my $sid (sort keys $storage->{ids}->%*) {
+        my $scfg = $storage->{ids}->{$sid};
+        $vg_owner{ $scfg->{vgname} } //= $sid if defined($scfg->{vgname});
+        next if $scfg->{type} ne 'lvm';
+        my ($base, $volname) = PVE::Storage::parse_volume_id($scfg->{base} // '', 1);
+        my ($wwid) = ($volname // '') =~ /(?:^|\.)dm-uuid-(?:part\d+-)?mpath-(\S+)$/;
+        next if !defined($wwid);
+        $luns{$wwid} //= { wwid => $wwid, explicit => 0 };
+        $luns{$wwid}->{'used-by-storage'} //= $sid;
+        $managed{$wwid}->{$_} = 1 for @$all_nodes;
+        $luns{$wwid}->{'multipath-storage'} //= $base if $requests_maps->($base);
+        $expected{$wwid}->{$_} = 1 for $storage_nodes->($scfg)->@*;
+    }
+    for my $node (sort @$all_nodes) {
+        my $report = eval { decode_json($raw->{$node} // '') };
+        $report = {} if ref($report) ne 'HASH';
+        my $entry = $nodes{$node} = { state => 'no-report' };
+        $entry->{time} = $report->{time} if defined($report->{time});
+        my $offline = exists($members->{$node}) && !$members->{$node}->{online};
+        next if $offline || !defined($report->{time}) || time() - $report->{time} > 180;
+        my @keys = qw(error apply-error iscsi-initiator-name other-maps);
+        $entry->{$_} = $report->{$_} for grep { defined($report->{$_}) } @keys;
+        $entry->{state} = defined($report->{error}) ? 'unavailable' : 'ok';
+        $unhinted{$node} = 1 if $report->{'vgs-unknown'};
+        next if $entry->{state} ne 'ok';
+
+        for my $lun (($report->{luns} // [])->@*) {
+            my $wwid = $lun->{wwid} // next;
+            my $row = $luns{$wwid} //= { wwid => $wwid, explicit => 0 };
+            $row->{$_} //= $lun->{$_} for grep { defined($lun->{$_}) } qw(name size);
+            my $owner = defined($lun->{vgname}) ? $vg_owner{ $lun->{vgname} } : undef;
+            $row->{'used-by-storage'} //= $owner if defined($owner);
+            # a shared LVM storage on the map needs it on its nodes, also without a base volume
+            my $lvm = defined($owner) ? $storage->{ids}->{$owner} : undef;
+            if ($lvm && $lvm->{type} eq 'lvm' && $lvm->{shared} && !$lvm->{disable}) {
+                $expected{$wwid}->{$_} = 1 for $storage_nodes->($lvm)->@*;
+            }
+            for my $sid (($lun->{storages} // [])->@*) {
+                my $scfg = $storage->{ids}->{$sid} // next;
+                $row->{'multipath-storage'} //= $sid if $requests_maps->($sid, $node);
+                $row->{'used-by-storage'} //= $sid
+                    if PVE::Storage::san_storage_serves_images($scfg);
+                $expected{$wwid}->{$_} = 1
+                    for !$scfg->{disable} ? $storage_nodes->($scfg)->@* : ();
+                $managed{$wwid}->{$_} = 1
+                    for $requests_maps->($sid) ? $storage_nodes->($scfg)->@* : ();
+            }
+            $observed{$wwid}->{$node} = {
+                state => worst_state($lun->{state}),
+                map { $_ => $lun->{$_} }
+                    grep { defined($lun->{$_}) }
+                    qw(name size paths-active paths-total paths-expected),
+            };
+        }
+    }
+    for my $wwid (sort keys %luns) {
+        my $row = $luns{$wwid};
+        $row->{nodes} = {};
+        for my $node (sort @$all_nodes) {
+            if ($observed{$wwid}->{$node}) {
+                $row->{nodes}->{$node} = $observed{$wwid}->{$node};
+            } elsif ($expected{$wwid}->{$node}) {
+                my $listed = $nodes{$node}->{state} eq 'ok';
+                # without the hint file of LVM a node leaves a map out that it only knows through
+                # the volume group of a storage
+                $listed = 0 if $unhinted{$node} && !$managed{$wwid}->{$node};
+                $row->{nodes}->{$node} = { state => $listed ? 'missing' : 'unknown' };
+            }
+        }
+        $row->{state} = worst_state(map { $_->{state} } values $row->{nodes}->%*);
+    }
+    return { nodes => \%nodes, luns => [map { $luns{$_} } sort keys %luns] };
+}
+
 1;
diff --git a/src/test/run_multipath_api_tests.pl b/src/test/run_multipath_api_tests.pl
index 230fcaae..d968e347 100755
--- a/src/test/run_multipath_api_tests.pl
+++ b/src/test/run_multipath_api_tests.pl
@@ -57,7 +57,7 @@ subtest 'explicit entries are ordinary configuration writes' => sub {
     }
     is_deeply(
         PVE::API2::Multipath->index({}),
-        [map { { name => $_ } } qw(overrides wwid)],
+        [map { { name => $_ } } qw(overrides status wwid)],
         'index',
     );
 };
@@ -455,6 +455,8 @@ subtest 'a LUN of a storage without a map is missing' => sub {
     my $iscsi = Test::MockModule->new('PVE::Storage::ISCSIPlugin');
     my $storage = Test::MockModule->new('PVE::Storage');
     my $lvm = Test::MockModule->new('PVE::Storage::LVMPlugin');
+    my $cluster = Test::MockModule->new('PVE::Cluster');
+    my $config = Test::MockModule->new('PVE::Multipath::Config');
     my %raw;
     $status->mock(publish => sub { $raw{n1} = encode_json({ $_[0]->%*, time => $NOW }) });
     $iscsi->mock(read_initiator_info => sub { undef });
@@ -480,6 +482,13 @@ subtest 'a LUN of a storage without a map is missing' => sub {
         [{ wwid => '3600a', state => 'missing', storages => ['san'], 'paths-expected' => 2 }],
         'the LUN of the storage, not one of an entry, nor one added in this pass',
     );
+    $cluster->mock(get_nodelist => sub { ['n1'] }, get_members => sub { {} });
+    $cluster->mock(get_node_kv => sub { \%raw });
+    $config->mock(read_config => sub { { ids => {} } });
+    my ($row) = PVE::Multipath::Status::cluster_status()->{luns}->@*;
+    is($row->{wwid}, '3600a', 'the cluster status lists it');
+    is($row->{state}, 'missing', 'as missing');
+    is($row->{'multipath-storage'}, 'san', 'with the storage that requests it');
 };
 
 subtest 'one entry point applies configuration and reports unavailable reasons' => sub {
@@ -516,7 +525,181 @@ subtest 'one entry point applies configuration and reports unavailable reasons'
         sub { [{ wwid => '3600a', name => 'data', 'paths-active' => 1, 'paths-total' => 2 }] });
     PVE::Multipath::Status::update_node_status();
     is($report->{luns}->[0]->{state}, 'degraded', 'all maps while the wanted ones are unknown');
+    ok(!exists($report->{luns}->[0]->{'paths-expected'}), 'no expected count without a source');
+    $gen->mock(sync => sub { { wwids => { '3600a' => { 'paths-expected' => 3 } } } });
+    $mp->mock(get_maps =>
+        sub { [{ wwid => '3600a', name => 'data', 'paths-active' => 2, 'paths-total' => 2 }] });
+    PVE::Multipath::Status::update_node_status();
+    is($report->{luns}->[0]->{'paths-expected'}, 3, 'expected count reported');
+    is($report->{luns}->[0]->{state}, 'degraded', 'fewer paths than expected');
     ok(!exists($report->{supported}), 'the report has no separate "supported" field');
 };
 
+subtest 'API returns final node and LUN states' => sub {
+    my $cluster = Test::MockModule->new('PVE::Cluster');
+    my $config = Test::MockModule->new('PVE::Multipath::Config');
+    my $storage = Test::MockModule->new('PVE::Storage');
+    $cluster->mock(get_nodelist => sub { [qw(n1 n2 n3 n4 n5)] });
+    $cluster->mock(get_members => sub { { n4 => { online => 0 } } });
+    my %raw = (
+        n1 => encode_json({
+            time => $NOW,
+            luns => [
+                {
+                    wwid => '3600a',
+                    state => 'optimal',
+                    'paths-total' => 2,
+                    'paths-active' => 2,
+                    'paths-expected' => 2,
+                    storages => ['iscsi'],
+                    vgname => 'vgfc',
+                },
+                {
+                    wwid => '3600d',
+                    state => 'optimal',
+                    'paths-total' => 2,
+                    'paths-active' => 2,
+                    storages => ['off'],
+                    vgname => 'vgshared',
+                },
+                {
+                    wwid => '3600f',
+                    state => 'optimal',
+                    'paths-total' => 2,
+                    'paths-active' => 2,
+                    storages => ['scoped'],
+                },
+            ],
+        }),
+        n2 => encode_json({ time => $NOW, luns => [] }),
+        n3 => encode_json({ time => $NOW - 181, luns => [] }),
+        n4 => encode_json({ time => $NOW, luns => [] }),
+        n5 => encode_json({ time => $NOW, error => 'multipath-tools is not installed' }),
+    );
+    $cluster->mock(get_node_kv => sub { \%raw });
+    my $entries = { '3600a' => { type => 'wwid' } };
+    $config->mock(read_config => sub { { ids => $entries } });
+    $storage->mock(
+        config => sub { {
+            ids => {
+                iscsi => { type => 'iscsi', 'managed-multipath' => 1 },
+                lvm => { type => 'lvm', base => 'iscsi:0.0.0.dm-uuid-mpath-3600b' },
+                fc => { type => 'lvm', vgname => 'vgfc' },
+                off => { type => 'iscsi' },
+                lvmoff => { type => 'lvm', base => 'off:0.0.0.dm-uuid-mpath-3600c' },
+                shared => { type => 'lvm', vgname => 'vgshared', shared => 1 },
+                gone =>
+                    { type => 'iscsi', 'managed-multipath' => 1, nodes => { departed => 1 } },
+                lvmgone => { type => 'lvm', base => 'gone:0.0.0.dm-uuid-mpath-3600e' },
+                scoped => { type => 'iscsi', 'managed-multipath' => 1, nodes => { n2 => 1 } },
+            },
+        } },
+    );
+    my $res = PVE::API2::Multipath->status({});
+    is_deeply(
+        [map { $res->{nodes}->{$_}->{state} } qw(n1 n2 n3 n4 n5)],
+        [qw(ok ok no-report no-report unavailable)],
+        'final node states',
+    );
+    is($res->{nodes}->{n3}->{time}, $NOW - 181, 'old report time retained');
+    my $lun = $res->{luns}->[0];
+    is($lun->{state}, 'missing', 'worst known state');
+    is($lun->{nodes}->{n1}->{state}, 'optimal', 'observed healthy map');
+    is($lun->{nodes}->{n2}->{state}, 'missing', 'expected map absent from current report');
+    is($lun->{nodes}->{n3}->{state}, 'unknown', 'stale observation');
+    is($lun->{'used-by-storage'}, 'fc', 'storage attributed through the reported volume group');
+    is($res->{luns}->[1]->{wwid}, '3600b', 'LVM base included without observation');
+    is($res->{luns}->[1]->{'used-by-storage'}, 'lvm', 'LVM consumer attributed');
+    is($lun->{'multipath-storage'}, 'iscsi', 'reported storage requests the map');
+    is($res->{luns}->[1]->{'multipath-storage'}, 'iscsi', 'base storage requests the map');
+    is($lun->{nodes}->{n1}->{'paths-expected'}, 2, 'expected path count of the node');
+    my %lun = map { $_->{wwid} => $_ } $res->{luns}->@*;
+    ok(
+        !exists($lun{'3600c'}->{'multipath-storage'}),
+        'a base without multipath requests nothing',
+    );
+    ok(!exists($lun{'3600d'}->{'multipath-storage'}), 'neither does a reported one');
+    ok(
+        !exists($lun{'3600e'}->{'multipath-storage'}),
+        'a base for no current node requests nothing',
+    );
+    ok(!exists($lun{'3600f'}->{'multipath-storage'}), 'a storage requests on its nodes only');
+    is(
+        $lun{'3600d'}->{nodes}->{n2}->{state},
+        'missing',
+        'the nodes of a shared LVM expect the map',
+    );
+    is($lun{'3600d'}->{'used-by-storage'}, 'shared', 'shared LVM attributed by volume group');
+    {
+        local $raw{n2} = encode_json({ time => $NOW, luns => [], 'vgs-unknown' => 1 });
+        my %unhinted = map { $_->{wwid} => $_ } PVE::API2::Multipath->status({})->{luns}->@*;
+        is(
+            $unhinted{'3600d'}->{nodes}->{n2}->{state},
+            'unknown',
+            'a node without LVM hints may have left out the map of a volume group',
+        );
+        is($unhinted{'3600a'}->{nodes}->{n2}->{state}, 'missing', 'but for one with an entry');
+        is(
+            $unhinted{'3600f'}->{nodes}->{n2}->{state},
+            'missing',
+            'and for one that an iSCSI storage requests there',
+        );
+        local $entries->{'3600d'} = { type => 'wwid', nodes => { n1 => 1 } };
+        %unhinted = map { $_->{wwid} => $_ } PVE::API2::Multipath->status({})->{luns}->@*;
+        is(
+            $unhinted{'3600d'}->{nodes}->{n2}->{state},
+            'unknown',
+            'an entry for other nodes does not change that',
+        );
+    }
+    eval {
+        PVE::JSONSchema::validate(
+            $res,
+            PVE::API2::Multipath->map_method_by_name('status')->{returns},
+        );
+    };
+    is($@, '', 'result satisfies the API schema');
+    is(
+        PVE::Multipath::Status::worst_state(qw(unknown optimal failed degraded missing)),
+        'failed',
+        'one ranking',
+    );
+};
+
+subtest 'every storage that requests a map counts' => sub {
+    my $cluster = Test::MockModule->new('PVE::Cluster');
+    my $config = Test::MockModule->new('PVE::Multipath::Config');
+    my $storage = Test::MockModule->new('PVE::Storage');
+    $cluster->mock(get_nodelist => sub { [qw(n1 n2 n3)] });
+    $cluster->mock(get_members => sub { {} });
+    my $lun = {
+        wwid => '3600x',
+        state => 'optimal',
+        'paths-total' => 2,
+        'paths-active' => 2,
+        storages => [qw(s1 s2)],
+    };
+    my %raw = map { $_ => encode_json({ time => $NOW, luns => [$lun] }) } qw(n1 n2);
+    $raw{n3} = encode_json({ time => $NOW, luns => [] });
+    $cluster->mock(get_node_kv => sub { \%raw });
+    $config->mock(read_config => sub { { ids => {} } });
+    $storage->mock(
+        config => sub { {
+            ids => {
+                s1 =>
+                    { type => 'iscsi', 'managed-multipath' => 1, nodes => { n1 => 1, n2 => 1 } },
+                s2 => {
+                    type => 'iscsi',
+                    'managed-multipath' => 1,
+                    nodes => { n3 => 1 },
+                    content => { images => 1 },
+                },
+            },
+        } },
+    );
+    my ($row) = PVE::Multipath::Status::cluster_status()->{luns}->@*;
+    is($row->{nodes}->{n3}->{state}, 'missing', 'a node of the second storage expects the map');
+    is($row->{'used-by-storage'}, 's2', 'which serves its LUNs');
+};
+
 done_testing();




  parent reply	other threads:[~2026-11-19 19:53 UTC|newest]

Thread overview: 44+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-19 19:46 [PATCH v8 cluster,storage,docs,manager 00/43] SAN: cluster-wide multipath, SAN views and a guided setup for shared LVM Thomas Lamprecht
2026-11-19 19:46 ` [PATCH v8 cluster 01/43] cfs: observe the multipath configuration files Thomas Lamprecht
2026-11-19 19:46 ` [PATCH v8 storage 02/43] diskmanage: collect disk transport type from lsblk Thomas Lamprecht
2026-11-19 19:46 ` [PATCH v8 storage 03/43] diskmanage: qualify NVMe over Fabrics transport Thomas Lamprecht
2026-11-19 19:46 ` [PATCH v8 storage 04/43] diskmanage: optionally include iSCSI session devices in disk enumeration Thomas Lamprecht
2026-11-19 19:46 ` [PATCH v8 storage 05/43] diskmanage: collect native NVMe multipath path state Thomas Lamprecht
2026-11-19 19:46 ` [PATCH v8 storage 06/43] iscsi: factor out session device map from device list Thomas Lamprecht
2026-11-19 19:46 ` [PATCH v8 storage 07/43] multipath: add a library around multipathd Thomas Lamprecht
2026-11-19 19:46 ` [PATCH v8 storage 08/43] diskmanage: add helper to list multipath devices Thomas Lamprecht
2026-11-19 19:46 ` [PATCH v8 storage 09/43] multipath: add a cluster-wide configuration Thomas Lamprecht
2026-11-19 19:46 ` [PATCH v8 storage 10/43] iscsi: add an option to manage storage LUNs with multipath Thomas Lamprecht
2026-11-19 19:46 ` [PATCH v8 storage 11/43] lvm: activate a missing base volume before using the volume group Thomas Lamprecht
2026-11-19 19:46 ` [PATCH v8 storage 12/43] multipath: apply the configuration on every node Thomas Lamprecht
2026-11-19 19:46 ` [PATCH v8 storage 13/43] multipath: publish per-node status Thomas Lamprecht
2026-11-19 19:46 ` [PATCH v8 storage 14/43] api: add endpoints for the cluster-wide multipath configuration Thomas Lamprecht
2026-11-19 19:46 ` Thomas Lamprecht [this message]
2026-11-19 19:46 ` [PATCH v8 storage 16/43] diskmanage: look up the requested disks by name Thomas Lamprecht
2026-11-19 19:46 ` [PATCH v8 storage 17/43] diskmanage: read the udev data of all disks with one call Thomas Lamprecht
2026-11-19 19:46 ` [PATCH v8 storage 18/43] api: scan: add a SAN LUN inventory Thomas Lamprecht
2026-11-19 19:46 ` [PATCH v8 storage 19/43] pvesm: expose the " Thomas Lamprecht
2026-11-19 19:46 ` [PATCH v8 storage 20/43] api: add node-level iSCSI status Thomas Lamprecht
2026-11-19 19:46 ` [PATCH v8 storage 21/43] api: scan: name the portal of an iSCSI path Thomas Lamprecht
2026-11-19 19:46 ` [PATCH v8 storage 22/43] disks: lvm: drop unused imports Thomas Lamprecht
2026-11-19 19:46 ` [PATCH v8 storage 23/43] disks: lvm: allow volume groups on SAN LUNs and multipath maps Thomas Lamprecht
2026-11-19 19:46 ` [PATCH v8 storage 24/43] disks: lvm: refuse to destroy the volume group of a shared storage Thomas Lamprecht
2026-11-19 19:46 ` [PATCH v8 storage 25/43] disks: allow wiping a SAN LUN that no storage uses Thomas Lamprecht
2026-11-19 19:46 ` [PATCH v8 storage 26/43] api: scan: report the process that has a SAN LUN open Thomas Lamprecht
2026-11-19 19:46 ` [PATCH v8 docs 27/43] storage: document the cluster-wide multipath management Thomas Lamprecht
2026-11-19 19:46 ` [PATCH v8 docs 28/43] storage: multipath: describe the use shown for an open LUN Thomas Lamprecht
2026-11-19 19:46 ` [PATCH v8 manager 29/43] pvestatd: apply the multipath configuration and report the node status Thomas Lamprecht
2026-11-19 19:46 ` [PATCH v8 manager 30/43] report: add the managed multipath configuration Thomas Lamprecht
2026-11-19 19:46 ` [PATCH v8 manager 31/43] api: cluster: add the multipath endpoints Thomas Lamprecht
2026-11-19 19:46 ` [PATCH v8 manager 32/43] api: nodes: expose the iSCSI status Thomas Lamprecht
2026-11-19 19:46 ` [PATCH v8 manager 33/43] ui: dc: add a SAN view Thomas Lamprecht
2026-11-19 19:46 ` [PATCH v8 manager 34/43] ui: storage: iscsi: add the multipath option Thomas Lamprecht
2026-11-19 19:46 ` [PATCH v8 manager 35/43] ui: lvm: enable shared when a base storage is selected Thomas Lamprecht
2026-11-19 19:46 ` [PATCH v8 manager 36/43] ui: node: add SAN LUNs panel Thomas Lamprecht
2026-11-19 19:46 ` [PATCH v8 manager 37/43] ui: node: san: wipe a LUN that no storage uses Thomas Lamprecht
2026-11-19 19:46 ` [PATCH v8 manager 38/43] ui: node: san: show iSCSI targets and sessions Thomas Lamprecht
2026-11-19 19:46 ` [PATCH v8 manager 39/43] ui: dc: san: add a guided setup for shared LVM on iSCSI Thomas Lamprecht
2026-11-19 19:46 ` [PATCH v8 manager 40/43] ui: dc: san: add a guided setup for shared LVM on Fibre Channel Thomas Lamprecht
2026-11-19 19:46 ` [PATCH v8 manager 41/43] ui: storage: point the iSCSI and LVM add dialogs to the SAN view Thomas Lamprecht
2026-11-19 19:46 ` [PATCH v8 manager 42/43] ui: san: show the guest or process that has a LUN open Thomas Lamprecht
2026-11-19 19:46 ` [PATCH v8 manager 43/43] ui: node: san: add a column for the target or subsystem of a LUN Thomas Lamprecht

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261119194655.3163258-16-t.lamprecht@proxmox.com \
    --to=t.lamprecht@proxmox.com \
    --cc=pve-devel@lists.proxmox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal