Skip to content

Commit

Permalink
Move constants to Monitor::Reason
Browse files Browse the repository at this point in the history
  • Loading branch information
jrafanie committed Feb 10, 2017
1 parent e5f4bd3 commit b60a5f0
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
6 changes: 2 additions & 4 deletions app/models/miq_server/worker_management/monitor.rb
Original file line number Diff line number Diff line change
Expand Up @@ -99,10 +99,8 @@ def check_not_responding(class_name = nil)
processed_workers.collect(&:id)
end

NOT_RESPONDING = :not_responding
MEMORY_EXCEEDED = :memory_exceeded
def monitor_reason_not_responding?(w)
[NOT_RESPONDING, MEMORY_EXCEEDED].include?(worker_get_monitor_reason(w.pid)) || w.stopping_for_too_long?
[Reason::NOT_RESPONDING, Reason::MEMORY_EXCEEDED].include?(worker_get_monitor_reason(w.pid)) || w.stopping_for_too_long?
end

def do_system_limit_exceeded
Expand All @@ -115,7 +113,7 @@ def do_system_limit_exceeded
msg = "#{w.format_full_log_msg} is being stopped because system resources exceeded threshold, it will be restarted once memory has freed up"
_log.warn(msg)
MiqEvent.raise_evm_event_queue_in_region(w.miq_server, "evm_server_memory_exceeded", :event_details => msg, :type => w.class.name)
restart_worker(w, :memory_exceeded)
restart_worker(w, Reason::MEMORY_EXCEEDED)
break
end
end
Expand Down
3 changes: 3 additions & 0 deletions app/models/miq_server/worker_management/monitor/reason.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
module MiqServer::WorkerManagement::Monitor::Reason
extend ActiveSupport::Concern

MEMORY_EXCEEDED = :memory_exceeded
NOT_RESPONDING = :not_responding

def worker_set_monitor_reason(pid, reason)
@workers_lock.synchronize(:EX) do
@workers[pid][:monitor_reason] = reason if @workers.key?(pid)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ def validate_worker(w)
msg = "#{w.format_full_log_msg} has not responded in #{Time.now.utc - w.last_heartbeat} seconds, restarting worker"
_log.error(msg)
MiqEvent.raise_evm_event_queue(w.miq_server, "evm_worker_not_responding", :event_details => msg, :type => w.class.name)
restart_worker(w, :not_responding)
restart_worker(w, Reason::NOT_RESPONDING)
return false
end

Expand Down

0 comments on commit b60a5f0

Please sign in to comment.