Updates CONF usage from bay to cluster.

Renames bay-related CONF options to their respective cluster names.
Adds release notes for CONF changes.

Change-Id: I7bbe0927e54c1f40a47bfdea448a88b467fef106
Implements: blueprint rename-bay-to-cluster
changes/60/362660/7
Stephen Watson 6 years ago
parent 5258fddf9d
commit 6ead3e4780
  1. 57
      magnum/api/validation.py
  2. 2
      magnum/cmd/template_manage.py
  3. 35
      magnum/conductor/handlers/bay_conductor.py
  4. 11
      magnum/db/sqlalchemy/alembic/versions/592131657ca1_add_coe_column_to_baymodel.py
  5. 12
      magnum/drivers/common/template_def.py
  6. 7
      magnum/opts.py
  7. 4
      magnum/tests/functional/python_client_base.py
  8. 4
      magnum/tests/unit/api/controllers/v1/test_baymodel.py
  9. 4
      magnum/tests/unit/api/controllers/v1/test_cluster_template.py
  10. 6
      magnum/tests/unit/api/test_validation.py
  11. 10
      magnum/tests/unit/conductor/handlers/test_bay_conductor.py
  12. 6
      magnum/tests/unit/conductor/handlers/test_k8s_bay_conductor.py
  13. 2
      magnum/tests/unit/conductor/handlers/test_mesos_bay_conductor.py
  14. 2
      magnum/tests/unit/conductor/handlers/test_swarm_bay_conductor.py
  15. 8
      magnum/tests/unit/drivers/test_template_definition.py
  16. 26
      releasenotes/notes/change-bay-to-cluster-in-config-1f2b95d1176d7231.yaml

@ -24,36 +24,45 @@ from magnum.i18n import _
from magnum import objects
baymodel_opts = [
cluster_template_opts = [
cfg.ListOpt('kubernetes_allowed_network_drivers',
default=['all'],
help=_("Allowed network drivers for kubernetes baymodels. "
"Use 'all' keyword to allow all drivers supported "
"for kubernetes baymodels. Supported network drivers "
"include flannel.")),
help=_("Allowed network drivers for kubernetes "
"cluster-templates. Use 'all' keyword to allow all "
"drivers supported for kubernetes cluster-templates. "
"Supported network drivers include flannel."),
deprecated_group='baymodel'),
cfg.StrOpt('kubernetes_default_network_driver',
default='flannel',
help=_("Default network driver for kubernetes baymodels.")),
help=_("Default network driver for kubernetes "
"cluster-templates."),
deprecated_group='baymodel'),
cfg.ListOpt('swarm_allowed_network_drivers',
default=['all'],
help=_("Allowed network drivers for docker swarm baymodels. "
"Use 'all' keyword to allow all drivers supported "
"for swarm baymodels. Supported network drivers "
"include docker and flannel.")),
help=_("Allowed network drivers for docker swarm "
"cluster-templates. Use 'all' keyword to allow all "
"drivers supported for swarm cluster-templates. "
"Supported network drivers include docker and flannel."
),
deprecated_group='baymodel'),
cfg.StrOpt('swarm_default_network_driver',
default='docker',
help=_("Default network driver for docker swarm baymodels.")),
help=_("Default network driver for docker swarm "
"cluster-templates."),
deprecated_group='baymodel'),
cfg.ListOpt('mesos_allowed_network_drivers',
default=['all'],
help=_("Allowed network drivers for mesos baymodels. "
help=_("Allowed network drivers for mesos cluster-templates. "
"Use 'all' keyword to allow all drivers supported "
"for mesos baymodels. Supported network drivers "
"include docker.")),
"for mesos cluster-templates. Supported network "
"drivers include docker."),
deprecated_group='baymodel'),
cfg.StrOpt('mesos_default_network_driver',
default='docker',
help=_("Default network driver for mesos baymodels.")),
help=_("Default network driver for mesos cluster-templates."),
deprecated_group='baymodel'),
]
cfg.CONF.register_opts(baymodel_opts, group='baymodel')
cfg.CONF.register_opts(cluster_template_opts, group='cluster_template')
bay_update_allowed_properties = set(['node_count'])
@ -251,9 +260,9 @@ class K8sValidator(Validator):
supported_network_drivers = ['flannel']
allowed_network_drivers = (
cfg.CONF.baymodel.kubernetes_allowed_network_drivers)
cfg.CONF.cluster_template.kubernetes_allowed_network_drivers)
default_network_driver = (
cfg.CONF.baymodel.kubernetes_default_network_driver)
cfg.CONF.cluster_template.kubernetes_default_network_driver)
supported_volume_driver = ['cinder']
@ -261,8 +270,10 @@ class K8sValidator(Validator):
class SwarmValidator(Validator):
supported_network_drivers = ['docker', 'flannel']
allowed_network_drivers = cfg.CONF.baymodel.swarm_allowed_network_drivers
default_network_driver = cfg.CONF.baymodel.swarm_default_network_driver
allowed_network_drivers = (cfg.CONF.cluster_template.
swarm_allowed_network_drivers)
default_network_driver = (cfg.CONF.cluster_template.
swarm_default_network_driver)
supported_volume_driver = ['rexray']
@ -270,7 +281,9 @@ class SwarmValidator(Validator):
class MesosValidator(Validator):
supported_network_drivers = ['docker']
allowed_network_drivers = cfg.CONF.baymodel.mesos_allowed_network_drivers
default_network_driver = cfg.CONF.baymodel.mesos_default_network_driver
allowed_network_drivers = (cfg.CONF.cluster_template.
mesos_allowed_network_drivers)
default_network_driver = (cfg.CONF.cluster_template.
mesos_default_network_driver)
supported_volume_driver = ['rexray']

@ -26,7 +26,7 @@ CONF = cfg.CONF
def is_enabled(name):
return name in CONF.bay.enabled_definitions
return name in CONF.cluster.enabled_definitions
class TemplateList(lister.Lister):

@ -38,27 +38,32 @@ from magnum import objects
from magnum.objects.fields import BayStatus as bay_status
bay_heat_opts = [
cluster_heat_opts = [
cfg.IntOpt('max_attempts',
default=2000,
help=('Number of attempts to query the Heat stack for '
'finding out the status of the created stack and '
'getting template outputs. This value is ignored '
'during bay creation if timeout is set as the poll '
'will continue until bay creation either ends '
'or times out.')),
'during cluster creation if timeout is set as the poll '
'will continue until cluster creation either ends '
'or times out.'),
deprecated_group='bay_heat'),
cfg.IntOpt('wait_interval',
default=1,
help=('Sleep time interval between two attempts of querying '
'the Heat stack. This interval is in seconds.')),
cfg.IntOpt('bay_create_timeout',
'the Heat stack. This interval is in seconds.'),
deprecated_group='bay_heat'),
cfg.IntOpt('create_timeout',
default=60,
help=('The length of time to let bay creation continue. This '
'interval is in minutes. The default is 60 minutes.'))
help=('The length of time to let cluster creation continue. '
'This interval is in minutes. The default is 60 minutes.'
),
deprecated_group='bay_heat',
deprecated_name='bay_create_timeout')
]
CONF = cfg.CONF
CONF.register_opts(bay_heat_opts, group='bay_heat')
CONF.register_opts(cluster_heat_opts, group='cluster_heat')
LOG = logging.getLogger(__name__)
@ -101,7 +106,7 @@ def _create_stack(context, osc, bay, bay_create_timeout):
else:
# no bay_create_timeout value was passed in to the request
# so falling back on configuration file value
heat_timeout = cfg.CONF.bay_heat.bay_create_timeout
heat_timeout = cfg.CONF.cluster_heat.create_timeout
fields = {
'stack_name': stack_name,
'parameters': heat_params,
@ -259,7 +264,7 @@ class Handler(object):
def _poll_and_check(self, osc, bay):
poller = HeatPoller(osc, bay)
lc = loopingcall.FixedIntervalLoopingCall(f=poller.poll_and_check)
lc.start(cfg.CONF.bay_heat.wait_interval, True)
lc.start(cfg.CONF.cluster_heat.wait_interval, True)
class HeatPoller(object):
@ -324,18 +329,18 @@ class HeatPoller(object):
# the loop will end when the stack completes or the timeout occurs
if stack.stack_status == bay_status.CREATE_IN_PROGRESS:
if (stack.timeout_mins is None and
self.attempts > cfg.CONF.bay_heat.max_attempts):
self.attempts > cfg.CONF.cluster_heat.max_attempts):
LOG.error(_LE('Bay check exit after %(attempts)s attempts,'
'stack_id: %(id)s, stack_status: %(status)s') %
{'attempts': cfg.CONF.bay_heat.max_attempts,
{'attempts': cfg.CONF.cluster_heat.max_attempts,
'id': self.bay.stack_id,
'status': stack.stack_status})
raise loopingcall.LoopingCallDone()
else:
if self.attempts > cfg.CONF.bay_heat.max_attempts:
if self.attempts > cfg.CONF.cluster_heat.max_attempts:
LOG.error(_LE('Bay check exit after %(attempts)s attempts,'
'stack_id: %(id)s, stack_status: %(status)s') %
{'attempts': cfg.CONF.bay_heat.max_attempts,
{'attempts': cfg.CONF.cluster_heat.max_attempts,
'id': self.bay.stack_id,
'status': stack.stack_status})
raise loopingcall.LoopingCallDone()

@ -29,14 +29,14 @@ import sqlalchemy as sa
from magnum.i18n import _
bay_heat_opts = [
cluster_heat_opts = [
cfg.StrOpt('cluster_coe',
default='kubernetes',
help=_('Container Orchestration Environments are '
'kubernetes or swarm.'))
'kubernetes or swarm.'),
deprecated_group='bay_heat')
]
cfg.CONF.register_opts(bay_heat_opts, group='bay_heat')
cfg.CONF.register_opts(cluster_heat_opts, group='cluster_heat')
def upgrade():
@ -45,7 +45,8 @@ def upgrade():
baymodel = sa.sql.table('baymodel',
sa.sql.column('coe', sa.String(length=255)))
op.execute(
baymodel.update().values({
'coe': op.inline_literal(cfg.CONF.bay_heat.cluster_coe)})
'coe': op.inline_literal(cfg.CONF.cluster_heat.cluster_coe)})
)

