Skip to content

Commit

Permalink
Merge pull request ManageIQ#17451 from lfu/log_worker_id_1535237
Browse files Browse the repository at this point in the history
 Keep track of the server ids where the automate task has been processed.
  • Loading branch information
gmcculloug authored Jun 19, 2018
2 parents a17e881 + 96ab071 commit 84e9fa9
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 0 deletions.
1 change: 1 addition & 0 deletions app/models/miq_provision/state_machine.rb
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ def mark_as_completed
end

def finish
mark_execution_servers
if status != 'Error'
number_of_vms = get_option(:number_of_vms).to_i
pass = get_option(:pass)
Expand Down
1 change: 1 addition & 0 deletions app/models/miq_request_task/state_machine.rb
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ def prematurely_finished?
end

def requeue_phase
mark_execution_servers
save # Save current phase_context
MiqQueue.put(
:class_name => self.class.name,
Expand Down
6 changes: 6 additions & 0 deletions app/models/mixins/miq_request_mixin.rb
Original file line number Diff line number Diff line change
Expand Up @@ -169,4 +169,10 @@ def request_dialog(action_name)
dialog = ResourceActionWorkflow.new(values, get_user, ra, {}).dialog
DialogSerializer.new.serialize(Array[dialog]).first
end

def mark_execution_servers
options[:executed_on_servers] ||= []
options[:executed_on_servers] << MiqServer.my_server.id
update_attributes(:options => options)
end
end
18 changes: 18 additions & 0 deletions spec/models/service_template_provision_task_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -233,5 +233,23 @@ def service_resource_id(index, scaling_max)
@task_1_2.update_and_notify_parent(:state => "finished", :status => "Ok", :message => "Test Message")
end
end

describe "#mark_execution_servers" do
let(:server) { FactoryGirl.create(:miq_server) }
before { allow(MiqServer).to receive(:my_server).and_return(server) }

it "with new server id" do
@task_0.mark_execution_servers
expect(@task_0.options[:executed_on_servers]).to eq([server.id])
end

it "with existing server id" do
@task_0.options[:executed_on_servers] = [server.id]
@task_0.save!

@task_0.mark_execution_servers
expect(@task_0.options[:executed_on_servers]).to eq([server.id, server.id])
end
end
end
end

0 comments on commit 84e9fa9

Please sign in to comment.