Browse Source

Merge "Fix label fixed_network_cidr" into stable/ussuri

changes/62/744062/1
Zuul 4 days ago
committed by Gerrit Code Review
parent
commit
87976988cb
13 changed files with 113 additions and 37 deletions
  1. +2
    -2
      contrib/drivers/dcos_centos_v1/templates/dcoscluster.yaml
  2. +2
    -2
      contrib/drivers/k8s_opensuse_v1/templates/kubecluster.yaml
  3. +7
    -0
      doc/source/user/index.rst
  4. +11
    -1
      magnum/drivers/heat/k8s_template_def.py
  5. +2
    -2
      magnum/drivers/k8s_coreos_v1/templates/kubecluster.yaml
  6. +2
    -2
      magnum/drivers/k8s_fedora_atomic_v1/templates/kubecluster.yaml
  7. +2
    -2
      magnum/drivers/k8s_fedora_coreos_v1/templates/kubecluster.yaml
  8. +2
    -2
      magnum/drivers/mesos_ubuntu_v1/templates/mesoscluster.yaml
  9. +3
    -3
      magnum/drivers/swarm_fedora_atomic_v1/templates/cluster.yaml
  10. +3
    -3
      magnum/drivers/swarm_fedora_atomic_v2/templates/swarmcluster.yaml
  11. +50
    -11
      magnum/tests/unit/conductor/handlers/test_k8s_cluster_conductor.py
  12. +21
    -7
      magnum/tests/unit/drivers/test_template_definition.py
  13. +6
    -0
      releasenotes/notes/fix-label-fixed_network_cidr-95d6a2571b58a8fc.yaml

+ 2
- 2
contrib/drivers/dcos_centos_v1/templates/dcoscluster.yaml View File

@@ -66,7 +66,7 @@ parameters:
description: uuid/name of an existing subnet to use to provision machines
default: ""

fixed_network_cidr:
fixed_subnet_cidr:
type: string
description: network range for fixed ip network
default: 10.0.0.0/24
@@ -347,7 +347,7 @@ resources:
properties:
existing_network: {get_param: fixed_network}
existing_subnet: {get_param: fixed_subnet}
private_network_cidr: {get_param: fixed_network_cidr}
private_network_cidr: {get_param: fixed_subnet_cidr}
dns_nameserver: {get_param: dns_nameserver}
external_network: {get_param: external_network}



+ 2
- 2
contrib/drivers/k8s_opensuse_v1/templates/kubecluster.yaml View File

@@ -45,7 +45,7 @@ parameters:
description: how many kubernetes minions to spawn
default: 1

fixed_network_cidr:
fixed_subnet_cidr:
type: string
description: network range for fixed ip network
default: 10.0.0.0/24
@@ -328,7 +328,7 @@ resources:
fixed_subnet:
type: OS::Neutron::Subnet
properties:
cidr: {get_param: fixed_network_cidr}
cidr: {get_param: fixed_subnet_cidr}
network: {get_resource: fixed_network}
dns_nameservers:
- {get_param: dns_nameserver}


+ 7
- 0
doc/source/user/index.rst View File

@@ -483,6 +483,8 @@ the table are linked to more details elsewhere in the user guide.
+---------------------------------------+--------------------+---------------+
| `calico_ipv4pool_ipip`_ | see below | Off |
+---------------------------------------+--------------------+---------------+
| `fixed_subnet_cidr`_ | see below | "" |
+---------------------------------------+--------------------+---------------+

.. _cluster:

@@ -1634,6 +1636,11 @@ _`metrics_scraper_tag`
The version of metrics-scraper used by kubernetes dashboard.
Ussuri default: v1.0.4

_`fixed_subnet_cidr`
CIDR of the fixed subnet created by Magnum when a user has not
specified an existing fixed_subnet during cluster creation.
Ussuri default: 10.0.0.0/24

External load balancer for services
-----------------------------------



+ 11
- 1
magnum/drivers/heat/k8s_template_def.py View File

