diff --git a/doc/source/user/index.rst b/doc/source/user/index.rst index aeba2a867a..4e804bf52f 100644 --- a/doc/source/user/index.rst +++ b/doc/source/user/index.rst @@ -1391,7 +1391,8 @@ _`cinder_csi_enabled` When 'true', out-of-tree Cinder CSI driver will be enabled. Requires 'cinder' to be selected as a 'volume_driver' and consequently also requires label 'cloud_provider_enabled' to be 'true' (see 'cloud_provider_enabled' section). - Default: false + Ussuri default: false + Victoria default: true _`cinder_csi_plugin_tag` This label allows users to override the default cinder-csi-plugin container diff --git a/magnum/api/controllers/v1/cluster.py b/magnum/api/controllers/v1/cluster.py index 0ac2ebe60c..6caf99ad25 100755 --- a/magnum/api/controllers/v1/cluster.py +++ b/magnum/api/controllers/v1/cluster.py @@ -16,9 +16,11 @@ import uuid from oslo_log import log as logging +from oslo_utils import strutils from oslo_utils import timeutils import pecan import six +import warnings import wsme from wsme import types as wtypes @@ -325,6 +327,12 @@ class ClustersController(base.Controller): 'detail': ['GET'], } + _in_tree_cinder_volume_driver_deprecation_note = ( + "The in-tree Cinder volume driver is deprecated and will be removed " + "in X cycle in favour of out-of-tree Cinder CSI driver which requires " + "the label cinder_csi_enabled set to True (default behaviour from " + "V cycle) when volume_driver is cinder.") + actions = cluster_actions.ActionsController() def _generate_name_for_cluster(self, context): @@ -498,7 +506,7 @@ class ClustersController(base.Controller): cluster.keypair = cluster_template.keypair_id # If labels is not present, use cluster_template value - if cluster.labels == wtypes.Unset: + if cluster.labels == wtypes.Unset or not cluster.labels: cluster.labels = cluster_template.labels else: # If labels are provided check if the user wishes to merge @@ -508,6 +516,13 @@ class ClustersController(base.Controller): labels.update(cluster.labels) cluster.labels = labels + cinder_csi_enabled = cluster.labels.get('cinder_csi_enabled', True) + if (cluster_template.volume_driver == 'cinder' and + not strutils.bool_from_string(cinder_csi_enabled)): + warnings.warn(self._in_tree_cinder_volume_driver_deprecation_note, + DeprecationWarning) + LOG.warning(self._in_tree_cinder_volume_driver_deprecation_note) + # If floating_ip_enabled is not present, use cluster_template value if cluster.floating_ip_enabled == wtypes.Unset: cluster.floating_ip_enabled = cluster_template.floating_ip_enabled diff --git a/magnum/api/controllers/v1/cluster_template.py b/magnum/api/controllers/v1/cluster_template.py index 480b8fb705..475112d75c 100644 --- a/magnum/api/controllers/v1/cluster_template.py +++ b/magnum/api/controllers/v1/cluster_template.py @@ -16,6 +16,7 @@ from oslo_log import log as logging from oslo_utils import timeutils import pecan import six +import warnings import wsme from wsme import types as wtypes @@ -255,7 +256,7 @@ class ClusterTemplatesController(base.Controller): 'detail': ['GET'], } - _devicemapper_overlay_deprecation = ( + _devicemapper_overlay_deprecation_note = ( "The devicemapper and overlay storage " "drivers are deprecated in favor of overlay2 in docker, and will be " "removed in a future release from docker. Users of the devicemapper " @@ -411,9 +412,11 @@ class ClusterTemplatesController(base.Controller): do_raise=False): raise exception.ClusterTemplatePublishDenied() - if (cluster_template_dict.get('docker_storage_driver') - in ('devicemapper', 'overlay')): - LOG.warning(self._devicemapper_overlay_deprecation) + if (cluster_template.docker_storage_driver in ('devicemapper', + 'overlay')): + warnings.warn(self._devicemapper_overlay_deprecation_note, + DeprecationWarning) + LOG.warning(self._devicemapper_overlay_deprecation_note) # NOTE(yuywz): We will generate a random human-readable name for # cluster_template if the name is not specified by user. @@ -484,7 +487,9 @@ class ClusterTemplatesController(base.Controller): if (cluster_template.docker_storage_driver in ('devicemapper', 'overlay')): - LOG.warning(self._devicemapper_overlay_deprecation) + warnings.warn(self._devicemapper_overlay_deprecation_note, + DeprecationWarning) + LOG.warning(self._devicemapper_overlay_deprecation_note) cluster_template.save() return ClusterTemplate.convert_with_links(cluster_template) diff --git a/magnum/drivers/k8s_fedora_atomic_v1/templates/kubecluster.yaml b/magnum/drivers/k8s_fedora_atomic_v1/templates/kubecluster.yaml index 08772f388a..b2b0ddfbf0 100644 --- a/magnum/drivers/k8s_fedora_atomic_v1/templates/kubecluster.yaml +++ b/magnum/drivers/k8s_fedora_atomic_v1/templates/kubecluster.yaml @@ -769,7 +769,7 @@ parameters: description: > true if the cinder csi feature should be enabled default: - false + true cinder_csi_plugin_tag: type: string diff --git a/magnum/drivers/k8s_fedora_coreos_v1/templates/kubecluster.yaml b/magnum/drivers/k8s_fedora_coreos_v1/templates/kubecluster.yaml index 048af9855c..9c36d224e2 100644 --- a/magnum/drivers/k8s_fedora_coreos_v1/templates/kubecluster.yaml +++ b/magnum/drivers/k8s_fedora_coreos_v1/templates/kubecluster.yaml @@ -781,7 +781,7 @@ parameters: description: > true if the cinder csi feature should be enabled default: - false + true cinder_csi_plugin_tag: type: string diff --git a/magnum/tests/unit/api/controllers/v1/test_cluster.py b/magnum/tests/unit/api/controllers/v1/test_cluster.py index c8f8f57374..d6c8fa642b 100644 --- a/magnum/tests/unit/api/controllers/v1/test_cluster.py +++ b/magnum/tests/unit/api/controllers/v1/test_cluster.py @@ -929,6 +929,17 @@ class TestPost(api_base.FunctionalTest): # Verify flavor_id from ClusterTemplate is used self.assertEqual('m1.small', cluster[0].flavor_id) + def test_create_cluster_with_cinder_csi_disabled(self): + self.cluster_template.volume_driver = 'cinder' + self.cluster_template.save() + cluster_labels = {'cinder_csi_enabled': 'false'} + bdict = apiutils.cluster_post_data(labels=cluster_labels) + note = 'in-tree Cinder volume driver is deprecated' + with self.assertWarnsRegex(DeprecationWarning, note): + response = self.post_json('/clusters', bdict) + self.assertEqual('application/json', response.content_type) + self.assertEqual(202, response.status_int) + def test_create_cluster_without_merge_labels(self): self.cluster_template.labels = {'label1': 'value1', 'label2': 'value2'} self.cluster_template.save() diff --git a/magnum/tests/unit/api/controllers/v1/test_cluster_template.py b/magnum/tests/unit/api/controllers/v1/test_cluster_template.py index 848d669ccc..c7511e0186 100644 --- a/magnum/tests/unit/api/controllers/v1/test_cluster_template.py +++ b/magnum/tests/unit/api/controllers/v1/test_cluster_template.py @@ -390,6 +390,18 @@ class TestPatch(api_base.FunctionalTest): self.cluster_template.uuid) self.assertEqual(response['hidden'], True) + def test_update_cluster_template_with_devicemapper(self): + cluster_template = obj_utils.create_test_cluster_template(self.context) + note = 'deprecated in favor of overlay2' + with self.assertWarnsRegex(DeprecationWarning, note): + response = self.patch_json('/clustertemplates/%s' % + cluster_template.uuid, + [{'path': '/docker_storage_driver', + 'value': 'devicemapper', + 'op': 'replace'}], + expect_errors=True) + self.assertEqual(200, response.status_int) + def test_update_cluster_template_replace_labels_success(self): cluster_template = obj_utils.create_test_cluster_template(self.context) response = self.patch_json('/clustertemplates/%s' % @@ -773,7 +785,9 @@ class TestPost(api_base.FunctionalTest): 'os_distro': 'fedora-atomic'} bdict = apiutils.cluster_template_post_data( docker_volume_size=1, docker_storage_driver="overlay") - response = self.post_json('/clustertemplates', bdict) + note = 'deprecated in favor of overlay2' + with self.assertWarnsRegex(DeprecationWarning, note): + response = self.post_json('/clustertemplates', bdict) self.assertEqual(bdict['docker_volume_size'], response.json['docker_volume_size']) cc_mock.assert_called_once_with(mock.ANY) diff --git a/releasenotes/notes/deprecate-in-tree-cinder-c781a5c160d45ab6.yaml b/releasenotes/notes/deprecate-in-tree-cinder-c781a5c160d45ab6.yaml new file mode 100644 index 0000000000..100e66e44c --- /dev/null +++ b/releasenotes/notes/deprecate-in-tree-cinder-c781a5c160d45ab6.yaml @@ -0,0 +1,8 @@ +--- +upgrade: + - | + Label cinder_csi_enabled defaults to True from V cycle. +deprecations: + - | + Deprecate in-tree Cinder volume driver for removal in X cycle in favour of + out-of-tree Cinder CSI plugin.