diff --git a/magnum/drivers/mesos_ubuntu_v1/template_def.py b/magnum/drivers/mesos_ubuntu_v1/template_def.py index 533e3fe839..5858af122e 100644 --- a/magnum/drivers/mesos_ubuntu_v1/template_def.py +++ b/magnum/drivers/mesos_ubuntu_v1/template_def.py @@ -13,8 +13,11 @@ # under the License. import os +import magnum.conf from magnum.drivers.heat import template_def +CONF = magnum.conf.CONF + class UbuntuMesosTemplateDefinition(template_def.BaseTemplateDefinition): """Mesos template for Ubuntu VM.""" @@ -61,6 +64,8 @@ class UbuntuMesosTemplateDefinition(template_def.BaseTemplateDefinition): extra_params['tenant_name'] = context.project_id extra_params['domain_name'] = context.domain_name extra_params['region_name'] = osc.cinder_region_name() + extra_params['nodes_affinity_policy'] = \ + CONF.cluster.nodes_affinity_policy label_list = ['rexray_preempt', 'mesos_slave_isolation', 'mesos_slave_image_providers', diff --git a/magnum/tests/unit/conductor/handlers/test_mesos_cluster_conductor.py b/magnum/tests/unit/conductor/handlers/test_mesos_cluster_conductor.py index 750938f22a..5bce564061 100644 --- a/magnum/tests/unit/conductor/handlers/test_mesos_cluster_conductor.py +++ b/magnum/tests/unit/conductor/handlers/test_mesos_cluster_conductor.py @@ -141,6 +141,7 @@ class TestClusterConductorWithMesos(base.TestCase): 'mesos_slave_image_providers': 'docker', 'verify_ca': True, 'openstack_ca': '', + 'nodes_affinity_policy': 'soft-anti-affinity' } self.assertEqual(expected, definition) self.assertEqual( @@ -198,6 +199,7 @@ class TestClusterConductorWithMesos(base.TestCase): 'verify_ca': True, 'slave_flavor': 'flavor_id', 'openstack_ca': '', + 'nodes_affinity_policy': 'soft-anti-affinity' } self.assertEqual(expected, definition) self.assertEqual( @@ -261,6 +263,7 @@ class TestClusterConductorWithMesos(base.TestCase): 'mesos_slave_image_providers': 'docker', 'verify_ca': True, 'openstack_ca': '', + 'nodes_affinity_policy': 'soft-anti-affinity' } self.assertEqual(expected, definition) self.assertEqual( @@ -328,6 +331,7 @@ class TestClusterConductorWithMesos(base.TestCase): 'mesos_slave_image_providers': 'docker', 'verify_ca': True, 'openstack_ca': '', + 'nodes_affinity_policy': 'soft-anti-affinity' } self.assertEqual(expected, definition) self.assertEqual( @@ -393,6 +397,7 @@ class TestClusterConductorWithMesos(base.TestCase): 'mesos_slave_image_providers': 'docker', 'verify_ca': True, 'openstack_ca': '', + 'nodes_affinity_policy': 'soft-anti-affinity' } self.assertEqual(expected, definition) self.assertEqual( diff --git a/magnum/tests/unit/drivers/test_template_definition.py b/magnum/tests/unit/drivers/test_template_definition.py index bdde0a517f..b06649175f 100644 --- a/magnum/tests/unit/drivers/test_template_definition.py +++ b/magnum/tests/unit/drivers/test_template_definition.py @@ -1747,10 +1747,15 @@ class UbuntuMesosTemplateDefinitionTestCase(base.TestCase): mesos_def = mesos_tdef.UbuntuMesosTemplateDefinition() + CONF.set_override('nodes_affinity_policy', + 'anti-affinity', + group='cluster') + mesos_def.get_params(mock_context, mock_cluster_template, mock_cluster) expected_kwargs = {'extra_params': { 'region_name': mock_osc.cinder_region_name.return_value, + 'nodes_affinity_policy': 'anti-affinity', 'auth_url': 'http://192.168.10.10:5000/v3', 'username': 'mesos_user', 'tenant_name': 'admin', diff --git a/releasenotes/notes/affinity-policy-for-mesos-template-def-82627eb231aa4d28.yaml b/releasenotes/notes/affinity-policy-for-mesos-template-def-82627eb231aa4d28.yaml new file mode 100644 index 0000000000..191c1f3f55 --- /dev/null +++ b/releasenotes/notes/affinity-policy-for-mesos-template-def-82627eb231aa4d28.yaml @@ -0,0 +1,7 @@ +--- +fixes: + - | + Fixes the problem with Mesos cluster creation where the + nodes_affinity_policy was not properly conveyed as it is required + in order to create the corresponding server group in Nova. + https://storyboard.openstack.org/#!/story/2005116