diff --git a/app/models/miq_server/worker_management/monitor.rb b/app/models/miq_server/worker_management/monitor.rb index aadc1934a22..9466bfc1e6c 100644 --- a/app/models/miq_server/worker_management/monitor.rb +++ b/app/models/miq_server/worker_management/monitor.rb @@ -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 @@ -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 diff --git a/app/models/miq_server/worker_management/monitor/validation.rb b/app/models/miq_server/worker_management/monitor/validation.rb index d5d779f1fdc..63d81ef3da7 100644 --- a/app/models/miq_server/worker_management/monitor/validation.rb +++ b/app/models/miq_server/worker_management/monitor/validation.rb @@ -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 diff --git a/spec/models/miq_server/worker_monitor_spec.rb b/spec/models/miq_server/worker_monitor_spec.rb index 83eb6ed3afe..8cf1fed5698 100644 --- a/spec/models/miq_server/worker_monitor_spec.rb +++ b/spec/models/miq_server/worker_monitor_spec.rb @@ -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 }