@ -36,12 +36,14 @@ COMMON_ENV_PATH = COMMON_TEMPLATES_PATH + "environments/"
template_def_opts = [
cfg.StrOpt('etcd_discovery_service_endpoint_format',
default='https://discovery.etcd.io/new?size=%(size)d',
help=_('Url for etcd public discovery endpoint.')),
help=_('Url for etcd public discovery endpoint.'),
deprecated_group='bay'),
cfg.ListOpt('enabled_definitions',
default=['magnum_vm_atomic_k8s', 'magnum_bm_fedora_k8s',
'magnum_vm_coreos_k8s', 'magnum_vm_atomic_swarm',
'magnum_vm_ubuntu_mesos'],
help=_('Enabled bay definition entry points.')),
help=_('Enabled cluster definition entry points.'),
deprecated_group='bay'),
]
docker_registry_opts = [
@ -54,7 +56,7 @@ docker_registry_opts = [
]
CONF = cfg.CONF
CONF.register_opts(template_def_opts, group='bay')
CONF.register_opts(template_def_opts, group='cluster')
CONF.register_opts(docker_registry_opts, group='docker_registry')
CONF.import_opt('trustee_domain_id', 'magnum.common.keystone', group='trust')
@ -243,7 +245,7 @@ class TemplateDefinition(object):
coe=coe)
type_definitions = definition_map[bay_type]
for name in cfg.CONF.bay.enabled_definitions:
for name in cfg.CONF.cluster.enabled_definitions:
if name in type_definitions:
return type_definitions[name]()
@ -428,7 +430,7 @@ class BaseTemplateDefinition(TemplateDefinition):
discovery_url = bay.discovery_url
else:
discovery_endpoint = (
cfg.CONF.bay.etcd_discovery_service_endpoint_format %
cfg.CONF.cluster.etcd_discovery_service_endpoint_format %
{'size': bay.master_count})
try:
discovery_url = requests.get(discovery_endpoint).text

