Add support for dry-run deployment without actual graph execution
This patch allows for astute to receive 'dry_run' option in deployment message and skip actual graph execution. This makes it easier for Fuel users to execut particular deployment and see the resulting expanded deployment graph. Change-Id: I28f216522fbeba9663d836b3d5a2f64c51133238 Partial-bug: #1569839
This commit is contained in:
parent
fe7286ad26
commit
94c96e3582
|
@ -101,8 +101,8 @@ module Astute
|
|||
# Please increase if nodes could not provisioning
|
||||
conf[:agent_nodiscover_file] = '/etc/nailgun-agent/nodiscover' # if this file in place, nailgun-agent will do nothing
|
||||
conf[:bootstrap_profile] = 'ubuntu_bootstrap' # use the Ubuntu based bootstrap by default
|
||||
conf[:graph_dot_dir] = "/tmp/" # default dir patch for debug graph file
|
||||
conf[:enable_graph_file] = false # enable debug graph records to file
|
||||
conf[:graph_dot_dir] = "/var/lib/astute/graphs" # default dir patch for debug graph file
|
||||
conf[:enable_graph_file] = true # enable debug graph records to file
|
||||
|
||||
# Server settings
|
||||
conf[:broker_host] = 'localhost'
|
||||
|
|
|
@ -77,7 +77,8 @@ module Astute
|
|||
deployment_engine.deploy(
|
||||
deployment_info: deployment_options[:deployment_info],
|
||||
tasks_graph: deployment_options[:tasks_graph],
|
||||
tasks_directory: deployment_options[:tasks_directory]
|
||||
tasks_directory: deployment_options[:tasks_directory],
|
||||
dry_run: deployment_options.fetch(:dry_run, false)
|
||||
)
|
||||
ensure
|
||||
Astute.logger.info "Deployment summary: time was spent " \
|
||||
|
|
|
@ -118,7 +118,8 @@ module Astute
|
|||
{
|
||||
:deployment_info => data['args'].fetch('deployment_info', []),
|
||||
:tasks_graph => data['args'].fetch('tasks_graph', {}),
|
||||
:tasks_directory => data['args'].fetch('tasks_directory', {})
|
||||
:tasks_directory => data['args'].fetch('tasks_directory', {}),
|
||||
:dry_run => data['args'].fetch('dry_run', false)
|
||||
}
|
||||
)
|
||||
rescue Timeout::Error
|
||||
|
|
|
@ -20,7 +20,7 @@ module Astute
|
|||
@ctx = context
|
||||
end
|
||||
|
||||
def deploy(tasks_graph: {}, tasks_directory: {} , deployment_info: [])
|
||||
def deploy(tasks_graph: {}, tasks_directory: {} , deployment_info: [], dry_run: false)
|
||||
raise DeploymentEngineError, "Deployment graph was not provided!" if
|
||||
tasks_graph.blank?
|
||||
|
||||
|
@ -46,7 +46,12 @@ module Astute
|
|||
setup_task_concurrency(tasks_graph, cluster)
|
||||
|
||||
write_graph_to_file(cluster)
|
||||
result = cluster.run
|
||||
if dry_run
|
||||
result = Hash.new
|
||||
result[:success] = true
|
||||
else
|
||||
result = cluster.run
|
||||
end
|
||||
report_deploy_result(result)
|
||||
end
|
||||
|
||||
|
|
|
@ -65,7 +65,8 @@ describe Astute::Orchestrator do
|
|||
Astute::TaskDeployment.any_instance.expects(:deploy).with(
|
||||
:deployment_info => deployment_info,
|
||||
:tasks_graph => tasks_graph,
|
||||
:tasks_directory => tasks_directory
|
||||
:tasks_directory => tasks_directory,
|
||||
:dry_run => false
|
||||
)
|
||||
|
||||
@orchestrator.task_deploy(
|
||||
|
|
|
@ -250,6 +250,23 @@ describe Astute::TaskDeployment do
|
|||
end
|
||||
end
|
||||
|
||||
context 'dry_run' do
|
||||
it 'should not run actual deployment if dry_run is set to True' do
|
||||
task_deployment.stubs(:remove_failed_nodes).returns([deployment_info, []])
|
||||
Astute::TaskPreDeploymentActions.any_instance.stubs(:process)
|
||||
task_deployment.stubs(:write_graph_to_file)
|
||||
ctx.stubs(:report)
|
||||
|
||||
Astute::TaskCluster.any_instance.expects(:run).never
|
||||
|
||||
task_deployment.deploy(
|
||||
deployment_info: deployment_info,
|
||||
tasks_graph: tasks_graph,
|
||||
tasks_directory: tasks_directory,
|
||||
dry_run: true)
|
||||
end
|
||||
end
|
||||
|
||||
context 'config' do
|
||||
around(:each) do |example|
|
||||
max_nodes_old_value = Astute.config.max_nodes_per_call
|
||||
|
@ -353,7 +370,7 @@ describe Astute::TaskDeployment do
|
|||
|
||||
file_handle = mock
|
||||
file_handle.expects(:write).with(regexp_matches(/digraph/)).never
|
||||
File.expects(:open).with("/tmp/graph-#{ctx.task_id}.dot", 'w')
|
||||
File.expects(:open).with("#{Astute.config.graph_dot_dir}/graph-#{ctx.task_id}.dot", 'w')
|
||||
.yields(file_handle).never
|
||||
|
||||
task_deployment.deploy(
|
||||
|
@ -372,7 +389,7 @@ describe Astute::TaskDeployment do
|
|||
|
||||
file_handle = mock
|
||||
file_handle.expects(:write).with(regexp_matches(/digraph/)).once
|
||||
File.expects(:open).with("/tmp/graph-#{ctx.task_id}.dot", 'w')
|
||||
File.expects(:open).with("#{Astute.config.graph_dot_dir}/graph-#{ctx.task_id}.dot", 'w')
|
||||
.yields(file_handle).once
|
||||
|
||||
task_deployment.deploy(
|
||||
|
|
|
@ -87,6 +87,8 @@ cat > %{buildroot}%{_bindir}/astuted <<EOF
|
|||
ruby -r 'rubygems' -e "gem 'astute', '>= 0'; load Gem.bin_path('astute', 'astuted', '>= 0')" -- \$@
|
||||
EOF
|
||||
install -d -m 755 %{buildroot}%{_localstatedir}/log/astute
|
||||
install -d -m 755 %{buildroot}/var/lib/astute
|
||||
install -d -m 755 %{buildroot}/var/lib/astute/graphs
|
||||
install -D -m644 %{_builddir}/%{rbname}-%{version}/%{rbname}.sysconfig %{buildroot}/%{_sysconfdir}/sysconfig/%{rbname}
|
||||
#nailgun-mcagents
|
||||
mkdir -p %{buildroot}/usr/libexec/mcollective/mcollective/agent/
|
||||
|
@ -108,6 +110,8 @@ install -D -m644 %{_builddir}/%{rbname}-%{version}/%{rbname}.service %{buildroot
|
|||
|
||||
%dir %attr(0750, naily, naily) %{_sysconfdir}/%{rbname}
|
||||
%dir %attr(0755, naily, naily) %{_localstatedir}/log/%{rbname}
|
||||
%dir /var/lib/astute
|
||||
%dir /var/lib/astute/graphs
|
||||
%config(noreplace) %{_bindir}/astuted
|
||||
%config(noreplace) %{_sysconfdir}/sysconfig/%{rbname}
|
||||
|
||||
|
|
Loading…
Reference in New Issue