From 496212798efa9f167de20a3ea0c2146658b2b466 Mon Sep 17 00:00:00 2001 From: "Vladimir Sharshov (warpc)" Date: Fri, 17 Mar 2017 20:48:52 +0300 Subject: [PATCH] Fix wrong ready status instead of stopped for stop deployment Report ready status for node means successful node status which can be get if all tasks was passed with ready and skipped statuses. Same effect can be get if Astute mark node as skipped. In this case we also get equal status 'successful'. So we need ask node about skipped statuses before ask it about successful status to prevent losing context about stop deployment operation. Change-Id: I3c042425cab800de0bfc4e03f29414b145f44983 Closes-Bug: #1672964 --- lib/astute/task_node.rb | 4 ++-- spec/unit/task_node_spec.rb | 21 +++++++++++++++++++++ 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/lib/astute/task_node.rb b/lib/astute/task_node.rb index e4b9e23b..796563f1 100644 --- a/lib/astute/task_node.rb +++ b/lib/astute/task_node.rb @@ -124,10 +124,10 @@ module Astute def node_report_status if !finished? {} - elsif successful? - cluster.node_statuses_transitions.fetch('successful', {}) elsif skipped? cluster.node_statuses_transitions.fetch('stopped', {}) + elsif successful? + cluster.node_statuses_transitions.fetch('successful', {}) else cluster.node_statuses_transitions.fetch('failed', {}) end diff --git a/spec/unit/task_node_spec.rb b/spec/unit/task_node_spec.rb index 6ee7383e..be0bc257 100644 --- a/spec/unit/task_node_spec.rb +++ b/spec/unit/task_node_spec.rb @@ -378,6 +378,27 @@ describe Astute::TaskNode do }) task_node.poll end + + it 'should report stopped if node skipped' do + cluster.node_statuses_transitions['stopped'] = { + 'status' => 'stopped' + } + cluster.node_statuses_transitions['successful'] = { + 'status' => 'ready' + } + + task_node.set_status_skipped + task_node.stubs(:finished?).returns(true) + task_node.stubs(:successful?).returns(true) + + ctx.expects(:report).with({ + 'nodes' => [{ + 'uid' => 'node_id', + 'status' => 'stopped', + 'progress' => 100}] + }) + task_node.report_node_status + end end it 'should report error if task failed and no more task' do