Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Performance: Do not schedule smartstate dispatch unless it is needed #15067

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions app/models/job_proxy_dispatcher.rb
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,10 @@ def assign_proxy_to_job(proxy, job)
end
end

def self.waiting?
Job.where(:state => 'waiting_to_start').exists?
end

def pending_jobs(target_class = VmOrTemplate)
class_name = target_class.base_class.name
@zone = MiqServer.my_zone
Expand Down
4 changes: 3 additions & 1 deletion app/models/miq_schedule_worker/jobs.rb
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,9 @@ def job_check_for_evm_snapshots(job_not_found_delay)
end

def job_proxy_dispatcher_dispatch
queue_work_on_each_zone(:class_name => "JobProxyDispatcher", :method_name => "dispatch", :task_id => "job_dispatcher", :priority => MiqQueue::HIGH_PRIORITY, :role => "smartstate", :state => "ready")
if JobProxyDispatcher.waiting?
queue_work_on_each_zone(:class_name => "JobProxyDispatcher", :method_name => "dispatch", :task_id => "job_dispatcher", :priority => MiqQueue::HIGH_PRIORITY, :role => "smartstate", :state => "ready")
end
end

def ems_refresh_timer(klass)
Expand Down