Added option 'debug' for graph execution

Also reworked legacy task manger to use this flag
instead of patch every deployment task

Change-Id: Ic4031b94ee359d414f1834a56b085ff12cc6b38f
Closes-Bug: 1618774
This commit is contained in:
Bulat Gaifullin 2016-08-31 16:18:45 +03:00
parent 8da188b68f
commit 400a430d7d
8 changed files with 49 additions and 21 deletions

View File

@ -100,6 +100,9 @@ GRAPH_EXECUTE_PARAMS_SCHEMA = {
},
"force": {
"type": "boolean"
},
"debug": {
"type": "boolean"
}
}
}

View File

@ -253,16 +253,6 @@ class DeploymentTask(BaseDeploymentTask):
deployment_tasks
)
# update all puppet tasks with puppet_debug value from settings
cluster_settings = objects.Cluster.get_editable_attributes(
task.cluster)
puppet_debug = cluster_settings['common']['puppet_debug']['value']
for deploy_task in deployment_tasks:
if deploy_task['type'] == consts.ORCHESTRATOR_TASK_TYPES.puppet:
logger.debug("Update puppet task: %s with debug=%s",
deploy_task['id'], puppet_debug)
deploy_task['parameters']['debug'] = puppet_debug
deployment_mode, message = cls.call_deployment_method(
task, tasks=deployment_tasks, nodes=nodes,
affected_nodes=affected_nodes, selected_task_ids=task_ids,
@ -286,6 +276,12 @@ class DeploymentTask(BaseDeploymentTask):
objects.Cluster.get_network_attributes(task.cluster)
)
# get puppet_debug attribute
cluster_settings = objects.Cluster.get_editable_attributes(
task.cluster)
if cluster_settings['common'].get('puppet_debug', {}).get('value'):
message['debug'] = True
rpc_message = make_astute_message(
task,
deployment_mode,

View File

@ -235,6 +235,7 @@ class TestHandlers(BaseIntegrationTest):
deployment_msg['args']['deployment_info'] = deployment_info
deployment_msg['args']['tasks_directory'] = {}
deployment_msg['args']['tasks_graph'] = {}
deployment_msg['args']['debug'] = True
provision_nodes = []
admin_net = objects.NetworkGroup.get_admin_network_group()
@ -384,7 +385,8 @@ class TestHandlers(BaseIntegrationTest):
'tasks_directory',
'tasks_graph',
'storage',
'glance'])
'glance',
'debug'])
@mock_rpc(pass_mock=True)
def test_neutron_deploy_cast_with_right_args_for_5_1_1(self, mocked_rpc):
@ -701,6 +703,7 @@ class TestHandlers(BaseIntegrationTest):
deployment_msg['args']['deployment_info'] = deployment_info
deployment_msg['args']['pre_deployment'] = []
deployment_msg['args']['post_deployment'] = []
deployment_msg['args']['debug'] = True
provision_nodes = []
admin_net = objects.NetworkGroup.get_admin_network_group()
@ -847,7 +850,8 @@ class TestHandlers(BaseIntegrationTest):
'priority',
'workloads_collector',
'storage',
'glance'])
'glance',
'debug'])
def check_pg_count(self, deployment_info):
pools = ['volumes', 'compute', 'backups', '.rgw',
@ -1207,6 +1211,7 @@ class TestHandlers(BaseIntegrationTest):
deployment_msg['args']['deployment_info'] = deployment_info
deployment_msg['args']['pre_deployment'] = []
deployment_msg['args']['post_deployment'] = []
deployment_msg['args']['debug'] = True
provision_nodes = []
admin_net = objects.NetworkGroup.get_admin_network_group()
@ -1354,7 +1359,8 @@ class TestHandlers(BaseIntegrationTest):
'workloads_collector',
'vms_conf',
'storage',
'glance'])
'glance',
'debug'])
@mock_rpc(pass_mock=True)
def test_deploy_and_remove_correct_nodes_and_statuses(self, mocked_rpc):

View File

@ -69,6 +69,9 @@ class TestGraphExecutorHandler(base.BaseIntegrationTest):
{
"cluster": self.cluster.id,
"graphs": [{"type": "test_graph"}],
"debug": True,
"noop_run": True,
"dry_run": True,
}
),
headers=self.default_headers
@ -94,8 +97,9 @@ class TestGraphExecutorHandler(base.BaseIntegrationTest):
]
},
'tasks_directory': {},
'dry_run': False,
'noop_run': False,
'dry_run': True,
'noop_run': True,
'debug': True
},
'respond_to': 'transaction_resp',
'method': 'task_deploy',

View File

@ -83,7 +83,7 @@ class TestTaskDeploy80(BaseIntegrationTest):
self.assertEqual("task_deploy", message["method"])
self.assertItemsEqual(
["task_uuid", "deployment_info",
"tasks_directory", "tasks_graph"],
"tasks_directory", "tasks_graph", "debug"],
message["args"]
)
@ -110,7 +110,7 @@ class TestTaskDeploy80(BaseIntegrationTest):
self.assertEqual("granular_deploy", message["method"])
self.assertItemsEqual(
["task_uuid", "deployment_info",
"pre_deployment", "post_deployment"],
"pre_deployment", "post_deployment", "debug"],
message["args"]
)
ensure_allowed.assert_called_once_with(mock.ANY)
@ -121,7 +121,7 @@ class TestTaskDeploy80(BaseIntegrationTest):
self.assertEqual("granular_deploy", message["method"])
self.assertItemsEqual(
["task_uuid", "deployment_info",
"pre_deployment", "post_deployment"],
"pre_deployment", "post_deployment", "debug"],
message["args"]
)

