all lists on lists.proxmox.com
 help / color / mirror / Atom feed
From: Dominik Csapak <d.csapak@proxmox.com>
To: pve-devel@lists.proxmox.com
Subject: [PATCH pve-storage 1/3] multipath: status: only report initiator name if open-iscsi is installed
Date: Fri, 20 Nov 2026 13:51:53 +0100	[thread overview]
Message-ID: <20261120125236.2393788-2-d.csapak@proxmox.com> (raw)
In-Reply-To: <20261120125236.2393788-1-d.csapak@proxmox.com>

when open-iscsi is removed but not purged, the file with the
initiator name stays, so the node still reported it. A leftover name
is of no use and should not end up in e.g. the access list of an
array, so only report it if iscsiadm is executable (like the iSCSI
status API call of a node checks).

With that, a node without an initiator name does not have a usable
open-iscsi (the package generates the name on installation, and
iscsid does not start without it), so the UI can use that to show
which nodes are missing it.

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
---
 src/PVE/API2/Multipath.pm           |  2 +-
 src/PVE/Multipath/Status.pm         |  9 ++++++---
 src/test/run_multipath_api_tests.pl | 16 ++++++++++++----
 3 files changed, 19 insertions(+), 8 deletions(-)

diff --git a/src/PVE/API2/Multipath.pm b/src/PVE/API2/Multipath.pm
index 59ca0eb..24955b3 100644
--- a/src/PVE/API2/Multipath.pm
+++ b/src/PVE/API2/Multipath.pm
@@ -154,7 +154,7 @@ my $node_schema = {
         'iscsi-initiator-name' => {
             type => 'string',
             optional => 1,
-            description => 'The iSCSI initiator name of the node.',
+            description => 'The iSCSI initiator name of the node, if open-iscsi is installed.',
         },
     },
 };
diff --git a/src/PVE/Multipath/Status.pm b/src/PVE/Multipath/Status.pm
index 1f13109..77da988 100644
--- a/src/PVE/Multipath/Status.pm
+++ b/src/PVE/Multipath/Status.pm
@@ -62,9 +62,12 @@ sub update_node_status() {
     my $report = { luns => [] };
     $report->{'apply-error'} = $apply->{error} if defined($apply->{error});
     require PVE::Storage::ISCSIPlugin;
-    my $initiator = eval { PVE::Storage::ISCSIPlugin::read_initiator_info() };
-    $report->{'iscsi-initiator-name'} = $initiator->{name}
-        if $initiator && defined($initiator->{name});
+    # the initiator name stays if open-iscsi is removed but not purged, so skip it then
+    if (PVE::Storage::ISCSIPlugin::iscsi_supported()) {
+        my $initiator = eval { PVE::Storage::ISCSIPlugin::read_initiator_info() };
+        $report->{'iscsi-initiator-name'} = $initiator->{name}
+            if $initiator && defined($initiator->{name});
+    }
     eval {
         die "multipath-tools is not installed\n" if !PVE::Multipath::is_supported();
         die "multipathd is not running or does not respond\n" if !PVE::Multipath::is_running();
diff --git a/src/test/run_multipath_api_tests.pl b/src/test/run_multipath_api_tests.pl
index 07ab562..e0dfb04 100755
--- a/src/test/run_multipath_api_tests.pl
+++ b/src/test/run_multipath_api_tests.pl
@@ -454,7 +454,7 @@ subtest 'an unconfigured node does not write drop-ins or reload' => sub {
         $mp->mock($function => sub { push @changes, $function });
     }
     my $iscsi = Test::MockModule->new('PVE::Storage::ISCSIPlugin');
-    $iscsi->mock(read_initiator_info => sub { {} });
+    $iscsi->mock(read_initiator_info => sub { {} }, iscsi_supported => sub { 1 });
     my $status = Test::MockModule->new('PVE::Multipath::Status');
     my $report;
     $status->mock(publish => sub { $report = $_[0] });
@@ -563,7 +563,7 @@ subtest 'only managed maps and those under a storage get a row' => sub {
     my $lvm = Test::MockModule->new('PVE::Storage::LVMPlugin');
     my $report;
     $status->mock(publish => sub { $report = $_[0] });
-    $iscsi->mock(read_initiator_info => sub { undef });
+    $iscsi->mock(read_initiator_info => sub { undef }, iscsi_supported => sub { 1 });
     $mp->mock(is_supported => sub { 1 }, is_running => sub { 1 });
     $mp->mock(
         get_maps => sub {
@@ -636,7 +636,7 @@ subtest 'a LUN of a storage without a map is missing' => sub {
     my $config = Test::MockModule->new('PVE::Multipath::Config');
     my %raw;
     $status->mock(publish => sub { $raw{n1} = encode_report({ $_[0]->%*, time => $NOW }) });
-    $iscsi->mock(read_initiator_info => sub { undef });
+    $iscsi->mock(read_initiator_info => sub { undef }, iscsi_supported => sub { 1 });
     $mp->mock(is_supported => sub { 1 }, is_running => sub { 1 }, get_maps => sub { [] });
     $lvm->mock(cached_pv_volume_groups => sub { {} });
     $gen->mock(
@@ -676,7 +676,10 @@ subtest 'one entry point applies configuration and reports unavailable reasons'
     my ($report, @order);
     $gen->mock(sync => sub { push @order, 'apply'; { error => 'reload failed' } });
     $status->mock(publish => sub { push @order, 'publish'; $report = $_[0] });
-    $iscsi->mock(read_initiator_info => sub { { name => 'iqn.2025-01.example:node' } });
+    $iscsi->mock(
+        read_initiator_info => sub { { name => 'iqn.2025-01.example:node' } },
+        iscsi_supported => sub { 1 },
+    );
     $mp->mock(is_supported => sub { 0 });
     PVE::Multipath::Status::update_node_status();
     is($report->{error}, 'multipath-tools is not installed', 'missing tools reason only');
@@ -686,6 +689,11 @@ subtest 'one entry point applies configuration and reports unavailable reasons'
         'the configuration is applied before the status is published',
     );
     is($report->{'apply-error'}, 'reload failed', 'apply failure is separate');
+    is($report->{'iscsi-initiator-name'}, 'iqn.2025-01.example:node', 'initiator name reported');
+    $iscsi->mock(iscsi_supported => sub { 0 });
+    PVE::Multipath::Status::update_node_status();
+    ok(!exists($report->{'iscsi-initiator-name'}), 'no leftover name without open-iscsi');
+    $iscsi->mock(iscsi_supported => sub { 1 });
     $mp->mock(is_supported => sub { 1 });
     $mp->mock(is_running => sub { 0 });
     PVE::Multipath::Status::update_node_status();
-- 
2.47.3





  reply	other threads:[~2026-11-20 12:53 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-20 12:51 [PATCH manager/storage 0/3] san: show and check for missing open-iscsi on nodes Dominik Csapak
2026-11-20 12:51 ` Dominik Csapak [this message]
2026-11-20 12:51 ` [PATCH pve-manager 2/3] ui: san: iscsi guided setup: don't allow nodes without open-iscsi Dominik Csapak
2026-11-20 12:51 ` [PATCH pve-manager 3/3] ui: dc: san: show missing open-iscsi in the node grid Dominik Csapak

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=20261120125236.2393788-2-d.csapak@proxmox.com \
    --to=d.csapak@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal