CID-443: rollbacks servers with failed bootstrap

This commit is contained in:
Anton Chuchkalov 2016-03-04 17:50:01 +03:00
parent 63b1a7fa84
commit 231c79ab48
2 changed files with 13 additions and 4 deletions

View File

@ -262,8 +262,8 @@ module Devops
return error_code(:server_not_in_chef_nodes)
end
else
# @out << roll_back
# mongo.server_delete @server.id
roll_back
mongo.server_delete @server.id
msg = "Failed while bootstraping server with id '#{@server.id}'\n"
msg << "Bootstraping operation result was #{bootstrap_status}"
DevopsLogger.logger.error msg
@ -510,7 +510,7 @@ module Devops
def schedule_expiration
if @deploy_env.expires
@out << "Planning expiration in #{@deploy_env.expires}"
puts_and_flush "Planning expiration in #{@deploy_env.expires}"
ExpirationScheduler.new(@deploy_env.expires, @server).schedule_expiration!
end
end

View File

@ -366,10 +366,19 @@ RSpec.describe Devops::Executor::ServerExecutor, type: :executor, stubbed_connec
end
context "when bootstrap wasn't successful" do
it 'returns :server_bootstrap_fail error code' do
before do
allow(executor).to receive(:bootstrap) { 1 }
allow(executor).to receive(:roll_back)
end
it 'returns :server_bootstrap_fail error code' do
expect(two_phase_bootstrap).to eq 2
end
it 'rollbacks server' do
allow(executor).to receive(:roll_back)
two_phase_bootstrap
end
end
context 'when an error occured during bootstrap' do