@ -38,7 +38,7 @@ def list_opts():
magnum.common.service.service_opts,
)),
('api', magnum.api.app.API_SERVICE_OPTS),
('bay', magnum.drivers.common.template_def.template_def_opts),
('cluster', magnum.drivers.common.template_def.template_def_opts),
('conductor', magnum.conductor.config.SERVICE_OPTS),
('database', magnum.db.sql_opts),
('docker', magnum.common.docker_utils.docker_opts),
@ -51,12 +51,13 @@ def list_opts():
('nova_client', magnum.common.clients.nova_client_opts),
('neutron_client', magnum.common.clients.neutron_client_opts),
('x509', magnum.common.x509.config.x509_opts),
('bay_heat', magnum.conductor.handlers.bay_conductor.bay_heat_opts),
('cluster_heat',
magnum.conductor.handlers.bay_conductor.cluster_heat_opts),
('certificates',
itertools.chain(magnum.common.cert_manager.cert_manager_opts,
local_cert_manager.local_cert_manager_opts,
)),
('baymodel', magnum.api.validation.baymodel_opts),
('cluster_template', magnum.api.validation.cluster_template_opts),
('keystone_auth', magnum.common.keystone.keystone_auth_opts),
('docker_registry',
magnum.drivers.common.template_def.docker_registry_opts)

@ -265,9 +265,9 @@ extendedKeyUsage = clientAuth
test_timeout = int(test_timeout)
except ValueError:
# If timeout value is invalid, set a default timeout.
test_timeout = cfg.CONF.bay_heat.bay_create_timeout
test_timeout = cfg.CONF.cluster_heat.create_timeout
if test_timeout <= 0:
test_timeout = cfg.CONF.bay_heat.bay_create_timeout
test_timeout = cfg.CONF.cluster_heat.create_timeout
self.useFixture(fixtures.Timeout(test_timeout, gentle=True))

