all lists on lists.proxmox.com
 help / color / mirror / Atom feed
From: Dietmar Maurer <dietmar@proxmox.com>
To: pve-devel@lists.proxmox.com
Subject: [PATCH storage 7/7] iscsi: add periodic-discovery flag to skip re-discovery on login
Date: Tue,  4 Aug 2026 11:08:19 +0200	[thread overview]
Message-ID: <20260804090819.2136483-8-dietmar@proxmox.com> (raw)
In-Reply-To: <20260804090819.2136483-1-dietmar@proxmox.com>

Every login first re-runs sendtargets discovery, which auto-persists
node records and resets their node.* settings to defaults. This
clobbers tuned records (timeouts, iface binding) and re-imposes the
portal's full advertised set, fighting intentional per-node record
divergence.

With periodic-discovery=0, discovery only runs when the node db has
no record for the target, seeding it once; later logins use the
existing records as-is. Login stays poll-driven either way, so
dropped sessions are still re-established on the next poll. The
default (1) keeps the current re-discover-on-login behavior. Static
iscsi-node-map configurations already bypass discovery, so the flag
has no effect there.

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

diff --git a/src/PVE/Storage/ISCSIPlugin.pm b/src/PVE/Storage/ISCSIPlugin.pm
index 85f33aa..33197b9 100644
--- a/src/PVE/Storage/ISCSIPlugin.pm
+++ b/src/PVE/Storage/ISCSIPlugin.pm
@@ -276,12 +276,12 @@ sub iscsi_discovery {
 }
 
 sub iscsi_login {
-    my ($target, $portals, $cache, $static) = @_;
+    my ($target, $portals, $cache, $skip_discovery) = @_;
 
     assert_iscsi_support();
 
-    # static configurations have their node db records synced already
-    if (!$static) {
+    # skipped when the node db records for the target already exist
+    if (!$skip_discovery) {
         eval { iscsi_discovery($target, $portals, $cache); };
         warn $@ if $@;
     }
@@ -573,6 +573,15 @@ sub properties {
                 format => $iscsi_node_map_fmt,
             },
         },
+        'periodic-discovery' => {
+            description => "Re-run sendtargets discovery before every login (default)."
+                . " When disabled, discovery only runs when the node database has no"
+                . " record for the target, and logins use the existing records as-is."
+                . " Has no effect when a static iscsi-node-map configuration applies.",
+            type => 'boolean',
+            default => 1,
+            optional => 1,
+        },
     };
 }
 
@@ -581,6 +590,7 @@ sub options {
         portal => { fixed => 1 },
         target => { fixed => 1 },
         'iscsi-node-map' => { optional => 1 },
+        'periodic-discovery' => { optional => 1 },
         nodes => { optional => 1 },
         disable => { optional => 1 },
         content => { optional => 1 },
@@ -716,16 +726,22 @@ sub activate_storage {
 
     my $node_targets = get_node_targets($scfg);
     my $static = $node_targets->{static};
+    my $periodic_discovery = $scfg->{'periodic-discovery'} // 1;
 
     for my $node_target (@{ $node_targets->{targets} }) {
         my ($target, $portals) = ($node_target->{target}, $node_target->{portals});
+        my $skip_discovery = $static;
 
         if ($static) {
             iscsi_sync_node_records($target, $portals, $cache);
         } else {
             # fall back to the configured discovery address on an empty node db
             my $recorded = iscsi_portals($target);
-            $portals = $recorded if scalar(@$recorded);
+            if (scalar(@$recorded)) {
+                $portals = $recorded;
+                # seed-once mode: the node db already holds records for this target
+                $skip_discovery = 1 if !$periodic_discovery;
+            }
         }
 
         my $sessions = iscsi_session($cache, $target);
@@ -745,7 +761,7 @@ sub activate_storage {
         }
 
         if ($do_login) {
-            eval { iscsi_login($target, $portals, $cache, $static); };
+            eval { iscsi_login($target, $portals, $cache, $skip_discovery); };
             warn $@ if $@;
         } else {
             # make sure we get all devices
-- 
2.47.3




      parent reply	other threads:[~2026-08-04  9:08 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 ` [PATCH storage 6/7] iscsi: iscsi_portals: return empty list instead of fallback portal Dietmar Maurer
2026-08-04  9:08 ` Dietmar Maurer [this message]

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-8-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 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