so the frontend has the information readily available.

Suggested-by: Thomas Lamprecht <[email protected]>
Signed-off-by: Fabian Ebner <[email protected]>
---
 PVE/API2/Cluster.pm     | 12 ++++++++++++
 PVE/Service/pvestatd.pm | 11 +++++++++++
 2 files changed, 23 insertions(+)

diff --git a/PVE/API2/Cluster.pm b/PVE/API2/Cluster.pm
index 3b918e55..11d6aa3a 100644
--- a/PVE/API2/Cluster.pm
+++ b/PVE/API2/Cluster.pm
@@ -306,6 +306,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,
+               },
            },
        },
     },
@@ -410,10 +415,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 7193388c..22173d63 100755
--- a/PVE/Service/pvestatd.pm
+++ b/PVE/Service/pvestatd.pm
@@ -122,6 +122,15 @@ my $generate_rrd_string = sub {
     return join(':', map { $_ // 'U' } @$data);
 };
 
+my $broadcast_cgroup_mode = sub {
+    my $cgroup_mode = eval { PVE::CGroup::cgroup_mode(); };
+    if (my $err = $@) {
+       syslog('err', "cgroup mode error: $err");
+    }
+
+    PVE::Cluster::broadcast_node_kv("cgroup-mode", $cgroup_mode);
+};
+
 sub update_node_status {
     my ($status_cfg) = @_;
 
@@ -151,6 +160,8 @@ sub update_node_status {
     # everything not free is considered to be used
     my $dused = $dinfo->{blocks} - $dinfo->{bfree};
 
+    $broadcast_cgroup_mode->();
+
     my $ctime = time();
 
     my $data = $generate_rrd_string->(
-- 
2.30.2



_______________________________________________
pve-devel mailing list
[email protected]
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel

Reply via email to