From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from gate001.proxmox.com (gate001.proxmox.com [IPv6:2a0f:8001:1:32::40]) by lore.proxmox.com (Postfix) with ESMTPS id 87DEF1FF065 for ; Mon, 23 Nov 2026 14:35:31 +0100 (CET) Received: from gate001.proxmox.com (localhost.localdomain [127.0.0.1]) by gate001.proxmox.com (Proxmox) with ESMTP id DA273217BC; Mon, 23 Nov 2026 14:34:32 +0100 (CET) From: Thomas Lamprecht To: pve-devel@lists.proxmox.com Subject: [PATCH v5 storage 07/26] api: config: check the cluster version before the first nvmeof storage Date: Mon, 23 Nov 2026 14:31:59 +0100 Message-ID: <20261123133412.3710030-8-t.lamprecht@proxmox.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20261123133412.3710030-1-t.lamprecht@proxmox.com> References: <20261123133412.3710030-1-t.lamprecht@proxmox.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Bm-Milter-Handled: 55990f41-d878-4baa-be0a-ee34c49e34d2 X-Bm-Transport-Timestamp: 1795440864255 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.148 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) RCVD_IN_DNSWL_MED -2.3 Sender listed at https://www.dnswl.org/, medium trust SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record Message-ID-Hash: RNVUR47Q345R722VOUFASZAMXM6LYYPG X-Message-ID-Hash: RNVUR47Q345R722VOUFASZAMXM6LYYPG X-MailFrom: t.lamprecht@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: A node without the nvmeof storage type drops the sections of such storages when it writes the storage configuration, for example when a storage is added or edited on that node. Refuse adding the first storage of the type until all nodes are online and run pve-manager 9.2.38 or newer, the first version that depends on a storage library with this type. Further ones are not checked, so that they can be added while a node is offline. Signed-off-by: Thomas Lamprecht --- src/PVE/API2/Storage/Config.pm | 5 +++++ src/test/run_nvmeof_tests.pl | 27 +++++++++++++++++++++++++++ 2 files changed, 32 insertions(+) diff --git a/src/PVE/API2/Storage/Config.pm b/src/PVE/API2/Storage/Config.pm index 47d57282..28bd7914 100755 --- a/src/PVE/API2/Storage/Config.pm +++ b/src/PVE/API2/Storage/Config.pm @@ -297,6 +297,11 @@ __PACKAGE__->register_method({ die "storage ID '$storeid' already defined\n"; } + # A node without the type drops its sections when it writes the configuration. + # FIXME: MAJOR VERSION: This check can be dropped at the next major version bump. + PVE::Cluster::assert_min_cluster_version(9, 2, 38) + if $type eq 'nvmeof' && !grep { $_->{type} eq 'nvmeof' } values $cfg->{ids}->%*; + $cfg->{ids}->{$storeid} = $opts; $returned_config = $plugin->on_add_hook($storeid, $opts, %$sensitive); diff --git a/src/test/run_nvmeof_tests.pl b/src/test/run_nvmeof_tests.pl index e8285695..b9bed005 100755 --- a/src/test/run_nvmeof_tests.pl +++ b/src/test/run_nvmeof_tests.pl @@ -12,6 +12,7 @@ use Time::HiRes (); use PVE::Tools qw(file_set_contents); +use PVE::API2::Storage::Config; use PVE::NVMeOF; use PVE::Storage; @@ -204,6 +205,32 @@ subtest 'configuration, portals and volumes' => sub { ); }; +subtest 'the first storage of the type needs an upgraded cluster' => sub { + my $raw = "dir: local\n\tpath /var/lib/vz\n\tcontent iso\n"; + my $cluster = Test::MockModule->new('PVE::Cluster'); + my $asserted; + $cluster->mock(assert_min_cluster_version => sub { $asserted = join('.', @_) }); + my $storage = Test::MockModule->new('PVE::Storage'); + $storage->mock( + lock_storage_config => sub { $_[0]->() }, + config => sub { PVE::Storage::Plugin->parse_config('storage.cfg', $raw) }, + write_config => sub { $raw = PVE::Storage::Plugin->write_config('storage.cfg', $_[0]) }, + activate_storage => sub { }, + ); + my $add = sub($storeid, $nqn) { + $asserted = undef; + PVE::API2::Storage::Config->create({ + storage => $storeid, + type => 'nvmeof', + subsysnqn => $nqn, + portals => '192.0.2.1', + }); + return $asserted; + }; + is($add->('fabric1', 'nqn.first'), '9.2.38', 'the first one checks the cluster'); + is($add->('fabric2', 'nqn.second'), undef, 'a further one does not'); +}; + subtest 'sysfs topology' => sub { my $sys = $PVE::NVMeOF::SYSFS; make_path(