public inbox for pve-devel@lists.proxmox.com
 help / color / mirror / Atom feed
From: Dietmar Maurer <dietmar@proxmox.com>
To: pve-devel@lists.proxmox.com
Subject: [PATCH storage 6/7] iscsi: iscsi_portals: return empty list instead of fallback portal
Date: Tue,  4 Aug 2026 11:08:18 +0200	[thread overview]
Message-ID: <20260804090819.2136483-7-dietmar@proxmox.com> (raw)
In-Reply-To: <20260804090819.2136483-1-dietmar@proxmox.com>

Returning the configured discovery address when the node db has no
records (or iscsiadm fails) hides whether records exist from callers.
Move the fallback to the call sites, so an upcoming change can gate
sendtargets discovery on the node db being empty.

No functional change.

Signed-off-by: Dietmar Maurer <dietmar@proxmox.com>
---
 src/PVE/Storage/ISCSIPlugin.pm | 25 ++++++++++++++-----------
 1 file changed, 14 insertions(+), 11 deletions(-)

diff --git a/src/PVE/Storage/ISCSIPlugin.pm b/src/PVE/Storage/ISCSIPlugin.pm
index 585b8c2..85f33aa 100644
--- a/src/PVE/Storage/ISCSIPlugin.pm
+++ b/src/PVE/Storage/ISCSIPlugin.pm
@@ -94,7 +94,7 @@ sub iscsi_test_portal {
 }
 
 sub iscsi_portals {
-    my ($target, $portal_in) = @_;
+    my ($target) = @_;
 
     assert_iscsi_support();
 
@@ -115,15 +115,12 @@ sub iscsi_portals {
             },
         );
     };
-
-    my $err = $@;
-    warn $err if $err;
-
-    if ($err || !scalar(@$res)) {
-        return [$portal_in];
-    } else {
-        return $res;
+    if (my $err = $@) {
+        warn $err;
+        return [];
     }
+
+    return $res;
 }
 
 # normalize for comparison: iscsiadm reports portals with an explicit port
@@ -726,7 +723,9 @@ sub activate_storage {
         if ($static) {
             iscsi_sync_node_records($target, $portals, $cache);
         } else {
-            $portals = iscsi_portals($target, $portals->[0]);
+            # fall back to the configured discovery address on an empty node db
+            my $recorded = iscsi_portals($target);
+            $portals = $recorded if scalar(@$recorded);
         }
 
         my $sessions = iscsi_session($cache, $target);
@@ -877,7 +876,11 @@ sub check_connection {
     my $node_targets = get_node_targets($scfg);
     for my $node_target (@{ $node_targets->{targets} }) {
         my ($target, $portals) = ($node_target->{target}, $node_target->{portals});
-        $portals = iscsi_portals($target, $portals->[0]) if !$node_targets->{static};
+        if (!$node_targets->{static}) {
+            # fall back to the configured discovery address on an empty node db
+            my $recorded = iscsi_portals($target);
+            $portals = $recorded if scalar(@$recorded);
+        }
 
         for my $portal (@$portals) {
             my $result = iscsi_test_portal($target, $portal, $cache);
-- 
2.47.3




  parent reply	other threads:[~2026-08-04  9:09 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-04  9:08 [PATCH storage 0/7] iscsi: per-node target and portal configuration Dietmar Maurer
2026-08-04  9:08 ` [PATCH storage 1/7] iscsi: discovery: do not stop early on a foreign target Dietmar Maurer
2026-08-04  9:08 ` [PATCH storage 2/7] iscsi: scan: do not persist discovery results in the node database Dietmar Maurer
2026-08-04  9:08 ` [PATCH storage 3/7] iscsi: validate target names with a dedicated format Dietmar Maurer
2026-08-04  9:08 ` [PATCH storage 4/7] iscsi: clarify that the portal property is the discovery address Dietmar Maurer
2026-08-04  9:08 ` [PATCH storage 5/7] iscsi: add iscsi-node-map property for per-node target and portals Dietmar Maurer
2026-08-04  9:08 ` Dietmar Maurer [this message]
2026-08-04  9:08 ` [PATCH storage 7/7] iscsi: add periodic-discovery flag to skip re-discovery on login Dietmar Maurer

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=20260804090819.2136483-7-dietmar@proxmox.com \
    --to=dietmar@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