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 21B2B1FF0DA for ; Thu, 19 Nov 2026 18:12:14 +0100 (CET) Received: from gate001.proxmox.com (localhost.localdomain [127.0.0.1]) by gate001.proxmox.com (Proxmox) with ESMTP id D07D02171E; Thu, 19 Nov 2026 18:11:58 +0100 (CET) From: Dominik Csapak To: pve-devel@lists.proxmox.com Subject: [PATCH pve-manager v3 2/3] api: provide GUI versions via index and /cluster/resources Date: Thu, 19 Nov 2026 18:09:08 +0100 Message-ID: <20261119171151.475428-3-d.csapak@proxmox.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20261119171151.475428-1-d.csapak@proxmox.com> References: <20261119171151.475428-1-d.csapak@proxmox.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SPAM-LEVEL: Spam detection results: 0 AWL 0.122 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) POISEN_SPAM_PILL 0.1 Meta: its spam POISEN_SPAM_PILL_1 0.1 random spam to be learned in bayes POISEN_SPAM_PILL_3 0.1 random spam to be learned in bayes 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: ZCB24LLYF4WKCSYBGIZK7NVD26WANH4B X-Message-ID-Hash: ZCB24LLYF4WKCSYBGIZK7NVD26WANH4B X-MailFrom: d.csapak@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: Index has these versions anyway, just expose them to the UI via the usual `Proxmox` object. In the /cluster/resources API call, we add that information to the node that is handling the request (which is normally the same where the index was loaded from). Cache the pwt versions locally for as long as the mtime does not change. Stat'ing should be cached by the underlying filesystem and be very cheap. This way we don't hit the file read on every call. With this information, the UI can detect an outdated UI version still running. Signed-off-by: Dominik Csapak --- PVE/API2/Cluster.pm | 31 +++++++++++++++++++++++++++++++ PVE/API2Tools.pm | 19 ++++++++++++++++--- www/index.html.tpl | 6 +++++- 3 files changed, 52 insertions(+), 4 deletions(-) diff --git a/PVE/API2/Cluster.pm b/PVE/API2/Cluster.pm index aaec3ec3..114ba033 100644 --- a/PVE/API2/Cluster.pm +++ b/PVE/API2/Cluster.pm @@ -21,6 +21,7 @@ use PVE::RPCEnvironment; use PVE::SafeSyslog; use PVE::Storage; use PVE::Tools qw(extract_param); +use PVE::pvecfg; use PVE::API2::ACMEAccount; use PVE::API2::ACMEPlugin; @@ -504,6 +505,25 @@ __PACKAGE__->register_method({ default => 'x86_64', optional => 1, }, + 'versions' => { + description => "Optional package versions (for type 'node').", + type => 'object', + optional => 1, + properties => { + 'pve-manager' => { + type => "string", + optional => 1, + description => + "The pve-manager version of this node. Only included for the node handling the request.", + }, + 'proxmox-widget-toolkit' => { + type => "string", + optional => 1, + description => + "The proxmox-widget-toolkit version of this node. Only included for the node handling the request.", + }, + }, + }, }, }, }, @@ -619,6 +639,8 @@ __PACKAGE__->register_method({ my $static_node_info = PVE::Cluster::get_node_kv("static-info"); if (!$param->{type} || $param->{type} eq 'node') { + my $nodename = PVE::INotify::nodename(); + foreach my $node (@$nodelist) { my $can_audit = $rpcenv->check($authuser, "/nodes/$node", ['Sys.Audit'], 1); my $entry = @@ -635,6 +657,15 @@ __PACKAGE__->register_method({ $entry->{'hastate'} = $status; } + if ($node eq $nodename) { + my $pwt_version = PVE::API2Tools::read_pwt_version(); + + $entry->{versions} = { 'pve-manager' => PVE::pvecfg::version() }; + # an empty version means reading failed, omit it to avoid false positives + $entry->{versions}->{'proxmox-widget-toolkit'} = $pwt_version + if $pwt_version ne ''; + } + push @$res, $entry; } } diff --git a/PVE/API2Tools.pm b/PVE/API2Tools.pm index c53ec03f..ad769f12 100644 --- a/PVE/API2Tools.pm +++ b/PVE/API2Tools.pm @@ -280,10 +280,23 @@ sub pwt_base_dir { return $PWT_BASE_DIR; } +my $pwt_version_cache = {}; + sub read_pwt_version { - my $wtversionraw = PVE::File::file_read_first_line($PWT_FILE) // ''; - my $wtversion = $wtversionraw =~ m|^// (.*)$| ? $1 : ''; - return $wtversion; + my $st = stat($PWT_FILE); + my $mtime = $st ? $st->mtime() : 0; + + if ( + !defined($pwt_version_cache->{version}) + || $pwt_version_cache->{mtime} != $mtime + ) { + my $wtversionraw = PVE::File::file_read_first_line($PWT_FILE) // ''; + my $wtversion = $wtversionraw =~ m|^// (.*)$| ? $1 : ''; + $pwt_version_cache->{version} = $wtversion; + $pwt_version_cache->{mtime} = $mtime; + } + + return $pwt_version_cache->{version}; } 1; diff --git a/www/index.html.tpl b/www/index.html.tpl index 125c1046..21345822 100644 --- a/www/index.html.tpl +++ b/www/index.html.tpl @@ -48,7 +48,11 @@ NodeArch: '[% arch %]', UserName: '[% username %]', CSRFPreventionToken: '[% token %]', - ConsentText: '[% consenttext.squote %]' + ConsentText: '[% consenttext.squote %]', + GUIVersions: { + 'pve-manager': '[% version %]', + 'proxmox-widget-toolkit': '[% wtversion %]', + }, }; -- 2.47.3