[pve-devel] [PATCH v2 pve-manager 4/7] add threshold to cpu/ram target

Alexandre Derumier aderumier at odiso.com
Wed Oct 9 16:01:34 CEST 2019


Signed-off-by: Alexandre Derumier <aderumier at odiso.com>
---
 PVE/API2/Nodes.pm | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/PVE/API2/Nodes.pm b/PVE/API2/Nodes.pm
index f86523b0..3578b6de 100644
--- a/PVE/API2/Nodes.pm
+++ b/PVE/API2/Nodes.pm
@@ -1979,7 +1979,8 @@ __PACKAGE__->register_method ({
 		    my $members = PVE::Cluster::get_members();
 		    my $rrd = PVE::Cluster::rrd_dump();
 		    my $nodelist = PVE::Cluster::get_nodelist();
-
+		    my $mem_threshold = 0.8;
+		    my $cpu_threshold = 0.8;
 		    my $vm_stats = PVE::API2Tools::extract_vm_stats($vmid, $d, $rrd);
 		    my $vm_cpu = $vm_stats->{cpu} * $vm_stats->{maxcpu};
 		    my $vm_mem = $vm_stats->{mem};
@@ -1994,8 +1995,8 @@ __PACKAGE__->register_method ({
 			my $node_freemem = $node_stats->{maxmem} - $node_stats->{mem};
 			my $node_freecpu = (100 - $node_stats->{cpu}) * $node_stats->{maxcpu};  #how to handle different cpu model power ? bogomips ?
 			next if $node_stats->{status} ne 'online';
-			next if $node_freecpu < $vm_cpu;
-			next if $node_freemem < $vm_mem;
+			next if $node_freecpu * $cpu_threshold < $vm_cpu;
+			next if $node_freemem * $mem_threshold < $vm_mem;
 			next if $node_stats->{maxcpu} < $vm_stats->{maxcpu};
 			eval { PVE::QemuServer::check_storage_availability($storecfg, $vmconf, $node) };
 			next if $@;
-- 
2.20.1




More information about the pve-devel mailing list