From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by lists.proxmox.com (Postfix) with ESMTPS id 0AA9091838 for ; Fri, 7 Oct 2022 14:48:58 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id DAE18264F5 for ; Fri, 7 Oct 2022 14:48:57 +0200 (CEST) Received: from proxmox-new.maurer-it.com (proxmox-new.maurer-it.com [94.136.29.106]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by firstgate.proxmox.com (Proxmox) with ESMTPS for ; Fri, 7 Oct 2022 14:48:56 +0200 (CEST) Received: from proxmox-new.maurer-it.com (localhost.localdomain [127.0.0.1]) by proxmox-new.maurer-it.com (Proxmox) with ESMTP id 995D444837 for ; Fri, 7 Oct 2022 14:42:05 +0200 (CEST) From: Fiona Ebner To: pve-devel@lists.proxmox.com Date: Fri, 7 Oct 2022 14:41:55 +0200 Message-Id: <20221007124156.110246-19-f.ebner@proxmox.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20221007124156.110246-1-f.ebner@proxmox.com> References: <20221007124156.110246-1-f.ebner@proxmox.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SPAM-LEVEL: Spam detection results: 0 AWL 0.027 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record URIBL_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to URIBL was blocked. See http://wiki.apache.org/spamassassin/DnsBlocklists#dnsbl-block for more information. [cluster.pm, pvestatd.pm] Subject: [pve-devel] [PATCH v2 manager 4/5] cluster resources: add cgroup-mode to node properties X-BeenThere: pve-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox VE development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 07 Oct 2022 12:48:58 -0000 so the frontend has the information readily available. It's enough for pvestatd to broadcast the value whenever it's 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 --- Changes from v1: * Only broadcast if necessary rather than periodically. PVE/API2/Cluster.pm | 12 ++++++++++++ PVE/Service/pvestatd.pm | 16 ++++++++++++++++ 2 files changed, 28 insertions(+) diff --git a/PVE/API2/Cluster.pm b/PVE/API2/Cluster.pm index d6b405e2..cb96abd7 100644 --- a/PVE/API2/Cluster.pm +++ b/PVE/API2/Cluster.pm @@ -312,6 +312,11 @@ __PACKAGE__->register_method({ type => 'string', optional => 1, }, + 'cgroup-mode' => { + description => "The cgroup mode the node operates under (when type == node).", + type => 'integer', + optional => 1, + }, }, }, }, @@ -416,10 +421,17 @@ __PACKAGE__->register_method({ } } + my $cgroup_modes = PVE::Cluster::get_node_kv("cgroup-mode"); + if (!$param->{type} || $param->{type} eq 'node') { foreach my $node (@$nodelist) { my $can_audit = $rpcenv->check($authuser, "/nodes/$node", [ 'Sys.Audit' ], 1); my $entry = PVE::API2Tools::extract_node_stats($node, $members, $rrd, !$can_audit); + + if (defined(my $mode = $cgroup_modes->{$node})) { + $entry->{'cgroup-mode'} = int($mode); + } + push @$res, $entry; } } diff --git a/PVE/Service/pvestatd.pm b/PVE/Service/pvestatd.pm index eac953df..61de8b36 100755 --- a/PVE/Service/pvestatd.pm +++ b/PVE/Service/pvestatd.pm @@ -123,9 +123,25 @@ my $generate_rrd_string = sub { return join(':', map { $_ // 'U' } @$data); }; +my sub broadcast_cgroup_mode { + my $cgroup_mode = eval { PVE::CGroup::cgroup_mode(); }; + if (my $err = $@) { + syslog('err', "cgroup mode error: $err"); + return; + } + + my $old = PVE::Cluster::get_node_kv("cgroup-mode", $cgroup_mode, $nodename); + $old = eval { decode_json($old->{$nodename}) } if defined($old->{$nodename}); + + PVE::Cluster::broadcast_node_kv("cgroup-mode", $cgroup_mode) + if !$old || $old != $cgroup_mode; +} + sub update_node_status { my ($status_cfg) = @_; + broadcast_cgroup_mode(); + my ($uptime) = PVE::ProcFSTools::read_proc_uptime(); my ($avg1, $avg5, $avg15) = PVE::ProcFSTools::read_loadavg(); -- 2.30.2