Merge branch 'remove_chef_client_options' into qa

This commit is contained in:
Anton Chuchkalov 2016-03-08 10:16:09 +03:00
commit f679fbb638
9 changed files with 2 additions and 37 deletions

View File

@ -28,7 +28,6 @@ class Deploy < Handler
job_ids = post("/deploy", job_ids = post("/deploy",
names: names, names: names,
tags: options[:tags], tags: options[:tags],
chef_client_options: options[:chef_client_options],
named_task: options[:named_task] named_task: options[:named_task]
) )
reports_urls(job_ids) reports_urls(job_ids)

View File

@ -18,7 +18,6 @@ class DeployOptions < CommonOptions
parser.recognize_option_value(:tag, variable: 'TAG1,TAG2...') do |tags| parser.recognize_option_value(:tag, variable: 'TAG1,TAG2...') do |tags|
options[:tags] = tags.split(",") options[:tags] = tags.split(",")
end end
parser.recognize_option_value(:chef_client_options)
parser.recognize_option_value(:named_task) parser.recognize_option_value(:named_task)
end end
end end

View File

@ -314,7 +314,6 @@ en:
descriptions: descriptions:
deploy: deploy:
tag: 'Tag names, comma separated list' tag: 'Tag names, comma separated list'
chef_client_options: 'String like "-o role[foo]"'
named_task: Name of task to run named_task: Name of task to run
image: image:
provider: Image provider provider: Image provider

View File

@ -33,7 +33,6 @@ module Devops
begin begin
deploy_info = create_deploy_info(s, project, body["build_number"]) deploy_info = create_deploy_info(s, project, body["build_number"])
deploy_info["run_list"] = run_list if run_list deploy_info["run_list"] = run_list if run_list
set_chef_client_options(deploy_info, s, project, body['chef_client_options'])
deploy_info["named_task"] = body["named_task"] deploy_info["named_task"] = body["named_task"]
jid = Worker.start_async(DeployWorker, jid = Worker.start_async(DeployWorker,
@ -120,16 +119,6 @@ module Devops
end end
end end
private
# env's chef client options may be nil or empty string; it's OK.
def set_chef_client_options(deploy_info, server, project, single_run_options)
if single_run_options
deploy_info['chef_client_options'] = single_run_options
else
deploy_info['chef_client_options'] = project.deploy_env(server.deploy_env).chef_client_options
end
end
end end
end end
end end

View File

@ -18,7 +18,6 @@ module Devops
# "tags": [], -> array of tags to apply on each server before running chef-client # "tags": [], -> array of tags to apply on each server before running chef-client
# "build_number": "", -> string, build number to deploy # "build_number": "", -> string, build number to deploy
# "run_list": [], -> array of strings to set run_list for chef-client # "run_list": [], -> array of strings to set run_list for chef-client
# "chef_client_options": "", String, optional. May be used to redefine run_list
# } # }
# #
# * *Returns* : text stream # * *Returns* : text stream

View File

@ -30,9 +30,6 @@ module Devops
::Validators::FieldValidator::FieldType::String, ::Validators::FieldValidator::FieldType::String,
::Validators::FieldValidator::Expires] ::Validators::FieldValidator::Expires]
set_field_validators :chef_client_options, [::Validators::FieldValidator::Nil,
::Validators::FieldValidator::FieldType::String]
def initialize d={} def initialize d={}
self.identifier = d["identifier"] self.identifier = d["identifier"]
set_provider(d) set_provider(d)
@ -41,7 +38,6 @@ module Devops
self.expires = d["expires"] self.expires = d["expires"]
b = d["users"] || [] b = d["users"] || []
self.users = b.uniq self.users = b.uniq
self.chef_client_options = d["chef_client_options"]
end end
def to_hash def to_hash
@ -49,8 +45,7 @@ module Devops
"identifier" => self.identifier, "identifier" => self.identifier,
"run_list" => self.run_list, "run_list" => self.run_list,
"expires" => self.expires, "expires" => self.expires,
"users" => self.users, "users" => self.users
"chef_client_options" => self.chef_client_options
}.merge(provider_hash) }.merge(provider_hash)
end end

View File

@ -397,9 +397,7 @@ module Devops
@out.flush @out.flush
cmd << " -j http://#{DevopsConfig.config[:address]}:#{DevopsConfig.config[:port]}/#{DevopsConfig.config[:url_prefix]}/v2.0/deploy/data/#{file}" cmd << " -j http://#{DevopsConfig.config[:address]}:#{DevopsConfig.config[:port]}/#{DevopsConfig.config[:url_prefix]}/v2.0/deploy/data/#{file}"
else else
if deploy_info['chef_client_options'].present? if deploy_info['named_task'].present?
cmd << " #{deploy_info['chef_client_options']}"
elsif deploy_info['named_task'].present?
named_task = @project.named_tasks.detect {|task| task['name'] == deploy_info['named_task']} named_task = @project.named_tasks.detect {|task| task['name'] == deploy_info['named_task']}
raise "Named task #{deploy_info['named_task']} doesn't exist." unless named_task raise "Named task #{deploy_info['named_task']} doesn't exist." unless named_task
puts_and_flush "Using named task #{deploy_info['named_task']}." puts_and_flush "Using named task #{deploy_info['named_task']}."

View File

@ -585,18 +585,6 @@ RSpec.describe Devops::Executor::ServerExecutor, type: :executor, stubbed_connec
deploy_server deploy_server
end end
it "uses chef_client_options from deploy_info if it is set" do
deploy_info['chef_client_options'] = '-r role'
expect(stubbed_knife).to receive(:ssh_stream).with(anything, 'chef-client --no-color -r role', any_args)
deploy_server
end
it "doesn't use chef_client_options from deploy_info if it's blank string" do
deploy_info['chef_client_options'] = ''
expect(stubbed_knife).to receive(:ssh_stream).with(anything, 'chef-client --no-color', any_args)
deploy_server
end
it "uses run list from named_task if it's set" do it "uses run list from named_task if it's set" do
project.named_tasks = [{'name' => 'foo', 'run_list' => ['role[backend]', 'role[frontend]']}] project.named_tasks = [{'name' => 'foo', 'run_list' => ['role[backend]', 'role[frontend]']}]
deploy_info['named_task'] = 'foo' deploy_info['named_task'] = 'foo'

View File

@ -10,7 +10,6 @@ RSpec.shared_examples 'deploy env' do
include_examples 'field type validation', :run_list, :not_nil, :maybe_empty_array, :run_list, :field_validator include_examples 'field type validation', :run_list, :not_nil, :maybe_empty_array, :run_list, :field_validator
include_examples 'field type validation', :users, :not_nil, :maybe_empty_array, :field_validator include_examples 'field type validation', :users, :not_nil, :maybe_empty_array, :field_validator
include_examples 'field type validation', :expires, :maybe_nil, :non_empty_string, :field_validator include_examples 'field type validation', :expires, :maybe_nil, :non_empty_string, :field_validator
include_examples 'field type validation', :chef_client_options, :maybe_nil, :maybe_empty_string, :field_validator
it 'should be valid only with all users available' do it 'should be valid only with all users available' do
expect(build(validated_model_name, users: ['root'])).to be_valid expect(build(validated_model_name, users: ['root'])).to be_valid