[pve-devel] [PATCH manager] pvestatd: rebroadcast version info as needed

Wolfgang Bumiller w.bumiller at proxmox.com
Fri Nov 12 13:23:53 CET 2021


since this is just in-memory data and can get lost with
pmxcfs restarts

Signed-off-by: Wolfgang Bumiller <w.bumiller at proxmox.com>
Fixes: 34a1305e9c21 ("pvestatd: broadcast version info")
---
 PVE/Service/pvestatd.pm | 15 ++++++++-------
 1 file changed, 8 insertions(+), 7 deletions(-)

diff --git a/PVE/Service/pvestatd.pm b/PVE/Service/pvestatd.pm
index b1e71ec8..6a413025 100755
--- a/PVE/Service/pvestatd.pm
+++ b/PVE/Service/pvestatd.pm
@@ -491,15 +491,16 @@ sub update_sdn_status {
     }
 }
 
-my $broadcast_version_info_done = 0;
+my $version_info;
 my sub broadcast_version_info : prototype() {
-    if (!$broadcast_version_info_done) {
-	PVE::Cluster::broadcast_node_kv(
-	    'version-info',
-	    encode_json(PVE::pvecfg::version_info()),
-	);
-	$broadcast_version_info_done = 1;
+    $version_info //= to_json(PVE::pvecfg::version_info(), { canonical => 1 });
+
+    if (my $old = PVE::Cluster::get_node_kv("version-info")) {
+	$old = $old->{$nodename};
+	return if $old && $old eq $version_info;
     }
+
+    PVE::Cluster::broadcast_node_kv('version-info', $version_info);
 }
 
 sub update_status {
-- 
2.30.2






More information about the pve-devel mailing list