@@ -188,6 +188,10 @@ class K8sTemplateDefinition(template_def.BaseTemplateDefinition):
else:
extra_params['fixed_network_name'] = cluster.name

if cluster.labels.get('fixed_subnet_cidr'):
extra_params['fixed_subnet_cidr'] = cluster.labels.get(
'fixed_subnet_cidr')

# NOTE(brtknr): Convert fixed subnet name to UUID. If fixed_subnet
# is not specified in cluster template use 'private' as the default
# value, which is the same as the heat template default value.
@@ -195,6 +199,12 @@ class K8sTemplateDefinition(template_def.BaseTemplateDefinition):
subnet_id = neutron.get_fixed_subnet_id(context, fixed_subnet)
if subnet_id:
extra_params['fixed_subnet'] = subnet_id
# NOTE(flwang): If a fixed subnet is given, then the label
# fixed_subnet_cidr should be updated to reflect the correct
# setting.
extra_params['fixed_subnet_cidr'] = neutron.get_subnet(
context, subnet_id, "id", "cidr")

return extra_params

def get_params(self, context, cluster_template, cluster, **kwargs):
@@ -272,7 +282,7 @@ class K8sTemplateDefinition(template_def.BaseTemplateDefinition):

def _set_master_lb_allowed_cidrs(self, context, cluster, extra_params):
if extra_params.get("master_lb_allowed_cidrs"):
subnet_cidr = (cluster.labels.get("fixed_network_cidr") or
subnet_cidr = (cluster.labels.get("fixed_subnet_cidr") or
"10.0.0.0/24")
if extra_params.get("fixed_subnet"):
subnet_cidr = neutron.get_subnet(context,


+ 2
- 2
magnum/drivers/k8s_coreos_v1/templates/kubecluster.yaml View File

@@ -104,7 +104,7 @@ parameters:
description: how many kubernetes minions to spawn
default: 1

fixed_network_cidr:
fixed_subnet_cidr:
type: string
description: network range for fixed ip network
default: 10.0.0.0/24
@@ -540,7 +540,7 @@ resources:
properties:
existing_network: {get_param: fixed_network}
existing_subnet: {get_param: fixed_subnet}
private_network_cidr: {get_param: fixed_network_cidr}
private_network_cidr: {get_param: fixed_subnet_cidr}
dns_nameserver: {get_param: dns_nameserver}
external_network: {get_param: external_network}
private_network_name: private


+ 2
- 2
magnum/drivers/k8s_fedora_atomic_v1/templates/kubecluster.yaml View File

@@ -170,7 +170,7 @@ parameters:
description: how many kubernetes minions to spawn
default: 1

fixed_network_cidr:
fixed_subnet_cidr:
type: string
description: network range for fixed ip network
default: 10.0.0.0/24
@@ -936,7 +936,7 @@ resources:
properties:
existing_network: {get_param: fixed_network}
existing_subnet: {get_param: fixed_subnet}
private_network_cidr: {get_param: fixed_network_cidr}
private_network_cidr: {get_param: fixed_subnet_cidr}
dns_nameserver: {get_param: dns_nameserver}
external_network: {get_param: external_network}
private_network_name: {get_param: fixed_network_name}


+ 2
- 2
magnum/drivers/k8s_fedora_coreos_v1/templates/kubecluster.yaml View File

@@ -170,7 +170,7 @@ parameters:
description: how many kubernetes minions to spawn
default: 1

fixed_network_cidr:
fixed_subnet_cidr:
type: string
description: network range for fixed ip network
default: 10.0.0.0/24
@@ -959,7 +959,7 @@ resources:
properties:
existing_network: {get_param: fixed_network}
existing_subnet: {get_param: fixed_subnet}
private_network_cidr: {get_param: fixed_network_cidr}
private_network_cidr: {get_param: fixed_subnet_cidr}
dns_nameserver: {get_param: dns_nameserver}
external_network: {get_param: external_network}
private_network_name: {get_param: fixed_network_name}


+ 2
- 2
magnum/drivers/mesos_ubuntu_v1/templates/mesoscluster.yaml View File

@@ -67,7 +67,7 @@ parameters:
description: how many mesos slaves to spawn initially
default: 1

fixed_network_cidr:
fixed_subnet_cidr:
type: string
description: network range for fixed ip network
default: 10.0.0.0/24
@@ -251,7 +251,7 @@ resources:
properties:
existing_network: {get_param: fixed_network}
existing_subnet: {get_param: fixed_subnet}
private_network_cidr: {get_param: fixed_network_cidr}
private_network_cidr: {get_param: fixed_subnet_cidr}
dns_nameserver: {get_param: dns_nameserver}
external_network: {get_param: external_network}



+ 3
- 3
magnum/drivers/swarm_fedora_atomic_v1/templates/cluster.yaml View File

@@ -103,7 +103,7 @@ parameters:
description: how many swarm nodes to spawn
default: 1

fixed_network_cidr:
fixed_subnet_cidr:
type: string
description: network range for fixed ip network
default: "10.0.0.0/24"
@@ -291,7 +291,7 @@ resources:
properties:
existing_network: {get_param: fixed_network}
existing_subnet: {get_param: fixed_subnet}
private_network_cidr: {get_param: fixed_network_cidr}
private_network_cidr: {get_param: fixed_subnet_cidr}
dns_nameserver: {get_param: dns_nameserver}
external_network: {get_param: external_network}

@@ -328,7 +328,7 @@ resources:
port_range_min: 2376
port_range_max: 2376
- protocol: tcp
remote_ip_prefix: {get_param: fixed_network_cidr}
remote_ip_prefix: {get_param: fixed_subnet_cidr}
port_range_min: 1
port_range_max: 65535
- protocol: udp


+ 3
- 3
magnum/drivers/swarm_fedora_atomic_v2/templates/swarmcluster.yaml View File

@@ -102,7 +102,7 @@ parameters:
type: number
description: how many secondary masters to spawn

fixed_network_cidr:
fixed_subnet_cidr:
type: string
description: network range for fixed ip network
default: "10.0.0.0/24"
@@ -228,7 +228,7 @@ resources:
properties:
existing_network: {get_param: fixed_network}
existing_subnet: {get_param: fixed_subnet}
private_network_cidr: {get_param: fixed_network_cidr}
private_network_cidr: {get_param: fixed_subnet_cidr}
dns_nameserver: {get_param: dns_nameserver}
external_network: {get_param: external_network}

@@ -261,7 +261,7 @@ resources:
port_range_min: 2377
port_range_max: 2377
- protocol: tcp
remote_ip_prefix: {get_param: fixed_network_cidr}
remote_ip_prefix: {get_param: fixed_subnet_cidr}
port_range_min: 1
port_range_max: 65535
- protocol: udp


+ 50
- 11
magnum/tests/unit/conductor/handlers/test_k8s_cluster_conductor.py View File

@@ -187,7 +187,9 @@ class TestClusterConductorWithK8s(base.TestCase):
'lvmdriver-1', group='cinder')
CONF.set_override('default_etcd_volume_type',
'lvmdriver-1', group='cinder')
self.fixed_subnet_cidr = '20.200.0.0/16'

@patch('magnum.common.neutron.get_subnet')
@patch('requests.get')
@patch('magnum.objects.ClusterTemplate.get_by_uuid')
@patch('magnum.objects.NodeGroup.list')
@@ -202,11 +204,12 @@ class TestClusterConductorWithK8s(base.TestCase):
mock_driver,
mock_objects_nodegroup_list,
mock_objects_cluster_template_get_by_uuid,
mock_get):
mock_get,
mock_get_subnet):
self._test_extract_template_definition(
mock_generate_csr_and_key, mock_sign_node_certificate,
mock_driver, mock_objects_cluster_template_get_by_uuid, mock_get,
mock_objects_nodegroup_list)
mock_objects_nodegroup_list, mock_get_subnet)