@ -616,7 +616,7 @@ class TestPost(api_base.FunctionalTest):
mock_image_data.return_value = {'name': 'mock_name',
'os_distro': 'fedora-atomic'}
for k, v in baymodel_config_dict.items():
cfg.CONF.set_override(k, v, 'baymodel')
cfg.CONF.set_override(k, v, 'cluster_template')
with mock.patch.object(self.dbapi, 'create_baymodel',
wraps=self.dbapi.create_baymodel) as cc_mock:
bdict = apiutils.baymodel_post_data(**baymodel_dict)
@ -628,7 +628,7 @@ class TestPost(api_base.FunctionalTest):
expected_driver = bdict.get('network_driver')
if not expected_driver:
expected_driver = (
cfg.CONF.baymodel.swarm_default_network_driver)
cfg.CONF.cluster_template.swarm_default_network_driver)
self.assertEqual(expected_driver,
response.json['network_driver'])
self.assertEqual(bdict['image_id'],

@ -647,7 +647,7 @@ class TestPost(api_base.FunctionalTest):
mock_image_data.return_value = {'name': 'mock_name',
'os_distro': 'fedora-atomic'}
for k, v in cluster_template_config_dict.items():
cfg.CONF.set_override(k, v, 'baymodel')
cfg.CONF.set_override(k, v, 'cluster_template')
with mock.patch.object(self.dbapi, 'create_baymodel',
wraps=self.dbapi.create_baymodel) as cc_mock:
bdict = apiutils.cluster_template_post_data(
@ -660,7 +660,7 @@ class TestPost(api_base.FunctionalTest):
expected_driver = bdict.get('network_driver')
if not expected_driver:
expected_driver = (
cfg.CONF.baymodel.swarm_default_network_driver)
cfg.CONF.cluster_template.swarm_default_network_driver)
self.assertEqual(expected_driver,
response.json['network_driver'])
self.assertEqual(bdict['image_id'],

@ -182,9 +182,9 @@ class TestValidation(base.BaseTestCase):
pass
for key, val in network_driver_config_dict.items():
cfg.CONF.set_override(key, val, 'baymodel')
cfg.CONF.set_override(key, val, 'cluster_template')
baymodel = mock.MagicMock()
baymodel.name = 'test_baymodel'
baymodel.name = 'test_cluster_template'
baymodel.network_driver = network_driver_type
baymodel.coe = coe
@ -269,7 +269,7 @@ class TestValidation(base.BaseTestCase):
pass
for key, val in network_driver_config_dict.items():
cfg.CONF.set_override(key, val, 'baymodel')
cfg.CONF.set_override(key, val, 'cluster_template')
baymodel_ident = 'test_uuid_or_name'
patch = [{'path': '/network_driver', 'value': network_driver_type,
'op': 'replace'}]

@ -492,7 +492,7 @@ class TestHeatPoller(base.TestCase):
@patch('magnum.common.clients.OpenStackClients')
def setup_poll_test(self, mock_openstack_client, cfg,
mock_retrieve_baymodel):
cfg.CONF.bay_heat.max_attempts = 10
cfg.CONF.cluster_heat.max_attempts = 10
bay = mock.MagicMock()
baymodel_dict = utils.get_test_baymodel(coe='kubernetes')
mock_heat_stack = mock.MagicMock()
@ -663,14 +663,14 @@ class TestHeatPoller(base.TestCase):
mock_heat_stack, bay, poller = self.setup_poll_test()
mock_heat_stack.stack_status = bay_status.DELETE_IN_PROGRESS
poller.attempts = cfg.CONF.bay_heat.max_attempts
poller.attempts = cfg.CONF.cluster_heat.max_attempts
self.assertRaises(loopingcall.LoopingCallDone, poller.poll_and_check)
def test_poll_create_in_prog_max_att_reached_no_timeout(self):
mock_heat_stack, bay, poller = self.setup_poll_test()
mock_heat_stack.stack_status = bay_status.CREATE_IN_PROGRESS
poller.attempts = cfg.CONF.bay_heat.max_attempts
poller.attempts = cfg.CONF.cluster_heat.max_attempts
mock_heat_stack.timeout_mins = None
self.assertRaises(loopingcall.LoopingCallDone, poller.poll_and_check)
@ -678,7 +678,7 @@ class TestHeatPoller(base.TestCase):
mock_heat_stack, bay, poller = self.setup_poll_test()
mock_heat_stack.stack_status = bay_status.CREATE_IN_PROGRESS
poller.attempts = cfg.CONF.bay_heat.max_attempts
poller.attempts = cfg.CONF.cluster_heat.max_attempts
mock_heat_stack.timeout_mins = 60
# since the timeout is set the max attempts gets ignored since
# the timeout will eventually stop the poller either when
@ -689,7 +689,7 @@ class TestHeatPoller(base.TestCase):
mock_heat_stack, bay, poller = self.setup_poll_test()
mock_heat_stack.stack_status = bay_status.CREATE_FAILED
poller.attempts = cfg.CONF.bay_heat.max_attempts
poller.attempts = cfg.CONF.cluster_heat.max_attempts
mock_heat_stack.timeout_mins = 60
self.assertRaises(loopingcall.LoopingCallDone, poller.poll_and_check)

@ -480,7 +480,7 @@ class TestBayConductorWithK8s(base.TestCase):
cfg.CONF.set_override('etcd_discovery_service_endpoint_format',
'http://etcd/test?size=%(size)d',
group='bay')
group='cluster')
mock_req = mock.MagicMock(text='https://address/token')
reqget.return_value = mock_req
@ -585,7 +585,7 @@ class TestBayConductorWithK8s(base.TestCase):
expected_stack_name = 'expected_stack_name-xx-xx-xx-xx'
expected_template_contents = 'template_contents'
dummy_bay_name = 'expected_stack_name'
expected_timeout = cfg.CONF.bay_heat.bay_create_timeout
expected_timeout = cfg.CONF.cluster_heat.create_timeout
mock_tpl_files = {}
mock_get_template_contents.return_value = [
@ -626,7 +626,7 @@ class TestBayConductorWithK8s(base.TestCase):
expected_template_contents = 'template_contents'
dummy_bay_name = 'expected_stack_name'
bay_timeout = 0
expected_timeout = cfg.CONF.bay_heat.bay_create_timeout
expected_timeout = cfg.CONF.cluster_heat.create_timeout
mock_tpl_files = {}
mock_get_template_contents.return_value = [

@ -275,7 +275,7 @@ class TestBayConductorWithMesos(base.TestCase):
@patch('magnum.common.clients.OpenStackClients')
def setup_poll_test(self, mock_openstack_client, cfg,
mock_retrieve_baymodel):
cfg.CONF.bay_heat.max_attempts = 10
cfg.CONF.cluster_heat.max_attempts = 10
bay = mock.MagicMock()
mock_heat_stack = mock.MagicMock()
mock_heat_client = mock.MagicMock()

@ -371,7 +371,7 @@ class TestBayConductorWithSwarm(base.TestCase):
@patch('magnum.common.clients.OpenStackClients')
def setup_poll_test(self, mock_openstack_client, cfg,
mock_retrieve_baymodel):
cfg.CONF.bay_heat.max_attempts = 10
cfg.CONF.cluster_heat.max_attempts = 10
bay = mock.MagicMock()
mock_heat_stack = mock.MagicMock()
mock_heat_client = mock.MagicMock()

@ -111,7 +111,7 @@ class TemplateDefinitionTestCase(base.TestCase):
def test_get_definition_not_enabled(self):
cfg.CONF.set_override('enabled_definitions',
['magnum_vm_atomic_k8s'],
group='bay')
group='cluster')
self.assertRaises(exception.BayTypeNotEnabled,
cmn_tdef.TemplateDefinition.get_template_definition,
'vm', 'coreos', 'kubernetes')
@ -385,7 +385,7 @@ class AtomicK8sTemplateDefinitionTestCase(BaseTemplateDefinitionTestCase):
def test_k8s_get_discovery_url(self, mock_get):
cfg.CONF.set_override('etcd_discovery_service_endpoint_format',
'http://etcd/test?size=%(size)d',
group='bay')
group='cluster')
expected_discovery_url = 'http://etcd/token'
mock_resp = mock.MagicMock()
mock_resp.text = expected_discovery_url
@ -405,7 +405,7 @@ class AtomicK8sTemplateDefinitionTestCase(BaseTemplateDefinitionTestCase):
def test_k8s_get_discovery_url_fail(self, mock_get):
cfg.CONF.set_override('etcd_discovery_service_endpoint_format',
'http://etcd/test?size=%(size)d',
group='bay')
group='cluster')
mock_get.side_effect = req_exceptions.RequestException()
mock_bay = mock.MagicMock()
mock_bay.master_count = 10
@ -778,7 +778,7 @@ class AtomicSwarmTemplateDefinitionTestCase(base.TestCase):
def test_swarm_get_discovery_url(self, mock_get):
cfg.CONF.set_override('etcd_discovery_service_endpoint_format',
'http://etcd/test?size=%(size)d',
group='bay')
group='cluster')
expected_discovery_url = 'http://etcd/token'
mock_resp = mock.MagicMock()
mock_resp.text = expected_discovery_url

@ -0,0 +1,26 @@
---
prelude: >
Magnum's bay-to-cluster blueprint [1] required
changes across much of its codebase to align to
industry standards.
To support this blueprint, certain group and option
names were changed in configuration files [2].
See the deprecations section for more details.
[1] https://review.openstack.org/#/q/topic:bp/rename-bay-to-cluster
[2] https://review.openstack.org/#/c/362660/
deprecations:
- The 'bay' group has been renamed to 'cluster' and all
options in the former 'bay' group have been moved to
'cluster'.
- The 'bay_heat' group has been renamed to 'cluster_heat'
and all options in the former 'bay_heat' group have been
moved to 'cluster_heat'.
- The 'bay_create_timeout' option in the former 'bay_heat'
group has been renamed to 'create_timeout' inside the
'cluster_heat' group.
- The 'baymodel' group has been renamed to 'cluster_template'
and all options in the former 'baymodel' group have been
moved to 'cluster_template'.
Loading…
Cancel
Save