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

use task queue for update stack operation #13897

Merged
merged 1 commit into from
Feb 16, 2017
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
Original file line number Diff line number Diff line change
Expand Up @@ -60,15 +60,19 @@ def raw_status
raise MiqException::MiqOrchestrationStatusError, err.to_s, err.backtrace
end

def queue_post_scaledown_task(services)
def queue_post_scaledown_task(services, task_id = nil)
MiqQueue.put(:class_name => self.class.name,
:expires_on => Time.now.utc + 2.hours,
:args => [services],
:args => [services, task_id],
:instance_id => id,
:method_name => "post_scaledown_task")
end

def post_scaledown_task(services)
def post_scaledown_task(services, task_id = nil)
task = MiqTask.find(task_id) unless task_id.nil?
if task && task.state == MiqTask::STATE_FINISHED && !task.status_ok?
raise MiqException::MiqQueueError, "Scaledown update failed, not running post scaledown task"
end
raise MiqException::MiqQueueRetryLater.new(:deliver_on => Time.now.utc + 1.minute) unless raw_status.first == 'UPDATE_COMPLETE'
services.each(&:delete_service)
end
Expand Down
16 changes: 16 additions & 0 deletions app/models/orchestration_stack.rb
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,22 @@ def raw_update_stack(_template, _options = {})
raise NotImplementedError, _("raw_update_stack must be implemented in a subclass")
end

def update_stack_queue(userid, template, options = {})
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where does this method get called?
If we add queue version to update, shouldn't we do the same to create and delete?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bzwei I've updated the ems_infra_controller scaling/scaledown actions to call this rather than raw_update_stack (as part of a larger mandate to remove any direct provider calls from UI controllers) -- you can see that in ManageIQ/manageiq-ui-classic#373

As for create/delete, it would make sense to add those, but so far (across all models) we have only added _queue methods for those provider actions that are actually called from the UI. At the moment nothing in the UI calls create or delete on orchestration stacks.

task_opts = {
:action => "updating Orchestration Stack for user #{userid}",
:userid => userid
}
queue_opts = {
:class_name => self.class.name,
:method_name => 'update_stack',
:instance_id => id,
:role => 'ems_operations',
:zone => ext_management_system.my_zone,
:args => [template, options]
}
MiqTask.generic_action_with_callback(task_opts, queue_opts)
end

def update_stack(template, options = {})
raw_update_stack(template, options)
end
Expand Down