def _test_extract_template_definition(
self,
@@ -216,6 +219,7 @@ class TestClusterConductorWithK8s(base.TestCase):
mock_objects_cluster_template_get_by_uuid,
mock_get,
mock_objects_nodegroup_list,
mock_get_subnet,
missing_attr=None):
if missing_attr in self.cluster_template_dict:
self.cluster_template_dict[missing_attr] = None
@@ -244,6 +248,8 @@ class TestClusterConductorWithK8s(base.TestCase):
mock_objects_nodegroup_list.return_value = [master_ng, worker_ng]
mock_driver.return_value = k8s_dr.Driver()

mock_get_subnet.return_value = self.fixed_subnet_cidr

(template_path,
definition,
env_files) = mock_driver()._extract_template_definition(self.context,
@@ -375,6 +381,7 @@ class TestClusterConductorWithK8s(base.TestCase):
'worker_nodegroup_name': 'worker_ng',
'post_install_manifest_url': '',
'master_lb_allowed_cidrs': None,
'fixed_subnet_cidr': self.fixed_subnet_cidr,
}

if missing_attr is not None:
@@ -398,6 +405,7 @@ class TestClusterConductorWithK8s(base.TestCase):
],
env_files)

@patch('magnum.common.neutron.get_subnet')
@patch('requests.get')
@patch('magnum.objects.ClusterTemplate.get_by_uuid')
@patch('magnum.objects.NodeGroup.list')
@@ -412,7 +420,8 @@ class TestClusterConductorWithK8s(base.TestCase):
mock_driver,
mock_objects_nodegroup_list,
mock_objects_cluster_template_get_by_uuid,
mock_get):
mock_get,
mock_get_subnet):
self.cluster_template_dict['registry_enabled'] = True
cluster_template = objects.ClusterTemplate(
self.context, **self.cluster_template_dict)
@@ -432,6 +441,7 @@ class TestClusterConductorWithK8s(base.TestCase):
master_ng = objects.NodeGroup(self.context, **self.master_ng_dict)
mock_objects_nodegroup_list.return_value = [master_ng, worker_ng]
mock_driver.return_value = k8s_dr.Driver()
mock_get_subnet.return_value = self.fixed_subnet_cidr

