summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBulat Gaifullin <gaifullinbf@gmail.com>2017-01-23 18:21:50 +0300
committerBulat Gaifullin <gaifullinbf@gmail.com>2017-02-08 13:20:22 +0000
commitdc8fd092d3ac194fcd98888df42ce28de2b85e49 (patch)
tree5c25256fb96daa3464d7057d570dd9a937216b37
parente2c008418de90f5feeae0515cbf27ab238395ae8 (diff)
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
Notes
Notes (review): Verified+1: Fuel CI <fuel-ci-bot@mirantis.com> Code-Review+1: Georgy Kibardin <gkibardin@mirantis.com> Code-Review+1: Alexander Kislitsky <akislitsky@mirantis.com> Code-Review+2: Ilya Kutukov <post.ilya@gmail.com> Workflow+1: Bulat Gaifullin <gaifullinbf@gmail.com> Verified+2: Jenkins Submitted-by: Jenkins Submitted-at: Tue, 28 Feb 2017 21:33:49 +0000 Reviewed-on: https://review.openstack.org/424192 Project: openstack/fuel-web Branch: refs/heads/master
-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',