From 955912c54ed9b0e7913616c004c7dbf7eb5aef00 Mon Sep 17 00:00:00 2001 From: Fiona Ebner Date: Thu, 10 Nov 2022 15:37:45 +0100 Subject: [PATCH] pvestatd: broadcast static node information 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 Signed-off-by: Fiona Ebner --- PVE/Service/pvestatd.pm | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/PVE/Service/pvestatd.pm b/PVE/Service/pvestatd.pm index eac953df..eb0dc130 100755 --- a/PVE/Service/pvestatd.pm +++ b/PVE/Service/pvestatd.pm @@ -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 { -- 2.39.5