CONF.set_override('swift_region',
'RegionOne',
@@ -528,6 +538,7 @@ class TestClusterConductorWithK8s(base.TestCase):
'worker_nodegroup_name': 'worker_ng',
'post_install_manifest_url': '',
'master_lb_allowed_cidrs': None,
'fixed_subnet_cidr': self.fixed_subnet_cidr
}

self.assertEqual(expected, definition)
@@ -541,6 +552,7 @@ class TestClusterConductorWithK8s(base.TestCase):
],
env_files)

@patch('magnum.common.neutron.get_subnet')
@patch('requests.get')
@patch('magnum.objects.ClusterTemplate.get_by_uuid')
@patch('magnum.objects.NodeGroup.list')
@@ -555,7 +567,8 @@ class TestClusterConductorWithK8s(base.TestCase):
mock_driver,
mock_objects_nodegroup_list,
mock_objects_cluster_template_get_by_uuid,
mock_get):
mock_get,
mock_get_subnet):

not_required = ['image_id', 'flavor_id', 'dns_nameserver',
'docker_volume_size', 'http_proxy',
@@ -587,6 +600,7 @@ class TestClusterConductorWithK8s(base.TestCase):
master_ng = objects.NodeGroup(self.context, **self.master_ng_dict)
master_ng.image_id = None
mock_objects_nodegroup_list.return_value = [master_ng, worker_ng]
mock_get_subnet.return_value = self.fixed_subnet_cidr

(template_path,
definition,
@@ -662,6 +676,7 @@ class TestClusterConductorWithK8s(base.TestCase):
'worker_nodegroup_name': 'worker_ng',
'post_install_manifest_url': '',
'master_lb_allowed_cidrs': None,
'fixed_subnet_cidr': self.fixed_subnet_cidr
}
self.assertEqual(expected, definition)
self.assertEqual(
@@ -674,6 +689,7 @@ class TestClusterConductorWithK8s(base.TestCase):
],
env_files)

