Fix fail detection for provisioning

Add test to prevent such behavior in future

Change-Id: If833723f0301f2008e6aabfc888d0bdf693f4f2e
Partial-Bug: #1653210
This commit is contained in:
Vladimir Sharshov (warpc) 2016-12-30 12:45:13 +03:00
parent 06fe7856f6
commit b0752c7a78
2 changed files with 11 additions and 4 deletions

View File

@ -129,10 +129,11 @@ module Astute
sleep Astute.config.task_poll_delay
end
failed_uids = shell_tasks.select{ |t| t.failed? }.inject([]) do |task|
failed_uids = shell_tasks.select{ |t| t.failed? }
.inject([]) do |failed_nodes, task|
Astute.logger.error("#{ctx.task_id}: Provision command returned " \
"non zero exit code on node: #{task.node_id}")
failed_uids << task.node_id
failed_nodes << task.node_id
end
failed_uids

View File

@ -201,8 +201,14 @@ describe Astute::ImageProvision do
end
it 'should run return failed nodes' do
provisioner.stubs(:run_shell_task).once.returns([6])
expect(provisioner.run_provision(ctx, nodes.map { |n| n['uid'] }, [])).to eql([6])
Astute::Shell.any_instance.stubs(:process)
Astute::Shell.any_instance.expects(:run).twice
Astute::Shell.any_instance.stubs(:finished?).returns(true)
Astute::Shell.any_instance.expects(:failed?).times(2)
.returns(false)
.then.returns(true)
expect(provisioner.run_provision(ctx, [5, 6], [])).to eql([6])
end
it 'should not erase info about alread failed nodes' do