From a227bf440ef47ca4c283990b0b8f35d67182e315 Mon Sep 17 00:00:00 2001 From: "Walter A. Boring IV" Date: Mon, 15 Aug 2016 12:06:56 -0700 Subject: [PATCH] Add new supported driver checks This patch adds the new mechanism for tagging drivers as supported or not as discussed in the TC mailing list post: http://lists.openstack.org/pipermail/openstack-dev/2016-August/101589.html This adds the following in place: 1) add new supported flag in every driver 2) When a driver no longer meets the Cinder community testing standards the driver supported flag will be set to False. 3) When the volume manager starts it checks to see if the driver is flagged not supported. If the supported flag is False, then the volume manager will log an error and then check to see if the driver section configuration setting of 'enable_unsupported_driver = True'. If the conf setting is not enabled, the driver will not be started. a) When the driver maintainer conforms to the community testing standards, then a follow up patch will be submitted to re-enable the supported flag. b) If the driver maintainer continues to not support the community testing standards, then the Cinder community will revisit removing the driver in the following release. c) If the driver section in cinder.conf has the enable_unsupported_driver set, then the volume manager will start the driver, but log a warning on every driver call saying the driver isn't supported and may be removed in the future. Implements: blueprint supported-drivers Change-Id: I19a60df85d5fb205fc63e700475ae20b86309c1e --- cinder/utils.py | 15 +++++++++++ cinder/volume/driver.py | 17 +++++++++++++ cinder/volume/drivers/xio.py | 2 +- cinder/volume/manager.py | 25 +++++++++++++++++++ .../supported-drivers-9c95dd2378cd308d.yaml | 3 +++ 5 files changed, 61 insertions(+), 1 deletion(-) create mode 100644 releasenotes/notes/supported-drivers-9c95dd2378cd308d.yaml diff --git a/cinder/utils.py b/cinder/utils.py index 7c33dd4a7..df41e1e96 100644 --- a/cinder/utils.py +++ b/cinder/utils.py @@ -520,6 +520,21 @@ def require_driver_initialized(driver): driver_name = driver.__class__.__name__ LOG.error(_LE("Volume driver %s not initialized"), driver_name) raise exception.DriverNotInitialized() + else: + log_unsupported_driver_warning(driver) + + +def log_unsupported_driver_warning(driver): + """Annoy the log about unsupported drivers.""" + if not driver.supported: + # Check to see if the driver is flagged as supported. + LOG.warning(_LW("Volume driver (%(driver_name)s %(version)s) is " + "currently unsupported and may be removed in the " + "next release of OpenStack. Use at your own risk."), + {'driver_name': driver.__class__.__name__, + 'version': driver.get_version()}, + resource={'type': 'driver', + 'id': driver.__class__.__name__}) def get_file_mode(path): diff --git a/cinder/volume/driver.py b/cinder/volume/driver.py index 91886fff9..100340d4e 100644 --- a/cinder/volume/driver.py +++ b/cinder/volume/driver.py @@ -265,6 +265,13 @@ volume_opts = [ help='If this is set to True, the backup_use_temp_snapshot ' 'path will be used during the backup. Otherwise, it ' 'will use backup_use_temp_volume path.'), + cfg.BoolOpt('enable_unsupported_driver', + default=False, + help="Set this to True when you want to allow an usupported " + "driver to start. Drivers that haven't maintained a " + "working CI system and testing are marked as unsupported " + "until CI is working again. This also marks a driver as " + "deprecated and may be removed in the next release."), ] # for backward compatibility @@ -356,6 +363,12 @@ class BaseVD(object): # set True by manager after successful check_for_setup self._initialized = False + # If a driver hasn't maintained their CI system, this will get + # set to False, which prevents the driver from starting. + # Add enable_unsupported_driver = True inn cinder.conf to get + # the unsupported driver started. + self._supported = True + def _driver_data_namespace(self): namespace = self.__class__.__name__ if self.configuration: @@ -480,6 +493,10 @@ class BaseVD(object): def initialized(self): return self._initialized + @property + def supported(self): + return self._supported + def set_throttle(self): bps_limit = ((self.configuration and self.configuration.safe_get('volume_copy_bps_limit')) or diff --git a/cinder/volume/drivers/xio.py b/cinder/volume/drivers/xio.py index 407704b98..be46071f7 100644 --- a/cinder/volume/drivers/xio.py +++ b/cinder/volume/drivers/xio.py @@ -62,7 +62,7 @@ def RaiseXIODriverException(): raise exception.XIODriverException() -class XIOISEDriver(object): +class XIOISEDriver(driver.VolumeDriver): VERSION = '1.1.4' diff --git a/cinder/volume/manager.py b/cinder/volume/manager.py index b02c88c48..aecdab020 100644 --- a/cinder/volume/manager.py +++ b/cinder/volume/manager.py @@ -375,6 +375,17 @@ class VolumeManager(manager.SchedulerDependentManager): def init_host(self, added_to_cluster=None): """Perform any required initialization.""" ctxt = context.get_admin_context() + if not self.driver.supported: + utils.log_unsupported_driver_warning(self.driver) + + if not self.configuration.enable_unsupported_driver: + LOG.error(_LE("Unsupported drivers are disabled." + " You can re-enable by adding " + "enable_unsupported_driver=True to the " + "driver section in cinder.conf"), + resource={'type': 'driver', + 'id': self.__class__.__name__}) + return # If we have just added this host to a cluster we have to include all # our resources in that cluster. @@ -485,6 +496,17 @@ class VolumeManager(manager.SchedulerDependentManager): {'driver_name': self.driver.__class__.__name__, 'version': self.driver.get_version()}) + try: + # Make sure the driver is initialized first + utils.log_unsupported_driver_warning(self.driver) + utils.require_driver_initialized(self.driver) + except exception.DriverNotInitialized: + LOG.error(_LE("Cannot complete RPC initialization because " + "driver isn't initialized properly."), + resource={'type': 'driver', + 'id': self.driver.__class__.__name__}) + return + stats = self.driver.get_volume_stats(refresh=True) svc_host = vol_utils.extract_host(self.host, 'backend') try: @@ -522,6 +544,9 @@ class VolumeManager(manager.SchedulerDependentManager): filter_properties=None, allow_reschedule=True, volume=None): """Creates the volume.""" + # Log about unsupported drivers + utils.log_unsupported_driver_warning(self.driver) + # FIXME(dulek): Remove this in v3.0 of RPC API. if volume is None: # For older clients, mimic the old behavior and look up the volume diff --git a/releasenotes/notes/supported-drivers-9c95dd2378cd308d.yaml b/releasenotes/notes/supported-drivers-9c95dd2378cd308d.yaml new file mode 100644 index 000000000..b11c2c9de --- /dev/null +++ b/releasenotes/notes/supported-drivers-9c95dd2378cd308d.yaml @@ -0,0 +1,3 @@ +--- +features: + - Added supported driver checks on all drivers.