View File

@ -105,6 +105,7 @@ class TestTransactionManager(base.BaseIntegrationTest):
'tasks_directory': {},
'dry_run': False,
'noop_run': False,
'debug': False,
},
'respond_to': 'transaction_resp',
'method': 'task_deploy',
@ -165,6 +166,7 @@ class TestTransactionManager(base.BaseIntegrationTest):
'tasks_directory': {},
'dry_run': False,
'noop_run': False,
'debug': False
},
'respond_to': 'transaction_resp',
'method': 'task_deploy',
@ -195,6 +197,7 @@ class TestTransactionManager(base.BaseIntegrationTest):
'tasks_directory': {},
'dry_run': False,
'noop_run': False,
'debug': False
},
'respond_to': 'transaction_resp',
'method': 'task_deploy',
@ -255,6 +258,8 @@ class TestTransactionManager(base.BaseIntegrationTest):
'tasks_directory': {},
'dry_run': False,
'noop_run': False,
'debug': False
},
'respond_to': 'transaction_resp',
'method': 'task_deploy',
@ -297,6 +302,8 @@ class TestTransactionManager(base.BaseIntegrationTest):
'tasks_directory': {},
'dry_run': False,
'noop_run': False,
'debug': False
},
'respond_to': 'transaction_resp',
'method': 'task_deploy',
@ -348,6 +355,7 @@ class TestTransactionManager(base.BaseIntegrationTest):
'tasks_directory': {},
'dry_run': False,
'noop_run': False,
'debug': False
},
'respond_to': 'transaction_resp',
'method': 'task_deploy',
@ -386,6 +394,7 @@ class TestTransactionManager(base.BaseIntegrationTest):
'tasks_directory': {},
'dry_run': True,
'noop_run': False,
'debug': False
},
'respond_to': 'transaction_resp',
'method': 'task_deploy',
@ -426,6 +435,7 @@ class TestTransactionManager(base.BaseIntegrationTest):
'tasks_directory': {},
'dry_run': False,
'noop_run': True,
'debug': False
},
'respond_to': 'transaction_resp',
'method': 'task_deploy',
@ -491,6 +501,7 @@ class TestTransactionManager(base.BaseIntegrationTest):
'tasks_directory': {},
'dry_run': False,
'noop_run': False,
'debug': False
},
'respond_to': 'transaction_resp',
'method': 'task_deploy',
@ -545,6 +556,7 @@ class TestTransactionManager(base.BaseIntegrationTest):
'tasks_directory': {},
'dry_run': False,
'noop_run': False,
'debug': False
},
'respond_to': 'transaction_resp',
'method': 'task_deploy',

View File

@ -31,8 +31,10 @@ class TestMakeAstuteMessage(BaseUnitTest):
def test_make_astute_message(self, lcm_mock, obj_mock):
resolver = mock.MagicMock()
context = mock.MagicMock()
tx = mock.MagicMock(dry_run=False, noop_run=False,
cache={'dry_run': False, 'noop_run': False})
tx = mock.MagicMock(
dry_run=False,
cache={'dry_run': False, 'noop_run': False, 'debug': False}
)
graph = {
'tasks': mock.MagicMock(),
'on_success': {'node_attributes': {}},
@ -63,6 +65,7 @@ class TestMakeAstuteMessage(BaseUnitTest):
'tasks_metadata': tasks_metadata,
'dry_run': False,
'noop_run': False,
'debug': False
}
},
result

View File

@ -74,6 +74,7 @@ def make_astute_message(transaction, context, graph, node_resolver):
'tasks_metadata': metadata,
'dry_run': transaction.cache.get('dry_run'),
'noop_run': transaction.cache.get('noop_run'),
'debug': transaction.cache.get('debug'),
}
}
@ -123,7 +124,8 @@ class TransactionsManager(object):
def __init__(self, cluster_id):
self.cluster_id = cluster_id
def execute(self, graphs, dry_run=False, noop_run=False, force=False):
def execute(self, graphs, dry_run=False, noop_run=False, force=False,
debug=False):
"""Start a new transaction with a given parameters.
Under the hood starting a new transaction means serialize a lot of
@ -135,6 +137,7 @@ class TransactionsManager(object):
:param dry_run: run a new transaction in dry run mode
:param noop_run: run a new transaction in noop run mode
:param force: re-evaluate tasks's conditions as it's a first run
:param debug: enable debug mode for tasks executor
"""
logger.debug(
'Start new transaction: '
@ -180,6 +183,7 @@ class TransactionsManager(object):
cache['force'] = force
cache['noop_run'] = noop_run
cache['dry_run'] = dry_run
cache['debug'] = debug
sub_transaction = transaction.create_subtask(
self.task_name,