From 9002a97ca8eee39ec777844cd3289c30af593db1 Mon Sep 17 00:00:00 2001 From: Luis Blanco Date: Tue, 7 May 2024 10:25:11 +0100 Subject: [PATCH 01/15] excluding chef-client not to be a memservice --- resources/recipes/prepare_system.rb | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/resources/recipes/prepare_system.rb b/resources/recipes/prepare_system.rb index 7619da6a..ac154bad 100644 --- a/resources/recipes/prepare_system.rb +++ b/resources/recipes/prepare_system.rb @@ -130,8 +130,7 @@ #getting total system memory less 10% reserved by system 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) - +memory_services(sysmem_total, ['chef-client']) # Don't assign memory to chef because the service will get handled #License From 04f74cf4a7fe30759fa3553e50fab73c2374550d Mon Sep 17 00:00:00 2001 From: Luis Blanco Date: Tue, 7 May 2024 12:04:46 +0100 Subject: [PATCH 02/15] lint quotes and frozen literal --- resources/recipes/prepare_system.rb | 78 ++++++++++++++--------------- 1 file changed, 39 insertions(+), 39 deletions(-) diff --git a/resources/recipes/prepare_system.rb b/resources/recipes/prepare_system.rb index ac154bad..f798934a 100644 --- a/resources/recipes/prepare_system.rb +++ b/resources/recipes/prepare_system.rb @@ -1,4 +1,4 @@ -# +# frozen_string_literal: true # Cookbook Name:: manager # Recipe:: prepare_system # @@ -8,103 +8,103 @@ # extend Rb_manager::Helpers -#clean metadata to get packages upgrades -execute "Clean yum metadata" do - command "yum clean metadata" +# Clean metadata to get packages upgrades +execute 'Clean yum metadata' do + command 'yum clean metadata' end # Set services_group related with the node mode (core, full, ...) -mode = node["redborder"]["mode"] -node["redborder"]["services_group"][mode].each do |s| - node.default["redborder"]["services"][s] = true +mode = node['redborder']['mode'] +node['redborder']['services_group'][mode].each do |s| + node.default['redborder']['services'][s] = true end -if mode != "core" or mode != "full" - node.default["redborder"]["services"]["consul-client"] = true +if mode != 'core' or mode != 'full' + node.default['redborder']['services']['consul-client'] = true end #Set :ipaddress_sync -ipaddress_sync=node["ipaddress"] +ipaddress_sync=node['ipaddress'] sync_net = `cat /etc/redborder/rb_init_conf.yml | grep sync_net | awk '{print $2'} | sed 's|/.*||'`.strip node['network']['interfaces'].each do |interface, details| - next unless "x#{interface}" != "xlo" + next unless "x#{interface}" != 'xlo' ipaddress_sync = `ip route get #{sync_net} | head -n 1 | awk '{for (i=1; i<=NF; i++) if ($i == "src") print $(i+1)}'`.strip end node.default[:ipaddress_sync]=ipaddress_sync #get mac mac_sync = `ip a | grep -w -B2 #{ipaddress_sync} | awk '{print toupper($2)}' | head -n 1 | tr -d '\n'` -node.default["mac_sync"] = mac_sync +node.default['mac_sync'] = mac_sync #Configure and enable chef-client -dnf_package "redborder-chef-client" do +dnf_package 'redborder-chef-client' do flush_cache [:before] action :upgrade end -template "/etc/sysconfig/chef-client" do - source "sysconfig_chef-client.rb" +template '/etc/sysconfig/chef-client' do + source 'sysconfig_chef-client.rb' mode 0644 variables( - :interval => node["chef-client"]["interval"], - :splay => node["chef-client"]["splay"], - :options => node["chef-client"]["options"] + :interval => node['chef-client']['interval'], + :splay => node['chef-client']['splay'], + :options => node['chef-client']['options'] ) end -if node["redborder"]["services"]["chef-client"] - service "chef-client" do +if node['redborder']['services']['chef-client'] + service 'chef-client' do action [:enable, :start] end else - service "chef-client" do + service 'chef-client' do action [:stop] end end #get managers information(name, ip, services...) -cdomain = "" +cdomain = '' File.open('/etc/redborder/cdomain') {|f| cdomain = f.readline.chomp} -node.default["redborder"]["cdomain"] = cdomain +node.default['redborder']['cdomain'] = cdomain #get managers information(name, ip, services...) -node.default["redborder"]["cluster_info"] = get_cluster_info() +node.default['redborder']['cluster_info'] = get_cluster_info() #get managers sorted by service -node.default["redborder"]["managers_per_services"] = managers_per_service() +node.default['redborder']['managers_per_services'] = managers_per_service() #get elasticache nodes -elasticache = Chef::DataBagItem.load("rBglobal", "elasticache") rescue elasticache = {} +elasticache = Chef::DataBagItem.load('rBglobal', 'elasticache') rescue elasticache = {} if !elasticache.empty? - node.default["redborder"]["memcached"]["server_list"] = getElasticacheNodes(elasticache["cfg_address"], elasticache["cfg_port"]) - node.default["redborder"]["memcached"]["port"] = elasticache["cfg_port"] - node.default["redborder"]["memcached"]["hosts"] = joinHostArray2port(node["redborder"]["memcached"]["server_list"], node["redborder"]["memcached"]["port"]).join(",") - node.default["redborder"]["memcached"]["elasticache"] = true + node.default['redborder']['memcached']['server_list'] = getElasticacheNodes(elasticache['cfg_address'], elasticache['cfg_port']) + node.default['redborder']['memcached']['port'] = elasticache['cfg_port'] + node.default['redborder']['memcached']['hosts'] = joinHostArray2port(node['redborder']['memcached']['server_list'], node['redborder']['memcached']['port']).join(',') + node.default['redborder']['memcached']['elasticache'] = true else - node.default["redborder"]["memcached"]["hosts"] = "memcached.service.#{node["redborder"]["cdomain"]}:#{node["redborder"]["memcached"]["port"]}" + node.default['redborder']['memcached']['hosts'] = "memcached.service.#{node['redborder']['cdomain']}:#{node['redborder']['memcached']['port']}" end #get organizations for http2k -node.default["redborder"]["organizations"] = get_orgs() if node["redborder"]["services"]["http2k"] +node.default['redborder']['organizations'] = get_orgs() if node['redborder']['services']['http2k'] #get sensors info -node.default["redborder"]["sensors_info"] = get_sensors_info() +node.default['redborder']['sensors_info'] = get_sensors_info() #get sensors info full info -node.default["redborder"]["sensors_info_all"] = get_sensors_all_info() +node.default['redborder']['sensors_info_all'] = get_sensors_all_info() #get sensors info of all flow sensors -node.default["redborder"]["all_flow_sensors_info"] = get_all_flow_sensors_info() +node.default['redborder']['all_flow_sensors_info'] = get_all_flow_sensors_info() #get logstash pipelines -node.default["redborder"]["logstash"]["pipelines"] = get_pipelines() +node.default['redborder']['logstash']['pipelines'] = get_pipelines() #get namespaces -node.default["redborder"]["namespaces"] = get_namespaces +node.default['redborder']['namespaces'] = get_namespaces #get string with all zookeeper hosts and port separated by commas, its needed for multiples services -zk_port = node["redborder"]["zookeeper"]["port"] +zk_port = node['redborder']['zookeeper']['port'] #zk_hosts = node["redborder"]["managers_per_services"]["zookeeper"].map {|z| "#{z}.node:#{zk_port}"}.join(',') -node.default["redborder"]["zookeeper"]["zk_hosts"] = "zookeeper.service.#{node["redborder"]["cdomain"]}:#{node["redborder"]["zookeeper"]["port"]}" +node.default['redborder']['zookeeper']['zk_hosts'] = "zookeeper.service.#{node['redborder']['cdomain']}:#{node['redborder']['zookeeper']['port']}" #set kafka host index if kafka is enabled in this host if node["redborder"]["managers_per_services"]["kafka"].include?(node.name) From 84675041d44921b6fbac27fc09ab92690044cc3a Mon Sep 17 00:00:00 2001 From: Luis Blanco Date: Tue, 7 May 2024 12:05:46 +0100 Subject: [PATCH 03/15] excluded mem services is a new attribute of data structure set --- resources/attributes/default.rb | 3 +++ resources/recipes/prepare_system.rb | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/resources/attributes/default.rb b/resources/attributes/default.rb index 6477e968..0d246978 100644 --- a/resources/attributes/default.rb +++ b/resources/attributes/default.rb @@ -1,3 +1,4 @@ +require 'set' # In case of reapeating, set will handle. Array won't #Default attributes #general @@ -92,6 +93,8 @@ default["redborder"]["memory_services"]["n2klocd"] = {"count" => 10, "memory" => 0 } default["redborder"]["memory_services"]["redborder-cep"] = {"count" => 10, "memory" => 0 } default["redborder"]["memory_services"]["rb-aioutliers"] = {"count" => 10, "memory" => 0 } +# excluded mem services +default['redborder']['excluded_memservices'] = Set.new(['chef-client']) # Don't assign memory to chef because the service will get handled # default attributes for managers_info, it would be rewriten with the cluster config default["redborder"]["cluster_info"] = {} diff --git a/resources/recipes/prepare_system.rb b/resources/recipes/prepare_system.rb index f798934a..6dc6977d 100644 --- a/resources/recipes/prepare_system.rb +++ b/resources/recipes/prepare_system.rb @@ -130,7 +130,7 @@ #getting total system memory less 10% reserved by system 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, ['chef-client']) # Don't assign memory to chef because the service will get handled +memory_services(sysmem_total, node['redborder']['excluded_memservices']) #License From 15303c6d321689009d3ea04796eaad03510f1f30 Mon Sep 17 00:00:00 2001 From: Luis Blanco Date: Tue, 7 May 2024 12:09:10 +0100 Subject: [PATCH 04/15] must provide excluded mem services --- resources/libraries/memory_services.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/resources/libraries/memory_services.rb b/resources/libraries/memory_services.rb index 89785923..cfe5d60f 100644 --- a/resources/libraries/memory_services.rb +++ b/resources/libraries/memory_services.rb @@ -1,6 +1,6 @@ module Rb_manager module Helpers - def memory_services(sysmem_total, excluded_services=[]) + def memory_services(sysmem_total, excluded_services) memory_serv = {} memory_services_size = 0 memory_services_size_total = 0 From ec61e6abfbd272efed9abbfb1a0c3920409e320d Mon Sep 17 00:00:00 2001 From: Luis Blanco Date: Tue, 7 May 2024 12:37:11 +0100 Subject: [PATCH 05/15] Revert "lint quotes and frozen literal" This reverts commit 04f74cf4a7fe30759fa3553e50fab73c2374550d. --- resources/recipes/prepare_system.rb | 78 ++++++++++++++--------------- 1 file changed, 39 insertions(+), 39 deletions(-) diff --git a/resources/recipes/prepare_system.rb b/resources/recipes/prepare_system.rb index 6dc6977d..34093141 100644 --- a/resources/recipes/prepare_system.rb +++ b/resources/recipes/prepare_system.rb @@ -1,4 +1,4 @@ -# frozen_string_literal: true +# # Cookbook Name:: manager # Recipe:: prepare_system # @@ -8,103 +8,103 @@ # extend Rb_manager::Helpers -# Clean metadata to get packages upgrades -execute 'Clean yum metadata' do - command 'yum clean metadata' +#clean metadata to get packages upgrades +execute "Clean yum metadata" do + command "yum clean metadata" end # Set services_group related with the node mode (core, full, ...) -mode = node['redborder']['mode'] -node['redborder']['services_group'][mode].each do |s| - node.default['redborder']['services'][s] = true +mode = node["redborder"]["mode"] +node["redborder"]["services_group"][mode].each do |s| + node.default["redborder"]["services"][s] = true end -if mode != 'core' or mode != 'full' - node.default['redborder']['services']['consul-client'] = true +if mode != "core" or mode != "full" + node.default["redborder"]["services"]["consul-client"] = true end #Set :ipaddress_sync -ipaddress_sync=node['ipaddress'] +ipaddress_sync=node["ipaddress"] sync_net = `cat /etc/redborder/rb_init_conf.yml | grep sync_net | awk '{print $2'} | sed 's|/.*||'`.strip node['network']['interfaces'].each do |interface, details| - next unless "x#{interface}" != 'xlo' + next unless "x#{interface}" != "xlo" ipaddress_sync = `ip route get #{sync_net} | head -n 1 | awk '{for (i=1; i<=NF; i++) if ($i == "src") print $(i+1)}'`.strip end node.default[:ipaddress_sync]=ipaddress_sync #get mac mac_sync = `ip a | grep -w -B2 #{ipaddress_sync} | awk '{print toupper($2)}' | head -n 1 | tr -d '\n'` -node.default['mac_sync'] = mac_sync +node.default["mac_sync"] = mac_sync #Configure and enable chef-client -dnf_package 'redborder-chef-client' do +dnf_package "redborder-chef-client" do flush_cache [:before] action :upgrade end -template '/etc/sysconfig/chef-client' do - source 'sysconfig_chef-client.rb' +template "/etc/sysconfig/chef-client" do + source "sysconfig_chef-client.rb" mode 0644 variables( - :interval => node['chef-client']['interval'], - :splay => node['chef-client']['splay'], - :options => node['chef-client']['options'] + :interval => node["chef-client"]["interval"], + :splay => node["chef-client"]["splay"], + :options => node["chef-client"]["options"] ) end -if node['redborder']['services']['chef-client'] - service 'chef-client' do +if node["redborder"]["services"]["chef-client"] + service "chef-client" do action [:enable, :start] end else - service 'chef-client' do + service "chef-client" do action [:stop] end end #get managers information(name, ip, services...) -cdomain = '' +cdomain = "" File.open('/etc/redborder/cdomain') {|f| cdomain = f.readline.chomp} -node.default['redborder']['cdomain'] = cdomain +node.default["redborder"]["cdomain"] = cdomain #get managers information(name, ip, services...) -node.default['redborder']['cluster_info'] = get_cluster_info() +node.default["redborder"]["cluster_info"] = get_cluster_info() #get managers sorted by service -node.default['redborder']['managers_per_services'] = managers_per_service() +node.default["redborder"]["managers_per_services"] = managers_per_service() #get elasticache nodes -elasticache = Chef::DataBagItem.load('rBglobal', 'elasticache') rescue elasticache = {} +elasticache = Chef::DataBagItem.load("rBglobal", "elasticache") rescue elasticache = {} if !elasticache.empty? - node.default['redborder']['memcached']['server_list'] = getElasticacheNodes(elasticache['cfg_address'], elasticache['cfg_port']) - node.default['redborder']['memcached']['port'] = elasticache['cfg_port'] - node.default['redborder']['memcached']['hosts'] = joinHostArray2port(node['redborder']['memcached']['server_list'], node['redborder']['memcached']['port']).join(',') - node.default['redborder']['memcached']['elasticache'] = true + node.default["redborder"]["memcached"]["server_list"] = getElasticacheNodes(elasticache["cfg_address"], elasticache["cfg_port"]) + node.default["redborder"]["memcached"]["port"] = elasticache["cfg_port"] + node.default["redborder"]["memcached"]["hosts"] = joinHostArray2port(node["redborder"]["memcached"]["server_list"], node["redborder"]["memcached"]["port"]).join(",") + node.default["redborder"]["memcached"]["elasticache"] = true else - node.default['redborder']['memcached']['hosts'] = "memcached.service.#{node['redborder']['cdomain']}:#{node['redborder']['memcached']['port']}" + node.default["redborder"]["memcached"]["hosts"] = "memcached.service.#{node["redborder"]["cdomain"]}:#{node["redborder"]["memcached"]["port"]}" end #get organizations for http2k -node.default['redborder']['organizations'] = get_orgs() if node['redborder']['services']['http2k'] +node.default["redborder"]["organizations"] = get_orgs() if node["redborder"]["services"]["http2k"] #get sensors info -node.default['redborder']['sensors_info'] = get_sensors_info() +node.default["redborder"]["sensors_info"] = get_sensors_info() #get sensors info full info -node.default['redborder']['sensors_info_all'] = get_sensors_all_info() +node.default["redborder"]["sensors_info_all"] = get_sensors_all_info() #get sensors info of all flow sensors -node.default['redborder']['all_flow_sensors_info'] = get_all_flow_sensors_info() +node.default["redborder"]["all_flow_sensors_info"] = get_all_flow_sensors_info() #get logstash pipelines -node.default['redborder']['logstash']['pipelines'] = get_pipelines() +node.default["redborder"]["logstash"]["pipelines"] = get_pipelines() #get namespaces -node.default['redborder']['namespaces'] = get_namespaces +node.default["redborder"]["namespaces"] = get_namespaces #get string with all zookeeper hosts and port separated by commas, its needed for multiples services -zk_port = node['redborder']['zookeeper']['port'] +zk_port = node["redborder"]["zookeeper"]["port"] #zk_hosts = node["redborder"]["managers_per_services"]["zookeeper"].map {|z| "#{z}.node:#{zk_port}"}.join(',') -node.default['redborder']['zookeeper']['zk_hosts'] = "zookeeper.service.#{node['redborder']['cdomain']}:#{node['redborder']['zookeeper']['port']}" +node.default["redborder"]["zookeeper"]["zk_hosts"] = "zookeeper.service.#{node["redborder"]["cdomain"]}:#{node["redborder"]["zookeeper"]["port"]}" #set kafka host index if kafka is enabled in this host if node["redborder"]["managers_per_services"]["kafka"].include?(node.name) From 75329b85325e42aeb73366e0eabe6ad355259488 Mon Sep 17 00:00:00 2001 From: Luis Blanco Date: Tue, 7 May 2024 12:37:52 +0100 Subject: [PATCH 06/15] Revert "must provide excluded mem services" This reverts commit 15303c6d321689009d3ea04796eaad03510f1f30. --- resources/libraries/memory_services.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/resources/libraries/memory_services.rb b/resources/libraries/memory_services.rb index cfe5d60f..89785923 100644 --- a/resources/libraries/memory_services.rb +++ b/resources/libraries/memory_services.rb @@ -1,6 +1,6 @@ module Rb_manager module Helpers - def memory_services(sysmem_total, excluded_services) + def memory_services(sysmem_total, excluded_services=[]) memory_serv = {} memory_services_size = 0 memory_services_size_total = 0 From 749a04155740edfacb52ebdd8a8ff30f705655cd Mon Sep 17 00:00:00 2001 From: Luis Blanco Date: Tue, 7 May 2024 12:40:21 +0100 Subject: [PATCH 07/15] normalize --- resources/attributes/default.rb | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/resources/attributes/default.rb b/resources/attributes/default.rb index 0d246978..d2fc9042 100644 --- a/resources/attributes/default.rb +++ b/resources/attributes/default.rb @@ -1,4 +1,4 @@ -require 'set' # In case of reapeating, set will handle. Array won't +# require 'set' # In case of reapeating, set will handle. Array won't. TODO: refactor to this line #Default attributes #general @@ -94,7 +94,8 @@ default["redborder"]["memory_services"]["redborder-cep"] = {"count" => 10, "memory" => 0 } default["redborder"]["memory_services"]["rb-aioutliers"] = {"count" => 10, "memory" => 0 } # excluded mem services -default['redborder']['excluded_memservices'] = Set.new(['chef-client']) # Don't assign memory to chef because the service will get handled +# default['redborder']['excluded_memservices'] = Set.new(['chef-client']) # TODO: refactor to this line +default['redborder']['excluded_memservices'] = ['chef-client'] # Don't assign memory to chef because the service will get handled # default attributes for managers_info, it would be rewriten with the cluster config default["redborder"]["cluster_info"] = {} From 546e802a33a7f7878eac813700603fbe71432fbf 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 12:50:40 +0100 Subject: [PATCH 08/15] rename to excluded_memory_services --- resources/attributes/default.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/resources/attributes/default.rb b/resources/attributes/default.rb index d2fc9042..ab56434b 100644 --- a/resources/attributes/default.rb +++ b/resources/attributes/default.rb @@ -95,7 +95,7 @@ default["redborder"]["memory_services"]["rb-aioutliers"] = {"count" => 10, "memory" => 0 } # excluded mem services # default['redborder']['excluded_memservices'] = Set.new(['chef-client']) # TODO: refactor to this line -default['redborder']['excluded_memservices'] = ['chef-client'] # Don't assign memory to chef because the service will get handled +default['redborder']['excluded_memory_services'] = %w[chef-client] # Don't assign memory to chef because the service will get handled # default attributes for managers_info, it would be rewriten with the cluster config default["redborder"]["cluster_info"] = {} From 7dcba4876340e9939e4b3db6810d18626c71a306 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 12:51:23 +0100 Subject: [PATCH 09/15] Update prepare_system.rb Rename to excluded_memory_services --- resources/recipes/prepare_system.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/resources/recipes/prepare_system.rb b/resources/recipes/prepare_system.rb index 34093141..2a6c0ee4 100644 --- a/resources/recipes/prepare_system.rb +++ b/resources/recipes/prepare_system.rb @@ -130,7 +130,7 @@ #getting total system memory less 10% reserved by system 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, node['redborder']['excluded_memservices']) +memory_services(sysmem_total, node['redborder']['excluded_memory_services']) #License From ff06e7350d4724b62da59f5a94daf32eb9be792d 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 14:22:59 +0100 Subject: [PATCH 10/15] Update prepare_system.rb Use node.default in order to specify precedence level --- resources/recipes/prepare_system.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/resources/recipes/prepare_system.rb b/resources/recipes/prepare_system.rb index 2a6c0ee4..4112c828 100644 --- a/resources/recipes/prepare_system.rb +++ b/resources/recipes/prepare_system.rb @@ -130,7 +130,7 @@ #getting total system memory less 10% reserved by system 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, node['redborder']['excluded_memory_services']) +memory_services(sysmem_total, node.default['redborder']['excluded_memory_services']) #License From 3db3a145b0d2d8e7dff76cae9dc29718f1154894 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 14:25:06 +0100 Subject: [PATCH 11/15] Clean comments --- resources/attributes/default.rb | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/resources/attributes/default.rb b/resources/attributes/default.rb index ab56434b..27135854 100644 --- a/resources/attributes/default.rb +++ b/resources/attributes/default.rb @@ -1,4 +1,3 @@ -# require 'set' # In case of reapeating, set will handle. Array won't. TODO: refactor to this line #Default attributes #general @@ -93,9 +92,9 @@ default["redborder"]["memory_services"]["n2klocd"] = {"count" => 10, "memory" => 0 } default["redborder"]["memory_services"]["redborder-cep"] = {"count" => 10, "memory" => 0 } default["redborder"]["memory_services"]["rb-aioutliers"] = {"count" => 10, "memory" => 0 } -# excluded mem services -# default['redborder']['excluded_memservices'] = Set.new(['chef-client']) # TODO: refactor to this line -default['redborder']['excluded_memory_services'] = %w[chef-client] # Don't assign memory to chef because the service will get handled + +# exclude mem services, setting memory to 0 for each. +default['redborder']['excluded_memory_services'] = %w[chef-client] # default attributes for managers_info, it would be rewriten with the cluster config default["redborder"]["cluster_info"] = {} 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 12/15] 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 From 1c900b627370f4ead6b8089b2496e427703c5dd8 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:13:13 +0100 Subject: [PATCH 13/15] Update prepare_system.rb --- resources/recipes/prepare_system.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/resources/recipes/prepare_system.rb b/resources/recipes/prepare_system.rb index 4112c828..0f97e046 100644 --- a/resources/recipes/prepare_system.rb +++ b/resources/recipes/prepare_system.rb @@ -130,7 +130,7 @@ #getting total system memory less 10% reserved by system 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, node.default['redborder']['excluded_memory_services']) +memory_services(sysmem_total) #License From 0ecb7819790cd43a467fd1705c311214c2b0e116 Mon Sep 17 00:00:00 2001 From: JuanSheba Date: Fri, 10 May 2024 15:02:40 +0100 Subject: [PATCH 14/15] Release 1.7.9 --- CHANGELOG.md | 24 ++++++++++++++++++++++++ resources/metadata.rb | 2 +- 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8757eda7..018d8894 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,30 @@ cookbook-rb-manager CHANGELOG =============== +## 1.7.9 + + - jsotofernandez + - [11d5833] Merge pull request #129 from redBorder/bugfix/#17186_exclude_chef_for_being_cgrouped + - Luis Blanco + - [1c8be40] add clean operation to makefile + - [749a041] normalize + - [75329b8] Revert "must provide excluded mem services" + - [ec61e6a] Revert "lint quotes and frozen literal" + - [15303c6] must provide excluded mem services + - [8467504] excluded mem services is a new attribute of data structure set + - [04f74cf] lint quotes and frozen literal + - [9002a97] excluding chef-client not to be a memservice + - Miguel Álvarez + - [c251329] Merge pull request #133 from redBorder/revert-132-bugfix/17236_logstash_enabled_without_pipelines + - [13246b8] Revert "Prevent logstash to be enabled when no pipelines are in the node (#132)" + - [7c0b5c4] Prevent logstash to be enabled when no pipelines are in the node (#132) + - [1c900b6] Update prepare_system.rb + - [f9d986c] Update memory_services.rb + - [3db3a14] Clean comments + - [ff06e73] Update prepare_system.rb + - [7dcba48] Update prepare_system.rb + - [546e802] rename to excluded_memory_services + ## 1.7.8 - nilsver diff --git a/resources/metadata.rb b/resources/metadata.rb index 5ee4375d..9a875064 100644 --- a/resources/metadata.rb +++ b/resources/metadata.rb @@ -4,7 +4,7 @@ license 'All rights reserved' description 'Installs/Configures redborder manager' long_description IO.read(File.join(File.dirname(__FILE__), 'README.md')) -version '1.7.8' +version '1.7.9' depends 'chef-server' depends 'zookeeper' From d5b04ab62c8615e13edc08cae528c06f823d3142 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miguel=20=C3=81lvarez?= <128592227+malvads@users.noreply.github.com> Date: Fri, 10 May 2024 15:04:02 +0100 Subject: [PATCH 15/15] Update CHANGELOG.md --- CHANGELOG.md | 17 ----------------- 1 file changed, 17 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 018d8894..adb6ada5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,26 +3,9 @@ cookbook-rb-manager CHANGELOG ## 1.7.9 - - jsotofernandez - - [11d5833] Merge pull request #129 from redBorder/bugfix/#17186_exclude_chef_for_being_cgrouped - - Luis Blanco - - [1c8be40] add clean operation to makefile - - [749a041] normalize - - [75329b8] Revert "must provide excluded mem services" - - [ec61e6a] Revert "lint quotes and frozen literal" - - [15303c6] must provide excluded mem services - - [8467504] excluded mem services is a new attribute of data structure set - - [04f74cf] lint quotes and frozen literal - - [9002a97] excluding chef-client not to be a memservice - Miguel Álvarez - - [c251329] Merge pull request #133 from redBorder/revert-132-bugfix/17236_logstash_enabled_without_pipelines - - [13246b8] Revert "Prevent logstash to be enabled when no pipelines are in the node (#132)" - - [7c0b5c4] Prevent logstash to be enabled when no pipelines are in the node (#132) - [1c900b6] Update prepare_system.rb - [f9d986c] Update memory_services.rb - - [3db3a14] Clean comments - - [ff06e73] Update prepare_system.rb - - [7dcba48] Update prepare_system.rb - [546e802] rename to excluded_memory_services ## 1.7.8