Support custom puppet debug mode
Instead of always using puppet debug, now user can chosen. Change-Id: I78fd8474863882b7dba2939b133cd90a78607324 Closes-Bug: #1433092
This commit is contained in:
parent
2d61ee42ec
commit
f08203ff93
|
@ -29,6 +29,7 @@ class Astute::DeploymentEngine::GranularDeployment < Astute::DeploymentEngine
|
|||
@running_tasks = {}
|
||||
@nodes_roles = nodes.inject({}) { |h, n| h.merge({n['uid'] => n['role']}) }
|
||||
@nodes_by_uid = nodes.inject({}) { |h, n| h.merge({ n['uid'] => n }) }
|
||||
@puppet_debug = nodes.first['puppet_debug']
|
||||
|
||||
begin
|
||||
@task_manager = Astute::TaskManager.new(nodes)
|
||||
|
@ -67,7 +68,8 @@ class Astute::DeploymentEngine::GranularDeployment < Astute::DeploymentEngine
|
|||
task['parameters']['puppet_manifest'],
|
||||
task['parameters']['puppet_modules'],
|
||||
task['parameters']['cwd'],
|
||||
task['parameters']['timeout']
|
||||
task['parameters']['timeout'],
|
||||
@puppet_debug
|
||||
)
|
||||
end
|
||||
|
||||
|
|
|
@ -27,7 +27,15 @@ class Astute::DeploymentEngine::NailyFact < Astute::DeploymentEngine
|
|||
|
||||
Astute.logger.info "#{@ctx.task_id}: Starting deployment"
|
||||
|
||||
Astute::PuppetdDeployer.deploy(@ctx, nodes, retries)
|
||||
Astute::PuppetdDeployer.deploy(
|
||||
@ctx,
|
||||
nodes,
|
||||
retries,
|
||||
puppet_manifest=nil,
|
||||
puppet_modules=nil,
|
||||
cwd=nil,
|
||||
puppet_debug=nodes.first['puppet_debug']
|
||||
)
|
||||
nodes_roles = nodes.map { |n| {n['uid'] => n['role']} }
|
||||
Astute.logger.info "#{@ctx.task_id}: Finished deployment of nodes => roles: #{nodes_roles.inspect}"
|
||||
end
|
||||
|
|
|
@ -18,7 +18,7 @@ module Astute
|
|||
|
||||
class PuppetTask
|
||||
|
||||
def initialize(ctx, node, retries=1, puppet_manifest=nil, puppet_modules=nil, cwd=nil, timeout=nil)
|
||||
def initialize(ctx, node, retries=1, puppet_manifest=nil, puppet_modules=nil, cwd=nil, timeout=nil, puppet_debug=false)
|
||||
@ctx = ctx
|
||||
@node = node
|
||||
@retries = retries
|
||||
|
@ -28,6 +28,7 @@ module Astute
|
|||
@time_observer = TimeObserver.new(timeout || Astute.config.puppet_timeout)
|
||||
@prev_summary = nil
|
||||
@is_hung = false
|
||||
@puppet_debug = puppet_debug
|
||||
end
|
||||
|
||||
def run
|
||||
|
@ -91,7 +92,7 @@ module Astute
|
|||
|
||||
def puppet_run
|
||||
puppetd.runonce(
|
||||
:puppet_debug => true,
|
||||
:puppet_debug => @puppet_debug,
|
||||
:manifest => @puppet_manifest,
|
||||
:modules => @puppet_modules,
|
||||
:cwd => @cwd
|
||||
|
|
|
@ -19,13 +19,14 @@ require 'timeout'
|
|||
module Astute
|
||||
module PuppetdDeployer
|
||||
|
||||
def self.deploy(ctx, nodes, retries=2, puppet_manifest=nil, puppet_modules=nil, cwd=nil)
|
||||
def self.deploy(ctx, nodes, retries=2, puppet_manifest=nil, puppet_modules=nil, cwd=nil, puppet_debug=false)
|
||||
@ctx = ctx
|
||||
@retries = retries
|
||||
@nodes = nodes
|
||||
@puppet_manifest = puppet_manifest || '/etc/puppet/manifests/site.pp'
|
||||
@puppet_modules = puppet_modules || '/etc/puppet/modules'
|
||||
@cwd = cwd || '/'
|
||||
@puppet_debug = puppet_debug
|
||||
|
||||
Astute.logger.debug "Waiting for puppet to finish deployment on all
|
||||
nodes (timeout = #{Astute.config.puppet_timeout} sec)..."
|
||||
|
@ -50,7 +51,7 @@ module Astute
|
|||
end
|
||||
|
||||
def self.puppet_task(n)
|
||||
PuppetTask.new(@ctx, n, @retries, @puppet_manifest, @puppet_modules, @cwd)
|
||||
PuppetTask.new(@ctx, n, @retries, @puppet_manifest, @puppet_modules, @cwd, @puppet_debug)
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
@ -17,8 +17,9 @@ module Fixtures
|
|||
|
||||
def self.common_attrs(deployment_mode, nodes)
|
||||
nodes.each do |node|
|
||||
node.merge(
|
||||
node.merge!(
|
||||
"deployment_id" => 1,
|
||||
"puppet_debug" => true,
|
||||
"storage_network_range" => "172.16.0.0/24",
|
||||
"auto_assign_floating_ip" => false,
|
||||
"mysql" => {
|
||||
|
@ -51,7 +52,7 @@ module Fixtures
|
|||
)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
def self.controller_nodes(nodes)
|
||||
controller_nodes = nodes.select{ |n| n['role'] == 'controller' }.map { |e| deep_copy e }
|
||||
end
|
||||
|
|
|
@ -17,7 +17,7 @@ module Fixtures
|
|||
deploy_info = Fixtures.common_attrs('ha', Fixtures.ha_nodes)
|
||||
deploy_info.each do |node|
|
||||
node.merge(
|
||||
'management_vip' => "192.168.0.111"
|
||||
'management_vip' => "192.168.0.111"
|
||||
)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -58,11 +58,25 @@ describe "NailyFact DeploymentEngine" do
|
|||
|
||||
context 'log parsing' do
|
||||
let(:deploy_data) do
|
||||
[{'uid' => 1, 'role' => 'controller', 'deployment_mode' => 'unknown', 'deployment_id' => '123'}]
|
||||
[{
|
||||
'uid' => 1,
|
||||
'role' => 'controller',
|
||||
'deployment_mode' => 'unknown',
|
||||
'deployment_id' => '123',
|
||||
'puppet_debug' => true
|
||||
}]
|
||||
end
|
||||
|
||||
it "it should not raise an exception if deployment mode is unknown" do
|
||||
Astute::PuppetdDeployer.stubs(:deploy).with(ctx, deploy_data, instance_of(Fixnum)).once
|
||||
Astute::PuppetdDeployer.stubs(:deploy).with(
|
||||
ctx,
|
||||
deploy_data,
|
||||
instance_of(Fixnum),
|
||||
nil,
|
||||
nil,
|
||||
nil,
|
||||
true
|
||||
).once
|
||||
expect {deploy_engine.deploy(deploy_data)}.to_not raise_exception
|
||||
end
|
||||
end
|
||||
|
@ -74,8 +88,24 @@ describe "NailyFact DeploymentEngine" do
|
|||
|
||||
it "should not raise any exception" do
|
||||
# we got two calls, one for controller (high priority), and another for all computes (same low priority)
|
||||
Astute::PuppetdDeployer.expects(:deploy).with(ctx, controller_nodes, instance_of(Fixnum)).once
|
||||
Astute::PuppetdDeployer.expects(:deploy).with(ctx, compute_nodes, instance_of(Fixnum)).once
|
||||
Astute::PuppetdDeployer.expects(:deploy).with(
|
||||
ctx,
|
||||
controller_nodes,
|
||||
instance_of(Fixnum),
|
||||
nil,
|
||||
nil,
|
||||
nil,
|
||||
true
|
||||
).once
|
||||
Astute::PuppetdDeployer.expects(:deploy).with(
|
||||
ctx,
|
||||
compute_nodes,
|
||||
instance_of(Fixnum),
|
||||
nil,
|
||||
nil,
|
||||
nil,
|
||||
true
|
||||
).once
|
||||
|
||||
expect {deploy_engine.deploy(deploy_data)}.to_not raise_exception
|
||||
end
|
||||
|
@ -118,12 +148,36 @@ describe "NailyFact DeploymentEngine" do
|
|||
|
||||
it "ha deploy should not raise any exception" do
|
||||
primary_controller = deploy_data.find { |n| n['role'] == 'primary-controller' }
|
||||
Astute::PuppetdDeployer.expects(:deploy).with(ctx, [primary_controller], 1).once
|
||||
Astute::PuppetdDeployer.expects(:deploy).with(
|
||||
ctx,
|
||||
[primary_controller],
|
||||
1,
|
||||
nil,
|
||||
nil,
|
||||
nil,
|
||||
true
|
||||
).once
|
||||
|
||||
controller_nodes.each do |n|
|
||||
Astute::PuppetdDeployer.expects(:deploy).with(ctx, [n], 1).once
|
||||
Astute::PuppetdDeployer.expects(:deploy).with(
|
||||
ctx,
|
||||
[n],
|
||||
1,
|
||||
nil,
|
||||
nil,
|
||||
nil,
|
||||
true
|
||||
).once
|
||||
end
|
||||
Astute::PuppetdDeployer.expects(:deploy).with(ctx, compute_nodes, instance_of(Fixnum)).once
|
||||
Astute::PuppetdDeployer.expects(:deploy).with(
|
||||
ctx,
|
||||
compute_nodes,
|
||||
instance_of(Fixnum),
|
||||
nil,
|
||||
nil,
|
||||
nil,
|
||||
true
|
||||
).once
|
||||
|
||||
deploy_engine.deploy(deploy_data)
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue