Add master_lb_enabled to cluster

Adding the master_lb_enabled option when creating a cluster,
which will benefit both the cloud provider side and the end
user side. For cloud prodiver, they don't have to maintain
separate cluster templates with or w/o master_lb_enabled enabled.
For end user, they can easily use one single template to create
different clusters with different configs.

Task: 39680
Story: 2007634

Change-Id: I0b586f05168ece84fd340ef7493a56688191053d
This commit is contained in:
Feilong Wang 2020-05-07 10:31:19 +12:00
parent b0bcd319ca
commit 946c1d67c7
23 changed files with 113 additions and 73 deletions

View File

@ -124,7 +124,7 @@ class DcosCentosTemplateDefinition(template_def.BaseTemplateDefinition):
# By default, master_discovery is set to 'static' # By default, master_discovery is set to 'static'
# If --master-lb-enabled is specified, # If --master-lb-enabled is specified,
# master_discovery will be set to 'master_http_loadbalancer' # master_discovery will be set to 'master_http_loadbalancer'
if cluster_template.master_lb_enabled: if cluster.master_lb_enabled:
extra_params['master_discovery'] = 'master_http_loadbalancer' extra_params['master_discovery'] = 'master_http_loadbalancer'
if 'true' == extra_params['dcos_overlay_enable']: if 'true' == extra_params['dcos_overlay_enable']:
@ -157,7 +157,7 @@ class DcosCentosTemplateDefinition(template_def.BaseTemplateDefinition):
env_files = [] env_files = []
template_def.add_priv_net_env_file(env_files, cluster) template_def.add_priv_net_env_file(env_files, cluster)
template_def.add_lb_env_file(env_files, cluster_template) template_def.add_lb_env_file(env_files, cluster)
template_def.add_fip_env_file(env_files, cluster_template, cluster) template_def.add_fip_env_file(env_files, cluster)
return env_files return env_files

View File

@ -44,15 +44,15 @@ class JeOSK8sTemplateDefinition(k8s_template_def.K8sTemplateDefinition):
extra_params=extra_params, extra_params=extra_params,
**kwargs) **kwargs)
def get_env_files(self, cluster_template, cluster): def get_env_files(self, cluster):
env_files = [] env_files = []
if cluster_template.master_lb_enabled: if cluster.master_lb_enabled:
env_files.append( env_files.append(
template_def.COMMON_ENV_PATH + 'with_master_lb.yaml') template_def.COMMON_ENV_PATH + 'with_master_lb.yaml')
else: else:
env_files.append( env_files.append(
template_def.COMMON_ENV_PATH + 'no_master_lb.yaml') template_def.COMMON_ENV_PATH + 'no_master_lb.yaml')
if cluster_template.floating_ip_enabled: if cluster.floating_ip_enabled:
env_files.append( env_files.append(
template_def.COMMON_ENV_PATH + 'enable_floating_ip.yaml') template_def.COMMON_ENV_PATH + 'enable_floating_ip.yaml')
else: else:

View File

@ -653,6 +653,10 @@ follows:
reached during cluster-create, the operation will be aborted and the reached during cluster-create, the operation will be aborted and the
cluster status will be set to 'CREATE_FAILED'. cluster status will be set to 'CREATE_FAILED'.
--master-lb-enabled
Indicates whether created clusters should have a load balancer for
master nodes or not.
List List
++++ ++++

View File

@ -151,6 +151,11 @@ class Bay(base.APIBase):
floating_ip_enabled = wsme.wsattr(types.boolean, default=True) floating_ip_enabled = wsme.wsattr(types.boolean, default=True)
"""Indicates whether created clusters should have a floating ip or not.""" """Indicates whether created clusters should have a floating ip or not."""
master_lb_enabled = wsme.wsattr(types.boolean)
"""Indicates whether created clusters should have a load balancer for master
nodes or not.
"""
def __init__(self, **kwargs): def __init__(self, **kwargs):
super(Bay, self).__init__() super(Bay, self).__init__()

View File

@ -202,6 +202,11 @@ class Cluster(base.APIBase):
wtypes.text, six.integer_types, bool, float)) wtypes.text, six.integer_types, bool, float))
"""Contains labels that exist in the parent but were not inherited.""" """Contains labels that exist in the parent but were not inherited."""
master_lb_enabled = wsme.wsattr(types.boolean)
"""Indicates whether created clusters should have a load balancer for master
nodes or not.
"""
def __init__(self, **kwargs): def __init__(self, **kwargs):
super(Cluster, self).__init__() super(Cluster, self).__init__()
self.fields = [] self.fields = []
@ -275,7 +280,8 @@ class Cluster(base.APIBase):
container_version=None, container_version=None,
fixed_network=None, fixed_network=None,
fixed_subnet=None, fixed_subnet=None,
floating_ip_enabled=True) floating_ip_enabled=True,
master_lb_enabled=True)
return cls._convert_with_links(sample, 'http://localhost:9511', expand) return cls._convert_with_links(sample, 'http://localhost:9511', expand)
@ -527,6 +533,10 @@ class ClustersController(base.Controller):
if cluster.floating_ip_enabled == wtypes.Unset: if cluster.floating_ip_enabled == wtypes.Unset:
cluster.floating_ip_enabled = cluster_template.floating_ip_enabled cluster.floating_ip_enabled = cluster_template.floating_ip_enabled
# If master_lb_enabled is not present, use cluster_template value
if cluster.master_lb_enabled == wtypes.Unset:
cluster.master_lb_enabled = cluster_template.master_lb_enabled
attributes = ["docker_volume_size", "master_flavor_id", "flavor_id", attributes = ["docker_volume_size", "master_flavor_id", "flavor_id",
"fixed_network", "fixed_subnet"] "fixed_network", "fixed_subnet"]
for attr in attributes: for attr in attributes:

View File

@ -0,0 +1,41 @@
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
from alembic import op
import sqlalchemy as sa
"""add-master_lb_enabled-to-cluster
Revision ID: 95096e2334ee
Revises: c04e925e65c2
Create Date: 2020-06-26 14:33:05.529200
"""
# revision identifiers, used by Alembic.
revision = '95096e2334ee'
down_revision = 'c04e925e65c2'
def upgrade():
op.add_column('cluster',
sa.Column('master_lb_enabled', sa.Boolean(), default=False))
# Populate existing cluster with the cluster template_id
connection = op.get_bind()
connection.execute(
"UPDATE cluster "
"INNER JOIN cluster_template "
"ON cluster_template.uuid=cluster.cluster_template_id "
"SET cluster.master_lb_enabled=cluster_template.master_lb_enabled "
"WHERE cluster_template.uuid=cluster.cluster_template_id and "
"cluster.master_lb_enabled is NULL"
)

View File

@ -148,6 +148,7 @@ class Cluster(Base):
fixed_network = Column(String(255, mysql_ndb_type=TINYTEXT)) fixed_network = Column(String(255, mysql_ndb_type=TINYTEXT))
fixed_subnet = Column(String(255, mysql_ndb_type=TINYTEXT)) fixed_subnet = Column(String(255, mysql_ndb_type=TINYTEXT))
floating_ip_enabled = Column(Boolean, default=True) floating_ip_enabled = Column(Boolean, default=True)
master_lb_enabled = Column(Boolean, default=False)
class ClusterTemplate(Base): class ClusterTemplate(Base):

View File

@ -70,7 +70,7 @@ class K8sMonitor(monitors.MonitorBase):
return (auto_healing_enabled and controller == "magnum-auto-healer") return (auto_healing_enabled and controller == "magnum-auto-healer")
def _is_cluster_accessible(self): def _is_cluster_accessible(self):
if self.cluster.cluster_template.master_lb_enabled: if self.cluster.master_lb_enabled:
lb_fip = self.cluster.labels.get("master_lb_floating_ip_enabled", lb_fip = self.cluster.labels.get("master_lb_floating_ip_enabled",
self.cluster.floating_ip_enabled) self.cluster.floating_ip_enabled)
return strutils.bool_from_string(lb_fip) return strutils.bool_from_string(lb_fip)

View File

@ -97,7 +97,7 @@ class CoreOSK8sTemplateDefinition(k8s_template_def.K8sTemplateDefinition):
template_def.add_etcd_volume_env_file(env_files, cluster) template_def.add_etcd_volume_env_file(env_files, cluster)
template_def.add_volume_env_file(env_files, cluster, template_def.add_volume_env_file(env_files, cluster,
nodegroup=nodegroup) nodegroup=nodegroup)
template_def.add_lb_env_file(env_files, cluster_template) template_def.add_lb_env_file(env_files, cluster)
template_def.add_fip_env_file(env_files, cluster_template, cluster) template_def.add_fip_env_file(env_files, cluster)
return env_files return env_files

View File

@ -233,7 +233,7 @@ class K8sFedoraTemplateDefinition(k8s_template_def.K8sTemplateDefinition):
template_def.add_etcd_volume_env_file(env_files, cluster) template_def.add_etcd_volume_env_file(env_files, cluster)
template_def.add_volume_env_file(env_files, cluster, template_def.add_volume_env_file(env_files, cluster,
nodegroup=nodegroup) nodegroup=nodegroup)
template_def.add_lb_env_file(env_files, cluster_template) template_def.add_lb_env_file(env_files, cluster)
template_def.add_fip_env_file(env_files, cluster_template, cluster) template_def.add_fip_env_file(env_files, cluster)
return env_files return env_files

View File

@ -163,7 +163,7 @@ class SwarmFedoraTemplateDefinition(template_def.BaseTemplateDefinition):
cluster) cluster)
template_def.add_volume_env_file(env_files, cluster, template_def.add_volume_env_file(env_files, cluster,
nodegroup=nodegroup) nodegroup=nodegroup)
template_def.add_lb_env_file(env_files, cluster_template) template_def.add_lb_env_file(env_files, cluster)
return env_files return env_files

View File

@ -189,8 +189,8 @@ class SwarmModeTemplateDefinition(template_def.BaseTemplateDefinition):
cluster) cluster)
template_def.add_volume_env_file(env_files, cluster, template_def.add_volume_env_file(env_files, cluster,
nodegroup=nodegroup) nodegroup=nodegroup)
template_def.add_lb_env_file(env_files, cluster_template) template_def.add_lb_env_file(env_files, cluster)
template_def.add_fip_env_file(env_files, cluster_template, cluster) template_def.add_fip_env_file(env_files, cluster)
return env_files return env_files

View File

@ -534,8 +534,8 @@ class BaseTemplateDefinition(TemplateDefinition):
return dict() return dict()
def add_lb_env_file(env_files, cluster_template): def add_lb_env_file(env_files, cluster):
if cluster_template.master_lb_enabled: if cluster.master_lb_enabled:
if keystone.is_octavia_enabled(): if keystone.is_octavia_enabled():
env_files.append(COMMON_ENV_PATH + 'with_master_lb_octavia.yaml') env_files.append(COMMON_ENV_PATH + 'with_master_lb_octavia.yaml')
else: else:
@ -562,7 +562,7 @@ def add_etcd_volume_env_file(env_files, cluster):
env_files.append(COMMON_ENV_PATH + 'with_etcd_volume.yaml') env_files.append(COMMON_ENV_PATH + 'with_etcd_volume.yaml')
def add_fip_env_file(env_files, cluster_template, cluster): def add_fip_env_file(env_files, cluster):
lb_fip_enabled = cluster.labels.get("master_lb_floating_ip_enabled") lb_fip_enabled = cluster.labels.get("master_lb_floating_ip_enabled")
master_lb_fip_enabled = (strutils.bool_from_string(lb_fip_enabled) or master_lb_fip_enabled = (strutils.bool_from_string(lb_fip_enabled) or
cluster.floating_ip_enabled) cluster.floating_ip_enabled)
@ -572,7 +572,7 @@ def add_fip_env_file(env_files, cluster_template, cluster):
else: else:
env_files.append(COMMON_ENV_PATH + 'disable_floating_ip.yaml') env_files.append(COMMON_ENV_PATH + 'disable_floating_ip.yaml')
if cluster_template.master_lb_enabled and master_lb_fip_enabled: if cluster.master_lb_enabled and master_lb_fip_enabled:
env_files.append(COMMON_ENV_PATH + 'enable_lb_floating_ip.yaml') env_files.append(COMMON_ENV_PATH + 'enable_lb_floating_ip.yaml')
else: else:
env_files.append(COMMON_ENV_PATH + 'disable_lb_floating_ip.yaml') env_files.append(COMMON_ENV_PATH + 'disable_lb_floating_ip.yaml')

