From b841f9e47d3c3d9d21a962d3536fbf54231f1884 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20Gonz=C3=A1lez?= Date: Thu, 27 Aug 2020 10:47:05 +0200 Subject: [PATCH] B #5045: Fix flow server token expiration error (#168) (cherry picked from commit 3d42b4461ba4b6dd0dcdf09f1b014c3cecb6e01f) --- src/cloud/common/CloudAuth.rb | 2 +- src/flow/lib/EventManager.rb | 3 +-- src/flow/lib/LifeCycleManager.rb | 3 +-- src/flow/lib/ServiceAutoScaler.rb | 17 ++++++----------- src/flow/lib/ServiceWatchDog.rb | 6 +----- 5 files changed, 10 insertions(+), 21 deletions(-) diff --git a/src/cloud/common/CloudAuth.rb b/src/cloud/common/CloudAuth.rb index 6de4b47852..6d668ea318 100644 --- a/src/cloud/common/CloudAuth.rb +++ b/src/cloud/common/CloudAuth.rb @@ -143,7 +143,7 @@ class CloudAuth retrieve_from_userpool(xpath) end - # Selects the username that matches the driver and evaluates to true the + # Selects the username that matches the driver and evaluates to true the # block passed to the function # block:: { |user| true or false } # [return] the username or nil diff --git a/src/flow/lib/EventManager.rb b/src/flow/lib/EventManager.rb index ab4cbe13cd..d03ed598e0 100644 --- a/src/flow/lib/EventManager.rb +++ b/src/flow/lib/EventManager.rb @@ -395,10 +395,9 @@ class EventManager def check_nodes_report(nodes) rc_nodes = { :successful => [], :failure => [] } - client = @cloud_auth.client nodes.delete_if do |node| - vm = OpenNebula::VirtualMachine.new_with_id(node, client) + vm = OpenNebula::VirtualMachine.new_with_id(node, @cloud_auth.client) vm.info diff --git a/src/flow/lib/LifeCycleManager.rb b/src/flow/lib/LifeCycleManager.rb index 4c4f7c93a2..64b0c10633 100644 --- a/src/flow/lib/LifeCycleManager.rb +++ b/src/flow/lib/LifeCycleManager.rb @@ -58,7 +58,7 @@ class ServiceLCM @event_manager = EventManager.new(em_conf).am - @wd = ServiceWD.new(client, em_conf) + @wd = ServiceWD.new(em_conf) # Register Action Manager actions @am.register_action(ACTIONS['DEPLOY_CB'], @@ -94,7 +94,6 @@ class ServiceLCM Thread.new do auto_scaler = ServiceAutoScaler.new(@srv_pool, - client, @cloud_auth, self) auto_scaler.start diff --git a/src/flow/lib/ServiceAutoScaler.rb b/src/flow/lib/ServiceAutoScaler.rb index 44ede7fc39..b3c04d0c0f 100644 --- a/src/flow/lib/ServiceAutoScaler.rb +++ b/src/flow/lib/ServiceAutoScaler.rb @@ -23,23 +23,21 @@ class ServiceAutoScaler # Class constructor # # @param service_pool [OpenNebula::ServicePool] Service pool - # @param clien [OpenNebula::Client] OpenNebula Client # @param cloud_auth [OpenNebula::CloudAuth] Cloud auth to get clients # @param lcm [LifeCycleManager] Lcm for flows - def initialize(service_pool, client, cloud_auth, lcm) + def initialize(service_pool, cloud_auth, lcm) @lcm = lcm @interval = cloud_auth.conf[:autoscaler_interval] @srv_pool = service_pool - @vm_pool = VirtualMachinePool.new(cloud_auth.client) @cloud_auth = cloud_auth - @client = client end # Start auto scaler loop def start loop do @srv_pool.info - @vm_pool.info_all_extended + vm_pool = VirtualMachinePool.new(client) + vm_pool.info_all_extended @srv_pool.each do |service| # fill service roles information @@ -51,7 +49,7 @@ class ServiceAutoScaler 'Checking policies for ' \ "service: #{service.id}" - apply_scaling_policies(service) + apply_scaling_policies(service, vm_pool) end sleep(@interval) @@ -62,9 +60,6 @@ class ServiceAutoScaler # Get OpenNebula client def client - # If there's a client defined use it - return @client unless @client.nil? - # If not, get one via cloud_auth @cloud_auth.client end @@ -73,9 +68,9 @@ class ServiceAutoScaler # to SCALING. Only one role is set to scale. # # @param [OpenNebula::Service] service - def apply_scaling_policies(service) + def apply_scaling_policies(service, vm_pool) service.roles.each do |name, role| - diff, cooldown_duration = role.scale?(@vm_pool) + diff, cooldown_duration = role.scale?(vm_pool) policies = {} policies['elasticity_policies'] = role.elasticity_policies diff --git a/src/flow/lib/ServiceWatchDog.rb b/src/flow/lib/ServiceWatchDog.rb index 4d2ba2354b..cab0932cfa 100644 --- a/src/flow/lib/ServiceWatchDog.rb +++ b/src/flow/lib/ServiceWatchDog.rb @@ -45,14 +45,13 @@ class ServiceWD # Class constructor # # @param options [Hash] event manager options - def initialize(client, options) + def initialize(options) @conf = DEFAULT_CONF.merge(options) @lcm = options[:lcm] @context = ZMQ::Context.new(1) @cloud_auth = @conf[:cloud_auth] @wait_timeout = @cloud_auth.conf[:wait_timeout] - @client = client # Array of running services to watch @mutex = Mutex.new @@ -154,9 +153,6 @@ class ServiceWD # Get OpenNebula client def client - # If there's a client defined use it - return @client unless @client.nil? - # If not, get one via cloud_auth @cloud_auth.client end