]> git.proxmox.com Git - pve-manager.git/commitdiff
pvestatd: broadcast static node information
authorFiona Ebner <f.ebner@proxmox.com>
Thu, 10 Nov 2022 14:37:45 +0000 (15:37 +0100)
committerThomas Lamprecht <t.lamprecht@proxmox.com>
Tue, 15 Nov 2022 13:07:56 +0000 (14:07 +0100)
Planned to be used for static resource scheduling in the HA manager.

It's enough to broadcast the values whenever they are outdated or not
set in the node's local kv store, because pmxcfs will re-broadcast the
local kv store whenever the quorate partition changes. This is already
relied upon for the 'ceph-versions' kv pair.

Suggested-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
PVE/Service/pvestatd.pm

index eac953df68ca0a970f00d2d153a07f557af2881c..eb0dc1305f9e126e0ee5a2da4b1914047dbb11c7 100755 (executable)
@@ -123,6 +123,24 @@ my $generate_rrd_string = sub {
     return join(':', map { $_ // 'U' } @$data);
 };
 
+my sub broadcast_static_node_info {
+    my ($cpus, $memory) = @_;
+
+    my $old = PVE::Cluster::get_node_kv('static-info', $nodename);
+    $old = eval { decode_json($old->{$nodename}) } if defined($old->{$nodename});
+
+    if (
+       !defined($old->{cpus}) || $old->{cpus} != $cpus
+       || !defined($old->{memory}) || $old->{memory} != $memory
+    ) {
+       my $info = {
+           cpus => $cpus,
+           memory => $memory,
+       };
+       PVE::Cluster::broadcast_node_kv('static-info', encode_json($info));
+    }
+}
+
 sub update_node_status {
     my ($status_cfg) = @_;
 
@@ -175,6 +193,8 @@ sub update_node_status {
     my $transactions = PVE::ExtMetric::transactions_start($status_cfg);
     PVE::ExtMetric::update_all($transactions, 'node', $nodename, $node_metric, $ctime);
     PVE::ExtMetric::transactions_finish($transactions);
+
+    broadcast_static_node_info($maxcpu, $meminfo->{memtotal});
 }
 
 sub auto_balloning {