View File

@ -128,7 +128,7 @@ class UbuntuMesosTemplateDefinition(template_def.BaseTemplateDefinition):
template_def.add_priv_net_env_file(env_files, cluster_template, template_def.add_priv_net_env_file(env_files, cluster_template,
cluster) cluster)
template_def.add_lb_env_file(env_files, cluster_template) template_def.add_lb_env_file(env_files, cluster)
return env_files return env_files

View File

@ -52,8 +52,9 @@ class Cluster(base.MagnumPersistentObject, base.MagnumObject,
# Version 1.20: Fields node_count, master_count, node_addresses, # Version 1.20: Fields node_count, master_count, node_addresses,
# master_addresses are now properties. # master_addresses are now properties.
# Version 1.21 Added fixed_network, fixed_subnet, floating_ip_enabled # Version 1.21 Added fixed_network, fixed_subnet, floating_ip_enabled
# Version 1.22 Added master_lb_enabled
VERSION = '1.21' VERSION = '1.22'
dbapi = dbapi.get_instance() dbapi = dbapi.get_instance()
@ -89,6 +90,7 @@ class Cluster(base.MagnumPersistentObject, base.MagnumObject,
'fixed_network': fields.StringField(nullable=True), 'fixed_network': fields.StringField(nullable=True),
'fixed_subnet': fields.StringField(nullable=True), 'fixed_subnet': fields.StringField(nullable=True),
'floating_ip_enabled': fields.BooleanField(default=True), 'floating_ip_enabled': fields.BooleanField(default=True),
'master_lb_enabled': fields.BooleanField(default=False),
} }
@staticmethod @staticmethod

View File

