Skip to content

Commit

Permalink
Merge pull request #13897 from sseago/queue-update_stack
Browse files Browse the repository at this point in the history
use task queue for update stack operation
  • Loading branch information
gmcculloug committed Feb 16, 2017
2 parents 9e2b41d + 88d5247 commit 594f5e9
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 3 deletions.
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 = {})
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

0 comments on commit 594f5e9

Please sign in to comment.