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 15C461FF0E6 for ; Fri, 24 Jul 2026 16:28:16 +0200 (CEST) Received: from gate001.proxmox.com (localhost.localdomain [127.0.0.1]) by gate001.proxmox.com (Proxmox) with ESMTP id DCCD7214CD; Fri, 24 Jul 2026 16:28:15 +0200 (CEST) From: David Riley To: pve-devel@lists.proxmox.com Subject: [PATCH pve-cluster v3 03/12] cluster: helpers: add cluster-wide version assertion Date: Fri, 24 Jul 2026 16:25:19 +0200 Message-ID: <20260724142528.109453-4-d.riley@proxmox.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20260724142528.109453-1-d.riley@proxmox.com> References: <20260724142528.109453-1-d.riley@proxmox.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Bm-Milter-Handled: 55990f41-d878-4baa-be0a-ee34c49e34d2 X-Bm-Transport-Timestamp: 1784903260759 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.098 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_LOW -0.7 Sender listed at https://www.dnswl.org/, low 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: 7ZXBJGTWBBIHBEQYRWSDBHZ5KWBXLWQK X-Message-ID-Hash: 7ZXBJGTWBBIHBEQYRWSDBHZ5KWBXLWQK X-MailFrom: d.riley@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: Add function to assert a minimum version requirement for the whole cluster. Evaluate against the cluster configuration. Dies if any node is offline, or running an older version, ensuring cluster-wide feature compatibility before allowing an operation to proceed. Prevent older nodes from truncating newly structured configuration entries. Prepare for #7294 to allow a safe rollout across mixed version clusters. Signed-off-by: David Riley Reviewed-by: Daniel Kral Link: https://bugzilla.proxmox.com/show_bug.cgi?id=7294 --- src/PVE/Cluster.pm | 39 ++++++++++++++++++++++++++++++++++++++- 1 file changed, 38 insertions(+), 1 deletion(-) diff --git a/src/PVE/Cluster.pm b/src/PVE/Cluster.pm index 034b78c..2a1e00b 100644 --- a/src/PVE/Cluster.pm +++ b/src/PVE/Cluster.pm @@ -20,7 +20,7 @@ use PVE::IPCC; use PVE::JSONSchema; use PVE::Network; use PVE::SafeSyslog; -use PVE::Tools qw(run_command); +use PVE::Tools qw(run_command pvecfg_min_version); use PVE::Cluster::IPCConst; @@ -929,4 +929,41 @@ sub cfs_rename_db_unsafe { rename $dbfile, "$dbfile.$ctime.bak" or warn "failed to rename old config database - $!\n"; } +# Asserts that all configured nodes in the cluster meet a minimum version requirement. +# Evaluates against the full, static cluster node list rather than only live nodes. +# Aborts if any node is offline, unreadable, or running an +# outdated version, preventing partial feature rollouts from corrupting cluster state. +# NOTE: Uses PVE::Tools::pvecfg_min_version, which currently checks basic major.minor.release +# triples. If gatekeeping a feature right around a major release transition, be aware that it +# does not yet lexically sort trailing Debian revision suffixes (e.g., distinguishing '9.0.0' as +# newer than '9.0.0~22'). +sub assert_min_cluster_version { + my ($major, $minor, $release) = @_; + + my $nodestat = get_node_kv('version-info'); + my $nodelist = get_nodelist(); + + for my $node (sort @$nodelist) { + my $raw_json = $nodestat->{$node}; + + if (!defined($raw_json)) { + die "cannot execute operation: cluster node '$node' is offline or not reporting its" + . " version. All nodes must be online to verify cluster-wide feature support.\n"; + } + + my $vinfo = eval { decode_json($raw_json) }; + if ($@ || !$vinfo || !$vinfo->{version}) { + die "cannot execute operation: failed to parse cluster version string for node" + . " '$node'.\n"; + } + + if (!pvecfg_min_version($vinfo->{version}, $major, $minor, $release)) { + die "cannot execute operation: cluster node '$node' runs an older version of Proxmox" + . " VE ($vinfo->{version}) than the required $major.$minor.$release. Please" + . " upgrade all nodes first.\n"; + } + } + return 1; +} + 1; -- 2.47.3