M #-: fix minor bug in OneFlow watch dog

This commit is contained in:
Ruben S. Montero authored and GitHub committed 2020-05-19 13:36:28 +02:00
commit b0ffa98b49
3 files changed
+50 -7

No files matched your search

+13 -4
View File
@@ -59,6 +59,8 @@ class ServiceLCM
@event_manager = EventManager.new(em_conf).am
@wd = ServiceWD.new(client, em_conf)
# Register Action Manager actions
@am.register_action(ACTIONS['DEPLOY_CB'],
method('deploy_cb'))
@@ -89,10 +91,7 @@ class ServiceLCM
Thread.new { catch_up(client) }
Thread.new do
wd = ServiceWD.new(client, em_conf)
wd.start(@srv_pool)
end
Thread.new { @wd.start(@srv_pool) }
Thread.new do
auto_scaler = ServiceAutoScaler.new(@srv_pool,
@@ -243,6 +242,8 @@ class ServiceLCM
if service.all_roles_running?
service.set_state(Service::STATE['RUNNING'])
service.update
@wd.add_service(service_id)
end
# If there is no node in PENDING the service is not modified.
@@ -288,6 +289,8 @@ class ServiceLCM
)
end
@wd.remove_service(service_id)
set_deploy_strategy(service)
roles = service.roles_shutdown
@@ -341,6 +344,8 @@ class ServiceLCM
)
end
@wd.remove_service(service_id)
role = service.roles[role_name]
if role.nil?
@@ -477,6 +482,8 @@ class ServiceLCM
if service.all_roles_running?
service.set_state(Service::STATE['RUNNING'])
@wd.add_service(service_id)
elsif service.strategy == 'straight'
set_deploy_strategy(service)
@@ -647,6 +654,8 @@ class ServiceLCM
service.set_state(Service::STATE['RUNNING'])
service.roles[role_name].set_state(Role::STATE['RUNNING'])
@wd.add_service(service_id)
service.update
end
+37 -1
View File
@@ -53,6 +53,10 @@ class ServiceWD
@cloud_auth = @conf[:cloud_auth]
@wait_timeout = @cloud_auth.conf[:wait_timeout]
@client = client
# Array of running services to watch
@mutex = Mutex.new
@services = []
end
# Start services WD
@@ -93,7 +97,12 @@ class ServiceWD
xml = Nokogiri::XML(Base64.decode64(content))
service_id = split_key[2]
service_id = split_key[2].to_i
@mutex.synchronize{
next unless @services.include?(service_id)
}
node = xml.xpath('/HOOK_MESSAGE/VM/ID').text.to_i
state = xml.xpath('/HOOK_MESSAGE/STATE').text
lcm_state = xml.xpath('/HOOK_MESSAGE/LCM_STATE').text
@@ -120,6 +129,24 @@ class ServiceWD
unsubscribe(subscriber)
end
# Add service to watch dog
#
# @param service_id [String] Service ID
def add_service(service_id)
@mutex.synchronize{
@services << service_id.to_i
}
end
# Remove service from watch dog
#
# @param service_id [String] Service ID
def remove_service(service_id)
@mutex.synchronize{
@services.delete(service_id.to_i)
}
end
private
# Get OpenNebula client
@@ -164,6 +191,15 @@ class ServiceWD
service_pool.each do |service|
service.info
if service.state != Service::STATE['RUNNING'] &&
service.state != Service::STATE['WARNING']
next
end
@mutex.synchronize{
@services << service.id.to_i
}
service.roles.each do |name, role|
role.nodes_ids.each do |node|
check_role_state(client, service.id, name, node)
@@ -47,8 +47,6 @@ module DomainList
vms
end
end
xml_txt = STDIN.read