Skip to content

Commit

Permalink
B #5045: Fix flow server token expiration error (#168)
Browse files Browse the repository at this point in the history
  • Loading branch information
Christian González authored Aug 27, 2020
1 parent 3c3b237 commit 3d42b44
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 21 deletions.
2 changes: 1 addition & 1 deletion src/cloud/common/CloudAuth.rb
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ def get_password(username, driver=nil)
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
Expand Down
3 changes: 1 addition & 2 deletions src/flow/lib/EventManager.rb
Original file line number Diff line number Diff line change
Expand Up @@ -395,10 +395,9 @@ def check_nodes(nodes, state, lcm_state, subscriber)

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

Expand Down
3 changes: 1 addition & 2 deletions src/flow/lib/LifeCycleManager.rb
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ def initialize(client, concurrency, cloud_auth)

@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'],
Expand Down Expand Up @@ -94,7 +94,6 @@ def initialize(client, concurrency, cloud_auth)

Thread.new do
auto_scaler = ServiceAutoScaler.new(@srv_pool,
client,
@cloud_auth,
self)
auto_scaler.start
Expand Down
17 changes: 6 additions & 11 deletions src/flow/lib/ServiceAutoScaler.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -51,7 +49,7 @@ def start
'Checking policies for ' \
"service: #{service.id}"

apply_scaling_policies(service)
apply_scaling_policies(service, vm_pool)
end

sleep(@interval)
Expand All @@ -62,9 +60,6 @@ def start

# 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
Expand All @@ -73,9 +68,9 @@ def client
# 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
Expand Down
6 changes: 1 addition & 5 deletions src/flow/lib/ServiceWatchDog.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -154,9 +153,6 @@ def remove_service(service_id)

# 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
Expand Down

0 comments on commit 3d42b44

Please sign in to comment.