Skip to content

Commit

Permalink
Fix Reason NameError using constants included in MiqServer
Browse files Browse the repository at this point in the history
Due to module inclusion spaghetti, it's easier and less confusing
to reference the Reason constants consistently in the MiqServer class,
which is the ultimate destination for all of these modules.

Fixes ManageIQ#13901 introduced in ManageIQ#13805

https://bugzilla.redhat.com/show_bug.cgi?id=1395736
  • Loading branch information
jrafanie committed Feb 14, 2017
1 parent 6636853 commit 3ea55fa
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
4 changes: 2 additions & 2 deletions app/models/miq_server/worker_management/monitor.rb
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ def check_not_responding(class_name = nil)
end

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

def do_system_limit_exceeded
Expand All @@ -113,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, Reason::MEMORY_EXCEEDED)
restart_worker(w, MiqServer::MEMORY_EXCEEDED)
break
end
end
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, Reason::NOT_RESPONDING)
restart_worker(w, MiqServer::NOT_RESPONDING)
return false
end

Expand Down
6 changes: 6 additions & 0 deletions spec/models/miq_server/worker_monitor_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -362,6 +362,12 @@
server.setup_drb_variables
end

it "should mark not responding if not recently heartbeated" do
worker.update(:last_heartbeat => 20.minutes.ago)
expect(server.validate_worker(worker)).to be_falsey
expect(worker.reload.status).to eq(MiqWorker::STATUS_STOPPING)
end

context "for excessive memory" do
before { worker.memory_usage = 2.gigabytes }

Expand Down

0 comments on commit 3ea55fa

Please sign in to comment.