@patch('magnum.common.neutron.get_subnet')
@patch('requests.get')
@patch('magnum.objects.ClusterTemplate.get_by_uuid')
@patch('magnum.objects.NodeGroup.list')
@@ -683,7 +699,8 @@ class TestClusterConductorWithK8s(base.TestCase):
mock_driver,
mock_objects_nodegroup_list,
mock_objects_cluster_template_get_by_uuid,
mock_get):
mock_get,
mock_get_subnet):
self.cluster_template_dict['cluster_distro'] = 'coreos'
cluster_template = objects.ClusterTemplate(
self.context, **self.cluster_template_dict)
@@ -700,6 +717,7 @@ class TestClusterConductorWithK8s(base.TestCase):
master_ng = objects.NodeGroup(self.context, **self.master_ng_dict)
mock_objects_nodegroup_list.return_value = [master_ng, worker_ng]
mock_driver.return_value = k8s_coreos_dr.Driver()
mock_get_subnet.return_value = self.fixed_subnet_cidr

(template_path,
definition,
@@ -775,6 +793,7 @@ class TestClusterConductorWithK8s(base.TestCase):
'master_nodegroup_name': 'master_ng',
'worker_nodegroup_name': 'worker_ng',
'master_lb_allowed_cidrs': None,
'fixed_subnet_cidr': self.fixed_subnet_cidr,
}
self.assertEqual(expected, definition)
self.assertEqual(
@@ -787,6 +806,7 @@ class TestClusterConductorWithK8s(base.TestCase):
],
env_files)

@patch('magnum.common.neutron.get_subnet')
@patch('requests.get')
@patch('magnum.objects.ClusterTemplate.get_by_uuid')
@patch('magnum.objects.NodeGroup.list')
@@ -796,7 +816,8 @@ class TestClusterConductorWithK8s(base.TestCase):
mock_driver,
mock_objects_nodegroup_list,
mock_objects_cluster_template_get_by_uuid,
reqget):
reqget,
mock_get_subnet):
self.cluster_template_dict['cluster_distro'] = 'coreos'
self.cluster_dict['discovery_url'] = None
mock_req = mock.MagicMock(text='http://tokentest/h1/h2/h3',
@@ -811,6 +832,7 @@ class TestClusterConductorWithK8s(base.TestCase):
master_ng = objects.NodeGroup(self.context, **self.master_ng_dict)
mock_objects_nodegroup_list.return_value = [master_ng, worker_ng]
mock_driver.return_value = k8s_coreos_dr.Driver()
mock_get_subnet.return_value = self.fixed_subnet_cidr

(template_path,
definition,
@@ -886,6 +908,7 @@ class TestClusterConductorWithK8s(base.TestCase):
'master_nodegroup_name': 'master_ng',
'worker_nodegroup_name': 'worker_ng',
'master_lb_allowed_cidrs': None,
'fixed_subnet_cidr': self.fixed_subnet_cidr,
}
self.assertEqual(expected, definition)
self.assertEqual(
@@ -898,6 +921,7 @@ class TestClusterConductorWithK8s(base.TestCase):
],
env_files)

@patch('magnum.common.neutron.get_subnet')
@patch('requests.get')
@patch('magnum.objects.ClusterTemplate.get_by_uuid')
@patch('magnum.objects.NodeGroup.list')
@@ -912,7 +936,8 @@ class TestClusterConductorWithK8s(base.TestCase):
mock_driver,
mock_objects_nodegroup_list,
mock_objects_cluster_template_get_by_uuid,
mock_get):
mock_get,
mock_get_subnet):
mock_driver.return_value = k8s_dr.Driver()
self._test_extract_template_definition(
mock_generate_csr_and_key,
@@ -921,8 +946,10 @@ class TestClusterConductorWithK8s(base.TestCase):
mock_objects_cluster_template_get_by_uuid,
mock_get,
mock_objects_nodegroup_list,
mock_get_subnet,
missing_attr='dns_nameserver')