@ -122,6 +122,7 @@ class TestClusterConductorWithK8s(base.TestCase):
'fixed_network': 'fixed_network', 'fixed_network': 'fixed_network',
'fixed_subnet': 'c2a6c8b0-a3c2-42a3-b3f4-01400a30896f', 'fixed_subnet': 'c2a6c8b0-a3c2-42a3-b3f4-01400a30896f',
'floating_ip_enabled': False, 'floating_ip_enabled': False,
'master_lb_enabled': False,
} }
self.worker_ng_dict = { self.worker_ng_dict = {
'uuid': '5d12f6fd-a196-4bf0-ae4c-1f639a523a53', 'uuid': '5d12f6fd-a196-4bf0-ae4c-1f639a523a53',

View File

@ -75,6 +75,7 @@ class TestClusterConductorWithMesos(base.TestCase):
'fixed_network': '', 'fixed_network': '',
'fixed_subnet': '', 'fixed_subnet': '',
'floating_ip_enabled': False, 'floating_ip_enabled': False,
'master_lb_enabled': False,
} }
self.worker_ng_dict = { self.worker_ng_dict = {
'uuid': '5d12f6fd-a196-4bf0-ae4c-1f639a523a53', 'uuid': '5d12f6fd-a196-4bf0-ae4c-1f639a523a53',
@ -276,6 +277,7 @@ class TestClusterConductorWithMesos(base.TestCase):
self.context, **self.cluster_template_dict) self.context, **self.cluster_template_dict)
mock_objects_cluster_template_get_by_uuid.return_value = \ mock_objects_cluster_template_get_by_uuid.return_value = \
cluster_template cluster_template
self.cluster_dict["master_lb_enabled"] = True
cluster = objects.Cluster(self.context, **self.cluster_dict) cluster = objects.Cluster(self.context, **self.cluster_dict)
worker_ng = objects.NodeGroup(self.context, **self.worker_ng_dict) worker_ng = objects.NodeGroup(self.context, **self.worker_ng_dict)
master_ng = objects.NodeGroup(self.context, **self.master_ng_dict) master_ng = objects.NodeGroup(self.context, **self.master_ng_dict)
@ -347,6 +349,7 @@ class TestClusterConductorWithMesos(base.TestCase):
self.context, **self.cluster_template_dict) self.context, **self.cluster_template_dict)
mock_objects_cluster_template_get_by_uuid.return_value = \ mock_objects_cluster_template_get_by_uuid.return_value = \
cluster_template cluster_template
self.cluster_dict["master_lb_enabled"] = True
cluster = objects.Cluster(self.context, **self.cluster_dict) cluster = objects.Cluster(self.context, **self.cluster_dict)
worker_ng = objects.NodeGroup(self.context, **self.worker_ng_dict) worker_ng = objects.NodeGroup(self.context, **self.worker_ng_dict)
master_ng = objects.NodeGroup(self.context, **self.master_ng_dict) master_ng = objects.NodeGroup(self.context, **self.master_ng_dict)
@ -424,6 +427,7 @@ class TestClusterConductorWithMesos(base.TestCase):
self.context, **self.cluster_template_dict) self.context, **self.cluster_template_dict)
mock_objects_cluster_template_get_by_uuid.return_value = \ mock_objects_cluster_template_get_by_uuid.return_value = \
cluster_template cluster_template
self.cluster_dict["master_lb_enabled"] = True
cluster = objects.Cluster(self.context, **self.cluster_dict) cluster = objects.Cluster(self.context, **self.cluster_dict)
worker_ng = objects.NodeGroup(self.context, **self.worker_ng_dict) worker_ng = objects.NodeGroup(self.context, **self.worker_ng_dict)
master_ng = objects.NodeGroup(self.context, **self.master_ng_dict) master_ng = objects.NodeGroup(self.context, **self.master_ng_dict)

View File

@ -85,6 +85,7 @@ class TestClusterConductorWithSwarm(base.TestCase):
'fixed_network': '', 'fixed_network': '',
'fixed_subnet': '', 'fixed_subnet': '',
'floating_ip_enabled': False, 'floating_ip_enabled': False,
'master_lb_enabled': False,
} }
self.worker_ng_dict = { self.worker_ng_dict = {
'uuid': '5d12f6fd-a196-4bf0-ae4c-1f639a523a53', 'uuid': '5d12f6fd-a196-4bf0-ae4c-1f639a523a53',
@ -411,6 +412,7 @@ class TestClusterConductorWithSwarm(base.TestCase):
mock_resp.text = expected_result mock_resp.text = expected_result
mock_get.return_value = mock_resp mock_get.return_value = mock_resp
mock_driver.return_value = swarm_dr.Driver() mock_driver.return_value = swarm_dr.Driver()
self.cluster_dict["master_lb_enabled"] = True
cluster = objects.Cluster(self.context, **self.cluster_dict) cluster = objects.Cluster(self.context, **self.cluster_dict)
worker_ng = objects.NodeGroup(self.context, **self.worker_ng_dict) worker_ng = objects.NodeGroup(self.context, **self.worker_ng_dict)
master_ng = objects.NodeGroup(self.context, **self.master_ng_dict) master_ng = objects.NodeGroup(self.context, **self.master_ng_dict)
@ -495,6 +497,7 @@ class TestClusterConductorWithSwarm(base.TestCase):
mock_resp.text = expected_result mock_resp.text = expected_result
mock_get.return_value = mock_resp mock_get.return_value = mock_resp
mock_driver.return_value = swarm_dr.Driver() mock_driver.return_value = swarm_dr.Driver()
self.cluster_dict["master_lb_enabled"] = True
cluster = objects.Cluster(self.context, **self.cluster_dict) cluster = objects.Cluster(self.context, **self.cluster_dict)
worker_ng = objects.NodeGroup(self.context, **self.worker_ng_dict) worker_ng = objects.NodeGroup(self.context, **self.worker_ng_dict)
master_ng = objects.NodeGroup(self.context, **self.master_ng_dict) master_ng = objects.NodeGroup(self.context, **self.master_ng_dict)
@ -585,6 +588,7 @@ class TestClusterConductorWithSwarm(base.TestCase):
mock_resp.text = expected_result mock_resp.text = expected_result
mock_get.return_value = mock_resp mock_get.return_value = mock_resp
mock_driver.return_value = swarm_dr.Driver() mock_driver.return_value = swarm_dr.Driver()
self.cluster_dict["master_lb_enabled"] = True
cluster = objects.Cluster(self.context, **self.cluster_dict) cluster = objects.Cluster(self.context, **self.cluster_dict)
worker_ng = objects.NodeGroup(self.context, **self.worker_ng_dict) worker_ng = objects.NodeGroup(self.context, **self.worker_ng_dict)
master_ng = objects.NodeGroup(self.context, **self.master_ng_dict) master_ng = objects.NodeGroup(self.context, **self.master_ng_dict)

View File

@ -536,7 +536,7 @@ class MonitorsTestCase(base.TestCase):
mock_nodes.items = [mock_node] mock_nodes.items = [mock_node]
cluster = self.k8s_monitor.cluster cluster = self.k8s_monitor.cluster
cluster.floating_ip_enabled = True cluster.floating_ip_enabled = True
cluster.cluster_template.master_lb_enabled = True cluster.master_lb_enabled = True
cluster.labels['master_lb_floating_ip_enabled'] = False cluster.labels['master_lb_floating_ip_enabled'] = False
self.k8s_monitor.poll_health_status() self.k8s_monitor.poll_health_status()

View File

@ -101,6 +101,7 @@ def get_test_cluster(**kw):
'fixed_network': kw.get('fixed_network', None), 'fixed_network': kw.get('fixed_network', None),
'fixed_subnet': kw.get('fixed_subnet', None), 'fixed_subnet': kw.get('fixed_subnet', None),
'floating_ip_enabled': kw.get('floating_ip_enabled', True), 'floating_ip_enabled': kw.get('floating_ip_enabled', True),
'master_lb_enabled': kw.get('master_lb_enabled', False),
} }
if kw.pop('for_api_use', False): if kw.pop('for_api_use', False):

View File

@ -186,13 +186,9 @@ class TemplateDefinitionTestCase(base.TestCase):
definition.output_mappings) definition.output_mappings)
def test_add_fip_env_lb_disabled_with_fp(self): def test_add_fip_env_lb_disabled_with_fp(self):
mock_cluster_template = mock.MagicMock(floating_ip_enabled=True, mock_cluster = mock.MagicMock(master_lb_enabled=False, labels={})
master_lb_enabled=False,
labels={})
mock_cluster = mock.MagicMock(labels={})
env_files = [] env_files = []
cmn_tdef.add_fip_env_file(env_files, mock_cluster_template, cmn_tdef.add_fip_env_file(env_files, mock_cluster)
mock_cluster)
self.assertEqual( self.assertEqual(
[ [
cmn_tdef.COMMON_ENV_PATH + 'enable_floating_ip.yaml', cmn_tdef.COMMON_ENV_PATH + 'enable_floating_ip.yaml',
@ -202,13 +198,11 @@ class TemplateDefinitionTestCase(base.TestCase):
) )
def test_add_fip_env_lb_enabled_with_fp(self): def test_add_fip_env_lb_enabled_with_fp(self):
mock_cluster_template = mock.MagicMock(floating_ip_enabled=True, mock_cluster = mock.MagicMock(floating_ip_enabled=True,
master_lb_enabled=True, master_lb_enabled=True,
labels={}) labels={})
mock_cluster = mock.MagicMock(floating_ip_enabled=True, labels={})
env_files = [] env_files = []
cmn_tdef.add_fip_env_file(env_files, mock_cluster_template, cmn_tdef.add_fip_env_file(env_files, mock_cluster)
mock_cluster)
self.assertEqual( self.assertEqual(
[ [
cmn_tdef.COMMON_ENV_PATH + 'enable_floating_ip.yaml', cmn_tdef.COMMON_ENV_PATH + 'enable_floating_ip.yaml',
@ -218,13 +212,9 @@ class TemplateDefinitionTestCase(base.TestCase):
) )
def test_add_fip_env_lb_disabled_without_fp(self): def test_add_fip_env_lb_disabled_without_fp(self):
mock_cluster_template = mock.MagicMock(floating_ip_enabled=False,
master_lb_enabled=False,
labels={})
mock_cluster = mock.MagicMock(labels={}, floating_ip_enabled=False) mock_cluster = mock.MagicMock(labels={}, floating_ip_enabled=False)
env_files = [] env_files = []
cmn_tdef.add_fip_env_file(env_files, mock_cluster_template, cmn_tdef.add_fip_env_file(env_files, mock_cluster)
mock_cluster)
self.assertEqual( self.assertEqual(
[ [
cmn_tdef.COMMON_ENV_PATH + 'disable_floating_ip.yaml', cmn_tdef.COMMON_ENV_PATH + 'disable_floating_ip.yaml',
@ -234,13 +224,9 @@ class TemplateDefinitionTestCase(base.TestCase):
) )
def test_add_fip_env_lb_enabled_without_fp(self): def test_add_fip_env_lb_enabled_without_fp(self):
mock_cluster_template = mock.MagicMock(floating_ip_enabled=False,
master_lb_enabled=True,
labels={})
mock_cluster = mock.MagicMock(labels={}, floating_ip_enabled=False,) mock_cluster = mock.MagicMock(labels={}, floating_ip_enabled=False,)
env_files = [] env_files = []
cmn_tdef.add_fip_env_file(env_files, mock_cluster_template, cmn_tdef.add_fip_env_file(env_files, mock_cluster)
mock_cluster)
self.assertEqual( self.assertEqual(
[ [
cmn_tdef.COMMON_ENV_PATH + 'disable_floating_ip.yaml', cmn_tdef.COMMON_ENV_PATH + 'disable_floating_ip.yaml',
@ -250,17 +236,11 @@ class TemplateDefinitionTestCase(base.TestCase):
) )
def test_add_fip_env_lb_fip_enabled_without_fp(self): def test_add_fip_env_lb_fip_enabled_without_fp(self):
mock_cluster_template = mock.MagicMock(
floating_ip_enabled=False,
master_lb_enabled=True,
labels={"master_lb_floating_ip_enabled": "true"}
)
mock_cluster = mock.MagicMock( mock_cluster = mock.MagicMock(
labels={"master_lb_floating_ip_enabled": "true"}, labels={"master_lb_floating_ip_enabled": "true"},
floating_ip_enabled=False,) floating_ip_enabled=False,)
env_files = [] env_files = []
cmn_tdef.add_fip_env_file(env_files, mock_cluster_template, cmn_tdef.add_fip_env_file(env_files, mock_cluster)
mock_cluster)
self.assertEqual( self.assertEqual(
[ [
cmn_tdef.COMMON_ENV_PATH + 'disable_floating_ip.yaml', cmn_tdef.COMMON_ENV_PATH + 'disable_floating_ip.yaml',
@ -270,18 +250,12 @@ class TemplateDefinitionTestCase(base.TestCase):
) )
def test_add_fip_env_lb_enable_lbfip_disable(self): def test_add_fip_env_lb_enable_lbfip_disable(self):
mock_cluster_template = mock.MagicMock(
floating_ip_enabled=False,
master_lb_enabled=True,
labels={"master_lb_floating_ip_enabled": "false"}
)
mock_cluster = mock.MagicMock( mock_cluster = mock.MagicMock(
labels={"master_lb_floating_ip_enabled": "false"}, labels={"master_lb_floating_ip_enabled": "false"},
floating_ip_enabled=False,) floating_ip_enabled=False,)
env_files = [] env_files = []
cmn_tdef.add_fip_env_file(env_files, mock_cluster_template, cmn_tdef.add_fip_env_file(env_files, mock_cluster)
mock_cluster)
self.assertEqual( self.assertEqual(
[ [
@ -292,18 +266,12 @@ class TemplateDefinitionTestCase(base.TestCase):
) )
def test_add_fip_env_lb_enable_lbfip_template_disable_cluster_enable(self): def test_add_fip_env_lb_enable_lbfip_template_disable_cluster_enable(self):
mock_cluster_template = mock.MagicMock(
floating_ip_enabled=False,
master_lb_enabled=True,
labels={}
)
mock_cluster = mock.MagicMock( mock_cluster = mock.MagicMock(
floating_ip_enabled=True, floating_ip_enabled=True,
labels={}) labels={})
env_files = [] env_files = []
cmn_tdef.add_fip_env_file(env_files, mock_cluster_template, cmn_tdef.add_fip_env_file(env_files, mock_cluster)
mock_cluster)
self.assertEqual( self.assertEqual(
[ [
@ -314,18 +282,12 @@ class TemplateDefinitionTestCase(base.TestCase):
) )
def test_add_fip_master_lb_fip_disabled_cluster_fip_enabled(self): def test_add_fip_master_lb_fip_disabled_cluster_fip_enabled(self):
mock_cluster_template = mock.MagicMock(
floating_ip_enabled=False,
master_lb_enabled=True,
labels={"master_lb_floating_ip_enabled": "false"}
)
mock_cluster = mock.MagicMock( mock_cluster = mock.MagicMock(
labels={"master_lb_floating_ip_enabled": "false"}, labels={"master_lb_floating_ip_enabled": "false"},
floating_ip_enabled=True,) floating_ip_enabled=True,)
env_files = [] env_files = []
cmn_tdef.add_fip_env_file(env_files, mock_cluster_template, cmn_tdef.add_fip_env_file(env_files, mock_cluster)
mock_cluster)
self.assertEqual( self.assertEqual(
[ [

View File

@ -355,7 +355,7 @@ class TestObject(test_base.TestCase, _TestObject):
# For more information on object version testing, read # For more information on object version testing, read
# https://docs.openstack.org/magnum/latest/contributor/objects.html # https://docs.openstack.org/magnum/latest/contributor/objects.html
object_data = { object_data = {
'Cluster': '1.21-e28dc2dd599433a6249f7901ebf7b162', 'Cluster': '1.22-39ae1aa9ed1e90ee05f67f64b5fce4bb',
'ClusterTemplate': '1.19-3b0b2b3933d0955abf3ab40111744960', 'ClusterTemplate': '1.19-3b0b2b3933d0955abf3ab40111744960',
'Certificate': '1.1-1924dc077daa844f0f9076332ef96815', 'Certificate': '1.1-1924dc077daa844f0f9076332ef96815',
'MyObj': '1.0-34c4b1aadefd177b13f9a2f894cc23cd', 'MyObj': '1.0-34c4b1aadefd177b13f9a2f894cc23cd',

View File

@ -0,0 +1,5 @@
---
features:
- |
Users can enable or disable master_lb_enabled when creating
a cluster.