-
Notifications
You must be signed in to change notification settings - Fork 898
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
[V2V] Allow active InfraConversionJob to be throttled #19277
[V2V] Allow active InfraConversionJob to be throttled #19277
Conversation
I feel like there should be a way for other classes to hook into this and define their own method that the JobProxyDispatcher then uses, but it doesn't look like there's a way. Hypothetically, I'm thinking of something like this:
And then each subclass of |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would like to see this refactored in general down the road, but this is good for now.
app/models/job_proxy_dispatcher.rb
Outdated
@@ -202,7 +202,7 @@ def assign_proxy_to_job(proxy, job) | |||
end | |||
|
|||
def self.waiting? | |||
Job.where(:state => 'waiting_to_start').exists? | |||
Job.where(:state => 'waiting_to_start').exists? || InfraConversionJob.where.not(:state => ['finished', 'waiting_to_start']).exists? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't like that this does two queries given how often this runs.
Instead of ||
can you use .or()
something like this?
>> Job.where(:state => "waiting_to_start").or(Job.where(:type => "InfraConversionJob").where.not(:state => ["finished", "waiting_to_start"]))
Job Load (0.9ms) SELECT "jobs".* FROM "jobs" WHERE ("jobs"."state" = $1 OR "jobs"."type" = $2 AND "jobs"."state" = 'running') LIMIT $3 [["state", "waiting_to_start"], ["type", "InfraConversionJob"], ["LIMIT", 11]]
Job Inst Including Associations (0.0ms - 0rows)
=> #<ActiveRecord::Relation []
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changed the query and added specs. Thanks @agrare
I agree this isn't great but might be the best we can do for now. @fdupont-redhat in addition to the query change can you add a test covering this case? |
Checked commits fabiendupont/manageiq@ea17a7b~...5d483da with ruby 2.4.6, rubocop 0.69.0, haml-lint 0.20.0, and yamllint 1.10.0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 thanks @fdupont-redhat
…unning_infraconversionjob [V2V] Allow active InfraConversionJob to be throttled
…unning_infraconversionjob [V2V] Allow active InfraConversionJob to be throttled (cherry picked from commit 1ec27c3) Fixes https://bugzilla.redhat.com/show_bug.cgi?id=1768518
Ivanchuk backport details:
|
@fdupont-redhat Travis is failing in ivanchuk branch. Are we missing some PR(s) in ivanchuk branch or do the specs added in this PR need to be modified in ivanchuk?
|
Thanks Dan! |
The
JobProxyDispatcher.dispatch
is called only ifJobProxyDispatcher.waiting?
returnstrue
. With existing implementation, it means that there is a Job in statewaiting_to_start
. However, thedispatch
method calls theInfraConversionThrottler.apply_limits
method that we need to run every 15 seconds as long as at least 1 InfraConversionJob is active, i.e. not infinished
orwaiting_to_start
state.This PR extends the check to include verification that active InfraConversionJob exists.
RHBZ: https://bugzilla.redhat.com/show_bug.cgi?id=1690851