@patch('magnum.common.neutron.get_subnet')
@patch('requests.get')
@patch('magnum.objects.ClusterTemplate.get_by_uuid')
@patch('magnum.objects.NodeGroup.list')
@@ -937,7 +964,8 @@ class TestClusterConductorWithK8s(base.TestCase):
mock_driver,
mock_objects_nodegroup_list,
mock_objects_cluster_template_get_by_uuid,
mock_get):
mock_get,
mock_get_subnet):
mock_driver.return_value = k8s_dr.Driver()
self._test_extract_template_definition(
mock_generate_csr_and_key,
@@ -946,8 +974,10 @@ class TestClusterConductorWithK8s(base.TestCase):
mock_objects_cluster_template_get_by_uuid,
mock_get,
mock_objects_nodegroup_list,
mock_get_subnet,
missing_attr='image_id')

@patch('magnum.common.neutron.get_subnet')
@patch('requests.get')
@patch('magnum.objects.ClusterTemplate.get_by_uuid')
@patch('magnum.objects.NodeGroup.list')
@@ -962,7 +992,8 @@ class TestClusterConductorWithK8s(base.TestCase):
mock_driver,
mock_objects_nodegroup_list,
mock_objects_cluster_template_get_by_uuid,
mock_get):
mock_get,
mock_get_subnet):
mock_driver.return_value = k8s_dr.Driver()
self._test_extract_template_definition(
mock_generate_csr_and_key,
@@ -971,8 +1002,10 @@ class TestClusterConductorWithK8s(base.TestCase):
mock_objects_cluster_template_get_by_uuid,
mock_get,
mock_objects_nodegroup_list,
mock_get_subnet,
missing_attr='docker_storage_driver')

@patch('magnum.common.neutron.get_subnet')
@patch('requests.get')
@patch('magnum.objects.ClusterTemplate.get_by_uuid')
@patch('magnum.objects.NodeGroup.list')
@@ -987,7 +1020,8 @@ class TestClusterConductorWithK8s(base.TestCase):
mock_driver,
mock_objects_nodegroup_list,
mock_objects_cluster_template_get_by_uuid,
mock_get):
mock_get,
mock_get_subnet):
mock_driver.return_value = k8s_dr.Driver()
self._test_extract_template_definition(
mock_generate_csr_and_key,
@@ -996,8 +1030,10 @@ class TestClusterConductorWithK8s(base.TestCase):
mock_objects_cluster_template_get_by_uuid,
mock_get,
mock_objects_nodegroup_list,
mock_get_subnet,
missing_attr='apiserver_port')

