From b3f1adb200d84c7908301b423bb4fbf23739b68c Mon Sep 17 00:00:00 2001 From: Dietmar Maurer Date: Wed, 21 Dec 2016 11:39:46 +0100 Subject: [PATCH] rebalance_lxc_containers: avoid repeated warnings if rebalance fails Only warn once. --- PVE/Service/pvestatd.pm | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/PVE/Service/pvestatd.pm b/PVE/Service/pvestatd.pm index e99d3c74..d214c80b 100755 --- a/PVE/Service/pvestatd.pm +++ b/PVE/Service/pvestatd.pm @@ -222,6 +222,8 @@ sub remove_stale_lxc_consoles { } } +my $rebalance_error_count = {}; + sub rebalance_lxc_containers { return if !-d '/sys/fs/cgroup/cpuset/lxc'; # nothing to do... @@ -237,8 +239,11 @@ sub rebalance_lxc_containers { my $modify_cpuset = sub { my ($vmid, $cpuset, $newset) = @_; - syslog('info', "modified cpu set for lxc/$vmid: " . - $newset->short_string()); + if (!$rebalance_error_count->{$vmid}) { + syslog('info', "modified cpu set for lxc/$vmid: " . + $newset->short_string()); + } + eval { # allow all, so that we can set new cpuset in /ns $all_cpus->write_to_cgroup("lxc/$vmid"); @@ -246,15 +251,18 @@ sub rebalance_lxc_containers { $newset->write_to_cgroup("lxc/$vmid/ns"); }; if (my $err = $@) { - warn $err; + warn $err if !$rebalance_error_count->{$vmid}++; # restore original $cpuset->write_to_cgroup("lxc/$vmid"); } else { # also apply to container root cgroup $newset->write_to_cgroup("lxc/$vmid"); + $rebalance_error_count->{$vmid} = 0; } }; - warn $@ if $@; + if (my $err = $@) { + warn $err if !$rebalance_error_count->{$vmid}++; + } }; my $ctlist = PVE::LXC::config_list();