Fixed switch to deploying state for nodes which will not be deployed
Nodes can be exluded from deployment, if there is no tasks to run on this nodes. Such nodes should not be switched to deployment state. Change-Id: I4cd23769b7643aae7b149ba30e5b0e91a3021563
This commit is contained in:
parent
e2c008418d
commit
dc8fd092d3
|
@ -464,3 +464,33 @@ class TestGetCurrentState(BaseUnitTest):
|
|||
}
|
||||
|
||||
self.assertEqual(expected_state, current_state)
|
||||
|
||||
|
||||
class TestPrepareNodes(BaseUnitTest):
|
||||
def test_apply_only_for_involved_nodes(self):
|
||||
nodes = [
|
||||
mock.MagicMock(
|
||||
uid=1, progress=0, error_type='deployment', error_msg='test'
|
||||
),
|
||||
mock.MagicMock(
|
||||
uid=2, progress=0, error_type='provision', error_msg='test2'
|
||||
),
|
||||
]
|
||||
manager._prepare_nodes(nodes, False, {2})
|
||||
self.assertEqual(0, nodes[0].progress)
|
||||
self.assertEqual('deployment', nodes[0].error_type)
|
||||
self.assertEqual('test', nodes[0].error_msg)
|
||||
self.assertEqual(1, nodes[1].progress)
|
||||
self.assertIsNone(nodes[1].error_type)
|
||||
self.assertIsNone(nodes[1].error_msg)
|
||||
|
||||
def test_not_reset_error_if_dry_run(self):
|
||||
nodes = [
|
||||
mock.MagicMock(
|
||||
uid=1, progress=0, error_type='deployment', error_msg='test'
|
||||
)
|
||||
]
|
||||
manager._prepare_nodes(nodes, True, {1})
|
||||
self.assertEqual(1, nodes[0].progress)
|
||||
self.assertEqual('deployment', nodes[0].error_type)
|
||||
self.assertEqual('test', nodes[0].error_msg)
|
||||
|
|
|
@ -350,13 +350,6 @@ class TransactionsManager(object):
|
|||
"execute graph %s on nodes %s",
|
||||
sub_transaction.graph_type, [n.id for n in nodes]
|
||||
)
|
||||
for node in nodes:
|
||||
# set progress to show that node is in progress state
|
||||
node.progress = 1
|
||||
if not sub_transaction.dry_run:
|
||||
node.error_type = None
|
||||
node.error_msg = None
|
||||
|
||||
# we should initialize primary roles for cluster before
|
||||
# role resolve has been created
|
||||
objects.Cluster.set_primary_tags(cluster, nodes)
|
||||
|
@ -374,6 +367,8 @@ class TransactionsManager(object):
|
|||
sub_transaction.cache.get('force')
|
||||
))
|
||||
|
||||
_prepare_nodes(nodes, sub_transaction.dry_run, context.new['nodes'])
|
||||
|
||||
# Attach desired state to the sub transaction, so when we continue
|
||||
# our top-level transaction, the new state will be calculated on
|
||||
# top of this.
|
||||
|
@ -567,6 +562,15 @@ def _dump_expected_state(transaction, state, tasks):
|
|||
db().flush()
|
||||
|
||||
|
||||
def _prepare_nodes(nodes, dry_run, involved_node_ids):
|
||||
for node in (node for node in nodes if node.uid in involved_node_ids):
|
||||
# set progress to show that node is in progress state
|
||||
node.progress = 1
|
||||
if not dry_run:
|
||||
node.error_type = None
|
||||
node.error_msg = None
|
||||
|
||||
|
||||
def _update_nodes(transaction, nodes_instances, nodes_params):
|
||||
allow_update = {
|
||||
'name',
|
||||
|
|
Loading…
Reference in New Issue