From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from gate001.proxmox.com (gate001.proxmox.com [45.144.208.40]) by lore.proxmox.com (Postfix) with ESMTPS id 265051FF0E3 for ; Tue, 04 Aug 2026 11:09:08 +0200 (CEST) Received: from gate001.proxmox.com (localhost.localdomain [127.0.0.1]) by gate001.proxmox.com (Proxmox) with ESMTP id C4101216B7; Tue, 04 Aug 2026 11:08:26 +0200 (CEST) From: Dietmar Maurer 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 Message-ID: <20260804090819.2136483-7-dietmar@proxmox.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20260804090819.2136483-1-dietmar@proxmox.com> References: <20260804090819.2136483-1-dietmar@proxmox.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SPAM-LEVEL: Spam detection results: 2 AWL -0.110 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) KAM_LAZY_DOMAIN_SECURITY 1 Sending domain does not have any anti-forgery methods RDNS_NONE 1.274 Delivered to internal network by a host with no rDNS SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_NONE 0.001 SPF: sender does not publish an SPF Record Message-ID-Hash: W2LBTVUIOA7EM5HUQVQEFGNU2MPFG3N6 X-Message-ID-Hash: W2LBTVUIOA7EM5HUQVQEFGNU2MPFG3N6 X-MailFrom: dietmar@zilli.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: 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 --- 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