@patch('magnum.common.neutron.get_subnet')
@patch('requests.get')
@patch('magnum.objects.ClusterTemplate.get_by_uuid')
@patch('magnum.objects.NodeGroup.list')
@@ -1012,7 +1048,8 @@ class TestClusterConductorWithK8s(base.TestCase):
mock_driver,
mock_objects_nodegroup_list,
mock_objects_cluster_template_get_by_uuid,
reqget):
reqget,
mock_get_subnet):
cluster_template = objects.ClusterTemplate(
self.context, **self.cluster_template_dict)
mock_generate_csr_and_key.return_value = {'csr': 'csr',
@@ -1035,6 +1072,7 @@ class TestClusterConductorWithK8s(base.TestCase):
mock_req = mock.MagicMock(text='https://address/token',
status_code=200)
reqget.return_value = mock_req
mock_get_subnet.return_value = self.fixed_subnet_cidr

(template_path,
definition,
@@ -1121,6 +1159,7 @@ class TestClusterConductorWithK8s(base.TestCase):
'worker_nodegroup_name': 'worker_ng',
'post_install_manifest_url': '',
'master_lb_allowed_cidrs': None,
'fixed_subnet_cidr': self.fixed_subnet_cidr,
}
self.assertEqual(expected, definition)
self.assertEqual(


+ 21
- 7
magnum/tests/unit/drivers/test_template_definition.py View File

@@ -388,6 +388,7 @@ class AtomicK8sTemplateDefinitionTestCase(BaseK8sTemplateDefinitionTestCase):
}
self.assertEqual(scale_params, expected_scale_params)

@mock.patch('magnum.common.neutron.get_subnet')
@mock.patch('magnum.drivers.heat.k8s_template_def.K8sTemplateDefinition'
'._set_master_lb_allowed_cidrs')
@mock.patch('magnum.common.neutron.get_fixed_network_name')
@@ -408,7 +409,8 @@ class AtomicK8sTemplateDefinitionTestCase(BaseK8sTemplateDefinitionTestCase):
mock_get_discovery_url, mock_osc_class,
mock_enable_octavia,
mock_get_fixed_network_name,
mock_set_master_lb_allowed_cidrs):
mock_set_master_lb_allowed_cidrs,
mock_get_subnet):
mock_generate_csr_and_key.return_value = {'csr': 'csr',
'private_key': 'private_key',
'public_key': 'public_key'}
@@ -440,6 +442,7 @@ class AtomicK8sTemplateDefinitionTestCase(BaseK8sTemplateDefinitionTestCase):

mock_context.auth_url = 'http://192.168.10.10:5000/v3'
mock_context.user_name = 'fake_user'
mock_get_subnet.return_value = '20.200.0.0/16'

flannel_cidr = mock_cluster.labels.get('flannel_network_cidr')
flannel_subnet = mock_cluster.labels.get(
@@ -716,6 +719,7 @@ class AtomicK8sTemplateDefinitionTestCase(BaseK8sTemplateDefinitionTestCase):
'post_install_manifest_url': '',
'metrics_scraper_tag': metrics_scraper_tag,
'master_lb_allowed_cidrs': master_lb_allowed_cidrs,
'fixed_subnet_cidr': '20.200.0.0/16',
}}
mock_get_params.assert_called_once_with(mock_context,
mock_cluster_template,
@@ -742,6 +746,7 @@ class AtomicK8sTemplateDefinitionTestCase(BaseK8sTemplateDefinitionTestCase):
mock_cluster.fixed_network
)

@mock.patch('magnum.common.neutron.get_subnet')
@mock.patch('magnum.common.neutron.get_external_network_id')
@mock.patch('magnum.common.keystone.is_octavia_enabled')
@mock.patch('magnum.common.clients.OpenStackClients')
@@ -759,7 +764,8 @@ class AtomicK8sTemplateDefinitionTestCase(BaseK8sTemplateDefinitionTestCase):
mock_get_discovery_url,
mock_osc_class,
mock_enable_octavia,
mock_get_external_network_id):
mock_get_external_network_id,
mock_get_subnet):
mock_generate_csr_and_key.return_value = {'csr': 'csr',
'private_key': 'private_key',
'public_key': 'public_key'}
@@ -803,6 +809,7 @@ class AtomicK8sTemplateDefinitionTestCase(BaseK8sTemplateDefinitionTestCase):
mock_cluster_template.external_network_id
)

@mock.patch('magnum.common.neutron.get_subnet')
@mock.patch('magnum.common.keystone.is_octavia_enabled')
@mock.patch('magnum.common.clients.OpenStackClients')
@mock.patch('magnum.drivers.k8s_fedora_atomic_v1.template_def'
@@ -818,7 +825,8 @@ class AtomicK8sTemplateDefinitionTestCase(BaseK8sTemplateDefinitionTestCase):
mock_get_params,
mock_get_discovery_url,
mock_osc_class,
mock_enable_octavia):
mock_enable_octavia,
mock_get_subnet):
mock_generate_csr_and_key.return_value = {'csr': 'csr',
'private_key': 'private_key',
'public_key': 'public_key'}
@@ -858,6 +866,7 @@ class AtomicK8sTemplateDefinitionTestCase(BaseK8sTemplateDefinitionTestCase):
mock_cluster,
)

