Browse Source

[k8s] Deprecate in-tree Cinder

- Deprecate in-tree Cinder volume driver for removal in X cycle in
  favour of out-of-tree Cinder CSI plugin for Kubernetes.
- Set cinder_csi_enabled to True by default from V cycle.
- Add unit test for in-tree Cinder deprecation.
- Add mssing unit tests for resent docker_storage_driver deprecation.

Change-Id: I6f033049b5ff18c19866637efc8cf964272097f5
Story: 2007048
Task: 37873
changes/31/728131/8
Bharat Kunwar 2 years ago
parent
commit
3179921f0c
  1. 3
      doc/source/user/index.rst
  2. 17
      magnum/api/controllers/v1/cluster.py
  3. 15
      magnum/api/controllers/v1/cluster_template.py
  4. 2
      magnum/drivers/k8s_fedora_atomic_v1/templates/kubecluster.yaml
  5. 2
      magnum/drivers/k8s_fedora_coreos_v1/templates/kubecluster.yaml
  6. 11
      magnum/tests/unit/api/controllers/v1/test_cluster.py
  7. 16
      magnum/tests/unit/api/controllers/v1/test_cluster_template.py
  8. 8
      releasenotes/notes/deprecate-in-tree-cinder-c781a5c160d45ab6.yaml

3
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

17
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

15
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)

2
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

2
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

11
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()

16
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)

8
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.
Loading…
Cancel
Save