From b707257a160fe6eea48ace8481f41e3cf46c3cf8 Mon Sep 17 00:00:00 2001 From: Thomas Lamprecht Date: Wed, 20 Oct 2021 16:37:05 +0200 Subject: [PATCH] statd: rebalance_lxc_containers: code bload reduction Signed-off-by: Thomas Lamprecht --- PVE/Service/pvestatd.pm | 21 +++++++-------------- 1 file changed, 7 insertions(+), 14 deletions(-) diff --git a/PVE/Service/pvestatd.pm b/PVE/Service/pvestatd.pm index 26d96bb2..6d07a801 100755 --- a/PVE/Service/pvestatd.pm +++ b/PVE/Service/pvestatd.pm @@ -284,8 +284,7 @@ sub rebalance_lxc_containers { my ($vmid, $cpuset, $newset) = @_; if (!$rebalance_error_count->{$vmid}) { - syslog('info', "modified cpu set for lxc/$vmid: " . - $newset->short_string()); + syslog('info', "modified cpu set for lxc/$vmid: " . $newset->short_string()); } eval { @@ -321,21 +320,16 @@ sub rebalance_lxc_containers { foreach my $vmid (sort keys %$ctlist) { my $cgpath = "$cpuset_base/lxc/$vmid"; - if (-d "$cgpath/ns") { $ctinfo->{$vmid} = $cgpath; } else { - # old style container - next; + next; # old style container } - my ($conf, $cpuset); - eval { - - $conf = PVE::LXC::Config->load_config($vmid); - - $cpuset = PVE::CpuSet->new_from_path($cgpath); - }; + my ($conf, $cpuset) = eval {( + PVE::LXC::Config->load_config($vmid), + PVE::CpuSet->new_from_path($cgpath), + )}; if (my $err = $@) { warn $err; next; @@ -349,8 +343,7 @@ sub rebalance_lxc_containers { my $cores = $conf->{cores} || $cpucount; $cores = $cpucount if $cores > $cpucount; - # see if the number of cores was hot-reduced or - # hasn't been enacted at all yet + # see if the number of cores was hot-reduced or hasn't been enacted at all yet my $newset = PVE::CpuSet->new(); if ($cores < scalar(@cpuset_members)) { for (my $i = 0; $i < $cores; $i++) {