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
|
# 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[: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[:bootstrap_profile] = 'ubuntu_bootstrap' # use the Ubuntu based bootstrap by default
|
||||||
conf[:graph_dot_dir] = "/tmp/" # default dir patch for debug graph file
|
conf[:graph_dot_dir] = "/var/lib/astute/graphs" # default dir patch for debug graph file
|
||||||
conf[:enable_graph_file] = false # enable debug graph records to file
|
conf[:enable_graph_file] = true # enable debug graph records to file
|
||||||
|
|
||||||
# Server settings
|
# Server settings
|
||||||
conf[:broker_host] = 'localhost'
|
conf[:broker_host] = 'localhost'
|
||||||
|
|
|
@ -77,7 +77,8 @@ module Astute
|
||||||
deployment_engine.deploy(
|
deployment_engine.deploy(
|
||||||
deployment_info: deployment_options[:deployment_info],
|
deployment_info: deployment_options[:deployment_info],
|
||||||
tasks_graph: deployment_options[:tasks_graph],
|
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
|
ensure
|
||||||
Astute.logger.info "Deployment summary: time was spent " \
|
Astute.logger.info "Deployment summary: time was spent " \
|
||||||
|
|
|
@ -118,7 +118,8 @@ module Astute
|
||||||
{
|
{
|
||||||
:deployment_info => data['args'].fetch('deployment_info', []),
|
:deployment_info => data['args'].fetch('deployment_info', []),
|
||||||
:tasks_graph => data['args'].fetch('tasks_graph', {}),
|
: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
|
rescue Timeout::Error
|
||||||
|
|
|
@ -20,7 +20,7 @@ module Astute
|
||||||
@ctx = context
|
@ctx = context
|
||||||
end
|
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
|
raise DeploymentEngineError, "Deployment graph was not provided!" if
|
||||||
tasks_graph.blank?
|
tasks_graph.blank?
|
||||||
|
|
||||||
|
@ -46,7 +46,12 @@ module Astute
|
||||||
setup_task_concurrency(tasks_graph, cluster)
|
setup_task_concurrency(tasks_graph, cluster)
|
||||||
|
|
||||||
write_graph_to_file(cluster)
|
write_graph_to_file(cluster)
|
||||||
|
if dry_run
|
||||||
|
result = Hash.new
|
||||||
|
result[:success] = true
|
||||||
|
else
|
||||||
result = cluster.run
|
result = cluster.run
|
||||||
|
end
|
||||||
report_deploy_result(result)
|
report_deploy_result(result)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -65,7 +65,8 @@ describe Astute::Orchestrator do
|
||||||
Astute::TaskDeployment.any_instance.expects(:deploy).with(
|
Astute::TaskDeployment.any_instance.expects(:deploy).with(
|
||||||
:deployment_info => deployment_info,
|
:deployment_info => deployment_info,
|
||||||
:tasks_graph => tasks_graph,
|
:tasks_graph => tasks_graph,
|
||||||
:tasks_directory => tasks_directory
|
:tasks_directory => tasks_directory,
|
||||||
|
:dry_run => false
|
||||||
)
|
)
|
||||||
|
|
||||||
@orchestrator.task_deploy(
|
@orchestrator.task_deploy(
|
||||||
|
|
|
@ -250,6 +250,23 @@ describe Astute::TaskDeployment do
|
||||||
end
|
end
|
||||||
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
|
context 'config' do
|
||||||
around(:each) do |example|
|
around(:each) do |example|
|
||||||
max_nodes_old_value = Astute.config.max_nodes_per_call
|
max_nodes_old_value = Astute.config.max_nodes_per_call
|
||||||
|
@ -353,7 +370,7 @@ describe Astute::TaskDeployment do
|
||||||
|
|
||||||
file_handle = mock
|
file_handle = mock
|
||||||
file_handle.expects(:write).with(regexp_matches(/digraph/)).never
|
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
|
.yields(file_handle).never
|
||||||
|
|
||||||
task_deployment.deploy(
|
task_deployment.deploy(
|
||||||
|
@ -372,7 +389,7 @@ describe Astute::TaskDeployment do
|
||||||
|
|
||||||
file_handle = mock
|
file_handle = mock
|
||||||
file_handle.expects(:write).with(regexp_matches(/digraph/)).once
|
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
|
.yields(file_handle).once
|
||||||
|
|
||||||
task_deployment.deploy(
|
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')" -- \$@
|
ruby -r 'rubygems' -e "gem 'astute', '>= 0'; load Gem.bin_path('astute', 'astuted', '>= 0')" -- \$@
|
||||||
EOF
|
EOF
|
||||||
install -d -m 755 %{buildroot}%{_localstatedir}/log/astute
|
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}
|
install -D -m644 %{_builddir}/%{rbname}-%{version}/%{rbname}.sysconfig %{buildroot}/%{_sysconfdir}/sysconfig/%{rbname}
|
||||||
#nailgun-mcagents
|
#nailgun-mcagents
|
||||||
mkdir -p %{buildroot}/usr/libexec/mcollective/mcollective/agent/
|
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(0750, naily, naily) %{_sysconfdir}/%{rbname}
|
||||||
%dir %attr(0755, naily, naily) %{_localstatedir}/log/%{rbname}
|
%dir %attr(0755, naily, naily) %{_localstatedir}/log/%{rbname}
|
||||||
|
%dir /var/lib/astute
|
||||||
|
%dir /var/lib/astute/graphs
|
||||||
%config(noreplace) %{_bindir}/astuted
|
%config(noreplace) %{_bindir}/astuted
|
||||||
%config(noreplace) %{_sysconfdir}/sysconfig/%{rbname}
|
%config(noreplace) %{_sysconfdir}/sysconfig/%{rbname}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue