diff --git a/nailgun/nailgun/objects/cluster.py b/nailgun/nailgun/objects/cluster.py index 3c27786e92..17e3ca6353 100644 --- a/nailgun/nailgun/objects/cluster.py +++ b/nailgun/nailgun/objects/cluster.py @@ -841,6 +841,18 @@ class Cluster(NailgunObject): else: return False + @classmethod + def dpdk_enabled(cls, instance): + # Had to do this due to issues with modules imports in current + # nailgun __init__.py which cannot be resolved easily + from nailgun.objects import Node + + if Release.is_nfv_supported(instance.release): + for node in cls.get_nodes_not_for_deletion(instance): + if Node.dpdk_enabled(node): + return True + return False + @classmethod def get_roles(cls, instance): """Returns a dictionary of node roles available for deployment. diff --git a/nailgun/nailgun/task/task.py b/nailgun/nailgun/task/task.py index d722d9be0e..aff8603d7c 100644 --- a/nailgun/nailgun/task/task.py +++ b/nailgun/nailgun/task/task.py @@ -448,7 +448,7 @@ class ClusterTransaction(DeploymentTask): @classmethod def mark_skipped(cls, tasks, ids_not_to_skip): - """Change tasks type which ids not present in ids_not_to_skip to skipped + """Change tasks type which ids are not ids_not_to_skip to skipped :param tasks: the list of deployment tasks to execute :param ids_not_to_skip: the list of task ids that will be not skipped @@ -1526,7 +1526,8 @@ class CheckBeforeDeploymentTask(object): # TODO(asvechnikov): Make an appropriate versioning of tasks if objects.Release.is_nfv_supported(task.cluster.release): cls._check_sriov_properties(task) - cls._check_dpdk_properties(task) + if objects.Cluster.dpdk_enabled(task.cluster): + cls._check_dpdk_properties(task) if objects.Release.is_external_mongo_enabled(task.cluster.release): cls._check_mongo_nodes(task) @@ -1868,8 +1869,10 @@ class CheckBeforeDeploymentTask(object): @classmethod def _check_dpdk_properties(self, task): dpdk_enabled = False - for node in task.cluster.nodes: - if node.pending_deletion: + for node in objects.Cluster.get_nodes_not_for_deletion(task.cluster): + + if (not objects.NodeAttributes.is_cpu_pinning_enabled(node) and + not objects.Node.dpdk_enabled): continue try: diff --git a/nailgun/nailgun/test/integration/test_task_deploy.py b/nailgun/nailgun/test/integration/test_task_deploy.py index 2f29f318e7..9ef0220918 100644 --- a/nailgun/nailgun/test/integration/test_task_deploy.py +++ b/nailgun/nailgun/test/integration/test_task_deploy.py @@ -23,6 +23,7 @@ from nailgun import errors from nailgun import objects from nailgun.orchestrator.task_based_deployment import TaskProcessor from nailgun import rpc +from nailgun.task.task import CheckBeforeDeploymentTask from nailgun.test.base import BaseIntegrationTest from nailgun.test.base import fake_tasks from nailgun.test.base import mock_rpc @@ -411,7 +412,8 @@ class TestTaskDeploy90(BaseIntegrationTest): if task['type'] != consts.ORCHESTRATOR_TASK_TYPES.skipped) ) - def test_deploy_check_failed_with_dpdk_cpu_distribution(self): + @mock.patch('objects.Node.dpdk_enabled', return_value=True) + def test_deploy_check_failed_with_dpdk_cpu_distribution(self, _): node = self.env.nodes[0] objects.Node.update_attributes(node, { @@ -429,6 +431,17 @@ class TestTaskDeploy90(BaseIntegrationTest): task.message ) + @mock.patch('objects.Node.dpdk_enabled', return_value=False) + def test_deploy_disabled_dpdk_check_ok_without_numa_meta(self, _): + node = self.env.nodes[0] + + node.meta.pop('numa_topology', {}) + + task = models.Task(name=consts.TASK_NAMES.deployment, + cluster=self.cluster) + self.assertNotRaises( + errors.InvalidData, CheckBeforeDeploymentTask.execute, task) + class TestTaskDeploy90AfterDeployment(BaseIntegrationTest): def setUp(self):