From f9d986cc24d333a57f2dd072c1041403aa9e2453 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miguel=20=C3=81lvarez?= <128592227+malvads@users.noreply.github.com> Date: Tue, 7 May 2024 15:12:27 +0100 Subject: [PATCH] Update memory_services.rb --- resources/libraries/memory_services.rb | 27 ++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/resources/libraries/memory_services.rb b/resources/libraries/memory_services.rb index 89785923..03f7eb66 100644 --- a/resources/libraries/memory_services.rb +++ b/resources/libraries/memory_services.rb @@ -9,7 +9,9 @@ def memory_services(sysmem_total, excluded_services=[]) node["redborder"]["memory_services"].each do |name,mem_s| if node["redborder"]["services"][name] and !excluded_services.include?(name) - memory_services_size = memory_services_size + mem_s["count"] + if !node["redborder"]["excluded_memory_services"].include?(name) + memory_services_size = memory_services_size + mem_s["count"] + end end memory_services_size_total = memory_services_size_total + mem_s["count"] end @@ -24,17 +26,18 @@ def memory_services(sysmem_total, excluded_services=[]) node["redborder"]["memory_services"].each do |name,mem_s| if node["redborder"]["services"][name] and !excluded_services.include?(name) - - # service count memory assigned * system memory / assigned services memory size - memory_serv[name] = (mem_s["count"] * sysmem_total / memory_services_size).round - #if the service has a limit of memory, we have to recalculate all using recursivity - if !mem_s["max_limit"].nil? and memory_serv[name] > mem_s["max_limit"] - memlimit_found = true - excluded_services << name - #assigning the limit of memory for this service - node.default["redborder"]["memory_services"][name]["memory"] = mem_s["max_limit"] - #now we have to take off the memory excluded from the total to recalculate memory wihout excluded services by limit - sysmem_total_limitsless = sysmem_total - mem_s["max_limit"] + if !node["redborder"]["excluded_memory_services"].include?(name) + # service count memory assigned * system memory / assigned services memory size + memory_serv[name] = (mem_s["count"] * sysmem_total / memory_services_size).round + #if the service has a limit of memory, we have to recalculate all using recursivity + if !mem_s["max_limit"].nil? and memory_serv[name] > mem_s["max_limit"] + memlimit_found = true + excluded_services << name + #assigning the limit of memory for this service + node.default["redborder"]["memory_services"][name]["memory"] = mem_s["max_limit"] + #now we have to take off the memory excluded from the total to recalculate memory wihout excluded services by limit + sysmem_total_limitsless = sysmem_total - mem_s["max_limit"] + end end end end