Skip to content

Commit

Permalink
Merge pull request #22 from redBorder/development
Browse files Browse the repository at this point in the history
Release 0.1.6
  • Loading branch information
malvads authored May 10, 2024
2 parents 490f95a + 7ade8ff commit 7b5ce0d
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 24 deletions.
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,15 @@
cookbook-rb-proxy CHANGELOG
===============

## 0.1.6

- Miguel Álvarez
- [fe69f8f] Update memory_services.rb
- [86466b0] Update prepare_system.rb
- [47c06c8] Clean comments
- [48fe519] Update prepare_system.rb
- [8d08754] Update default.rb

## 0.1.5

- David Vanhoucke
Expand Down
4 changes: 4 additions & 0 deletions resources/attributes/default.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# require 'set' TODO: refactor to this
#Default attributes

#general
Expand Down Expand Up @@ -42,6 +43,9 @@
default["redborder"]["memory_services"]["n2klocd"] = {"count" => 10, "memory" => 0 }
default["redborder"]["memory_services"]["k2http"] = {"count" => 10, "memory" => 0 }

# exclude mem services, setting memory to 0 for each.
default['redborder']['excluded_memory_services'] = ['chef-client']

default["redborder"]["services"] = {}
default["redborder"]["services"]["chef-client"] = true
default["redborder"]["services"]["kafka"] = true
Expand Down
30 changes: 16 additions & 14 deletions resources/libraries/memory_services.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -24,18 +26,19 @@ 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"]
end
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

Expand All @@ -50,4 +53,3 @@ def memory_services(sysmem_total, excluded_services=[])
end
end
end

2 changes: 1 addition & 1 deletion resources/metadata.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
license 'All rights reserved'
description 'Installs/Configures redborder proxy'
long_description IO.read(File.join(File.dirname(__FILE__), 'README.md'))
version '0.1.5'
version '0.1.6'

depends 'rb-selinux'
depends 'zookeeper'
Expand Down
9 changes: 0 additions & 9 deletions resources/recipes/prepare_system.rb
Original file line number Diff line number Diff line change
Expand Up @@ -70,12 +70,3 @@
sysmem_total = (node["memory"]["total"].to_i * 0.90).to_i
#node attributes related with memory are changed inside the function to have simplicity using recursivity
memory_services(sysmem_total)









0 comments on commit 7b5ce0d

Please sign in to comment.