summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJenkins <jenkins@review.openstack.org>2017-02-28 21:33:49 +0000
committerGerrit Code Review <review@openstack.org>2017-02-28 21:33:49 +0000
commitd72287f19e533b8f6bf4c5e6abdee9612bf4ea64 (patch)
tree72266ded38fea840ed7ef7cb8b806ef5b8ea54cd
parent9fc3e312dc15e0bfab9c3148f277a3b74b2496c7 (diff)
parentdc8fd092d3ac194fcd98888df42ce28de2b85e49 (diff)
Merge "Fixed switch to deploying state for nodes which will not be deployed"
-rw-r--r--nailgun/nailgun/test/unit/test_transactions_manager.py30
-rw-r--r--nailgun/nailgun/transactions/manager.py18
2 files changed, 41 insertions, 7 deletions
diff --git a/nailgun/nailgun/test/unit/test_transactions_manager.py b/nailgun/nailgun/test/unit/test_transactions_manager.py
index 5006b0c..f49b066 100644
--- a/nailgun/nailgun/test/unit/test_transactions_manager.py
+++ b/nailgun/nailgun/test/unit/test_transactions_manager.py
@@ -464,3 +464,33 @@ class TestGetCurrentState(BaseUnitTest):
464 } 464 }
465 465
466 self.assertEqual(expected_state, current_state) 466 self.assertEqual(expected_state, current_state)
467
468
469class TestPrepareNodes(BaseUnitTest):
470 def test_apply_only_for_involved_nodes(self):
471 nodes = [
472 mock.MagicMock(
473 uid=1, progress=0, error_type='deployment', error_msg='test'
474 ),
475 mock.MagicMock(
476 uid=2, progress=0, error_type='provision', error_msg='test2'
477 ),
478 ]
479 manager._prepare_nodes(nodes, False, {2})
480 self.assertEqual(0, nodes[0].progress)
481 self.assertEqual('deployment', nodes[0].error_type)
482 self.assertEqual('test', nodes[0].error_msg)
483 self.assertEqual(1, nodes[1].progress)
484 self.assertIsNone(nodes[1].error_type)
485 self.assertIsNone(nodes[1].error_msg)
486
487 def test_not_reset_error_if_dry_run(self):
488 nodes = [
489 mock.MagicMock(
490 uid=1, progress=0, error_type='deployment', error_msg='test'
491 )
492 ]
493 manager._prepare_nodes(nodes, True, {1})
494 self.assertEqual(1, nodes[0].progress)
495 self.assertEqual('deployment', nodes[0].error_type)
496 self.assertEqual('test', nodes[0].error_msg)
diff --git a/nailgun/nailgun/transactions/manager.py b/nailgun/nailgun/transactions/manager.py
index 7be79fd..0b2608a 100644
--- a/nailgun/nailgun/transactions/manager.py
+++ b/nailgun/nailgun/transactions/manager.py
@@ -350,13 +350,6 @@ class TransactionsManager(object):
350 "execute graph %s on nodes %s", 350 "execute graph %s on nodes %s",
351 sub_transaction.graph_type, [n.id for n in nodes] 351 sub_transaction.graph_type, [n.id for n in nodes]
352 ) 352 )
353 for node in nodes:
354 # set progress to show that node is in progress state
355 node.progress = 1
356 if not sub_transaction.dry_run:
357 node.error_type = None
358 node.error_msg = None
359
360 # we should initialize primary roles for cluster before 353 # we should initialize primary roles for cluster before
361 # role resolve has been created 354 # role resolve has been created
362 objects.Cluster.set_primary_tags(cluster, nodes) 355 objects.Cluster.set_primary_tags(cluster, nodes)
@@ -374,6 +367,8 @@ class TransactionsManager(object):
374 sub_transaction.cache.get('force') 367 sub_transaction.cache.get('force')
375 )) 368 ))
376 369
370 _prepare_nodes(nodes, sub_transaction.dry_run, context.new['nodes'])
371
377 # Attach desired state to the sub transaction, so when we continue 372 # Attach desired state to the sub transaction, so when we continue
378 # our top-level transaction, the new state will be calculated on 373 # our top-level transaction, the new state will be calculated on
379 # top of this. 374 # top of this.
@@ -567,6 +562,15 @@ def _dump_expected_state(transaction, state, tasks):
567 db().flush() 562 db().flush()
568 563
569 564
565def _prepare_nodes(nodes, dry_run, involved_node_ids):
566 for node in (node for node in nodes if node.uid in involved_node_ids):
567 # set progress to show that node is in progress state
568 node.progress = 1
569 if not dry_run:
570 node.error_type = None
571 node.error_msg = None
572
573
570def _update_nodes(transaction, nodes_instances, nodes_params): 574def _update_nodes(transaction, nodes_instances, nodes_params):
571 allow_update = { 575 allow_update = {
572 'name', 576 'name',