-
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
Add OrchestrationTemplateRunner to queue up orchestration stack deployment #18374
Add OrchestrationTemplateRunner to queue up orchestration stack deployment #18374
Conversation
} | ||
MiqTask.generic_action_with_callback(task_opts, queue_opts) | ||
end | ||
|
||
def update_orchestration_stack |
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.
Similarly we should have a queue version for update too. It can be either included here or with a separate PR.
app/models/service_orchestration.rb
Outdated
@@ -35,6 +35,23 @@ def deploy_orchestration_stack | |||
save_create_options | |||
end | |||
|
|||
def deploy_orchestration_stack_queue | |||
userid ||= User.current_user.try(:userid) |
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.
Is userid
a local variable? ||
will be no effect.
e48c5a1
to
c117a9d
Compare
c117a9d
to
2178ef8
Compare
2178ef8
to
ac9505d
Compare
This pull request is not mergeable. Please rebase and repush. |
ac9505d
to
5cd8b7d
Compare
5cd8b7d
to
7b2fdd5
Compare
The goal of this refactoring is that every promise |
7b2fdd5
to
136b53e
Compare
end | ||
end | ||
|
||
def service |
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.
Try our best to decouple modules. Avoid service
in this class. The job options should contain only parameters necessary to deploy a stack. For update the options can include stack_id too.
self.name = "#{name}, Orchestration Stack ID: #{@orchestration_stack.id}" | ||
miq_task.update_attributes(:name => name) | ||
save! | ||
service.add_resource(@orchestration_stack) |
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.
move this line back to service class. You can add orchestraiton_stack_id to job's options so that the service can read back the stack.
my_signal(minimize_indirect, :post_stack_run, err.message, 'error') | ||
ensure | ||
# create options may never be saved before unless they were overridden | ||
service.save_create_options |
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.
move back to service class
time = Time.zone.now | ||
update_attributes(:started_on => time) | ||
miq_task.update_attributes(:started_on => time) | ||
my_signal(false, :deploy_orchestration_stack) |
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.
increase the queue priority to high
af1562c
to
3735f09
Compare
@bzwei Updated. |
creation_options = stack_options | ||
@orchestration_stack = ManageIQ::Providers::CloudManager::OrchestrationStack.create_stack( | ||
orchestration_manager, stack_name, orchestration_template, creation_options | ||
job_options = { |
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.
why not place all options together without a merge?
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.
stack_options
might change orchestration_manager
and orchestration_template
.
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.
It is hard to understand. In this case, we can do
deploy_stack_options = stack_options
job_options = {
:create_options => deploy_stack_options,
:orchestration_manager_id => orchestration_manager.id,
...
}
app/models/service_orchestration.rb
Outdated
@@ -47,6 +68,8 @@ def orchestration_stack | |||
if @orchestration_stack.nil? && options.fetch_path(:orchestration_stack, 'ems_id') | |||
@orchestration_stack = OrchestrationStack.new(options[:orchestration_stack]) | |||
end | |||
|
|||
@orchestration_stack ||= orchestration_runner_job.orchestration_stack if orchestration_runner_job |
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.
@orchestration_stack ||= orchestration_runner_job.try(:orchestration_stack)
app/models/service_orchestration.rb
Outdated
end | ||
|
||
def wait_on_orchestration_stack | ||
while orchestration_stack.blank? |
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.
You don't need to modify orchestration_stack
method (for performance reason). Change this method to
while deploy_stack_job.orchestration_stack.blank?
...
end
@orchestration_stack = deploy_stack_job.orchestration_stack
This is the only place you need to get the stack from the runner job.
app/models/service_orchestration.rb
Outdated
orchestration_manager, stack_name, orchestration_template, creation_options | ||
job_options = { | ||
:create_options => stack_options, | ||
:priority => MiqQueue::HIGH_PRIORITY, |
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 think we need to set priority always to high. We need high priority to start the job because the current thread is waiting on it. Once it starts, the priority should reduce to normal.
c708c20
to
5bbe071
Compare
app/models/service_orchestration.rb
Outdated
end | ||
|
||
def wait_on_orchestration_stack | ||
while orchestration_runner_job.orchestration_stack.blank? |
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.
clearly this only applies to deploy_stack_job
. update_stack_job
does not need to wait on the stack.
creation_options = stack_options | ||
@orchestration_stack = ManageIQ::Providers::CloudManager::OrchestrationStack.create_stack( | ||
orchestration_manager, stack_name, orchestration_template, creation_options | ||
job_options = { |
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.
It is hard to understand. In this case, we can do
deploy_stack_options = stack_options
job_options = {
:create_options => deploy_stack_options,
:orchestration_manager_id => orchestration_manager.id,
...
}
5bbe071
to
d37428f
Compare
app/models/service_orchestration.rb
Outdated
# Code running with Rails QueryCache enabled, | ||
# need to disable caching for the reload to see updates. | ||
self.class.uncached { reload } | ||
orchestration_runner_job.class.uncached { orchestration_runner_job.reload } |
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.
deploy_stack_job.class.uncached
app/models/service_orchestration.rb
Outdated
self.class.uncached { reload } | ||
orchestration_runner_job.class.uncached { orchestration_runner_job.reload } | ||
end | ||
@orchestration_stack = orchestration_runner_job.orchestration_stack |
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.
deploy_stack_job.orchestration_stack
All provider calls should be placed in the queue with the correct provider zone. Add OrchestrationTemplateRunner to handle the provider calls via MiqQueue. https://bugzilla.redhat.com/show_bug.cgi?id=1656351
d37428f
to
08ab7f4
Compare
Checked commits lfu/manageiq@18f6f21~...08ab7f4 with ruby 2.3.3, rubocop 0.52.1, haml-lint 0.20.0, and yamllint 1.10.0 |
Add OrchestrationTemplateRunner to queue up orchestration stack deployment (cherry picked from commit bb4f8bf) Fixes https://bugzilla.redhat.com/show_bug.cgi?id=1686891
Hammer backport details:
|
Provider specific provisions executed as part of a service provision are supposed to be queued to the provider zone.
Blocks ManageIQ/manageiq-content#500.Fixes https://bugzilla.redhat.com/show_bug.cgi?id=1656351
@miq-bot assign @gmcculloug
@miq-bot add_label bug, gaprindashvili/yes, hammer/yes, services, orchestration