@mock.patch('magnum.common.neutron.get_subnet')
@mock.patch('magnum.common.keystone.is_octavia_enabled')
@mock.patch('magnum.common.clients.OpenStackClients')
@mock.patch('magnum.drivers.k8s_fedora_atomic_v1.template_def'
@@ -873,7 +882,8 @@ class AtomicK8sTemplateDefinitionTestCase(BaseK8sTemplateDefinitionTestCase):
mock_get_params,
mock_get_discovery_url,
mock_osc_class,
mock_enable_octavia):
mock_enable_octavia,
mock_get_subnet):
mock_generate_csr_and_key.return_value = {'csr': 'csr',
'private_key': 'private_key',
'public_key': 'public_key'}
@@ -912,6 +922,7 @@ class AtomicK8sTemplateDefinitionTestCase(BaseK8sTemplateDefinitionTestCase):
actual_params.get("ingress_controller")
)

@mock.patch('magnum.common.neutron.get_subnet')
@mock.patch('magnum.drivers.heat.k8s_template_def.K8sTemplateDefinition'
'._set_master_lb_allowed_cidrs')
@mock.patch('magnum.common.keystone.is_octavia_enabled')
@@ -930,7 +941,8 @@ class AtomicK8sTemplateDefinitionTestCase(BaseK8sTemplateDefinitionTestCase):
mock_get_output, mock_get_params,
mock_get_discovery_url, mock_osc_class,
mock_enable_octavia,
mock_set_master_lb_allowed_cidrs):
mock_set_master_lb_allowed_cidrs,
mock_get_subnet):
mock_generate_csr_and_key.return_value = {'csr': 'csr',
'private_key': 'private_key',
'public_key': 'public_key'}
@@ -960,6 +972,7 @@ class AtomicK8sTemplateDefinitionTestCase(BaseK8sTemplateDefinitionTestCase):

mock_context.auth_url = 'http://192.168.10.10:5000/v3'
mock_context.user_name = 'fake_user'
mock_get_subnet.return_value = "20.200.0.0/16"

flannel_cidr = mock_cluster.labels.get('flannel_network_cidr')
flannel_subnet = mock_cluster.labels.get(
@@ -1239,6 +1252,7 @@ class AtomicK8sTemplateDefinitionTestCase(BaseK8sTemplateDefinitionTestCase):
'post_install_manifest_url': '',
'metrics_scraper_tag': metrics_scraper_tag,
'master_lb_allowed_cidrs': master_lb_allowed_cidrs,
'fixed_subnet_cidr': '20.200.0.0/16',
}}
mock_get_params.assert_called_once_with(mock_context,
mock_cluster_template,
@@ -1515,12 +1529,12 @@ class AtomicK8sTemplateDefinitionTestCase(BaseK8sTemplateDefinitionTestCase):
self.assertEqual(extra_params["master_lb_allowed_cidrs"],
"192.168.0.0/16,10.0.0.0/24")

def test_set_master_lb_allowed_cidrs_fixed_network_cidr(self):
def test_set_master_lb_allowed_cidrs_fixed_subnet_cidr(self):
definition = self.get_definition()
extra_params = {"master_lb_allowed_cidrs": "192.168.0.0/16"}
mock_cluster = mock.MagicMock()
mock_context = mock.MagicMock()
mock_cluster.labels = {"fixed_network_cidr": "100.0.0.0/24"}
mock_cluster.labels = {"fixed_subnet_cidr": "100.0.0.0/24"}

definition._set_master_lb_allowed_cidrs(mock_context,
mock_cluster, extra_params)


+ 6
- 0
releasenotes/notes/fix-label-fixed_network_cidr-95d6a2571b58a8fc.yaml View File

@@ -0,0 +1,6 @@
---
fixes:
- |
Now the label `fixed_network_cidr` have been renamed with
`fixed_subnet_cidr`. And it can be passed in and set
correctly.

Loading…
Cancel
Save