diff --git a/doc/source/devref/quality_of_service.rst b/doc/source/devref/quality_of_service.rst index ea10377daa4..3beb9fb61b6 100644 --- a/doc/source/devref/quality_of_service.rst +++ b/doc/source/devref/quality_of_service.rst @@ -100,12 +100,14 @@ For a list of all rule types, see: neutron.services.qos.qos_consts.VALID_RULE_TYPES. The list of supported QoS rule types exposed by neutron is calculated as -the common subset of rules supported by all active QoS drivers. +set of rules supported by at least one active QoS driver. Note: the list of supported rule types reported by core plugin is not enforced -when accessing QoS rule resources. This is mostly because then we would not be -able to create rules while at least one of the QoS driver in gate lacks -support for the rules we're trying to test. +when accessing QoS rule resources. + +When a policy is attached to a port or a network, or when a rule is created or updated, +core plugins may validate write requests against their backends, and invalidate requests +that don't make sense or can't be implemented by affected backends. Database models diff --git a/neutron/services/qos/drivers/manager.py b/neutron/services/qos/drivers/manager.py index c33465ba9ad..8b4d40e8387 100644 --- a/neutron/services/qos/drivers/manager.py +++ b/neutron/services/qos/drivers/manager.py @@ -137,20 +137,14 @@ class QosServiceDriverManager(object): if not self._drivers: return [] - rule_types = set(qos_consts.VALID_RULE_TYPES) + rule_types = set() # Recalculate on every call to allow drivers determine supported rule # types dynamically for driver in self._drivers: - new_rule_types = rule_types & set(driver.supported_rules) - dropped_rule_types = rule_types - new_rule_types - if dropped_rule_types: - LOG.debug("%(rule_types)s rule types disabled " - "because enabled %(driver)s does not support them", - {'rule_types': ', '.join(dropped_rule_types), - 'driver': driver.name}) - rule_types = new_rule_types + rule_types |= set(driver.supported_rules) LOG.debug("Supported QoS rule types " - "(common subset for all loaded QoS drivers): %s", rule_types) + "(rules supported by at least one loaded QoS driver): %s", + rule_types) return rule_types diff --git a/neutron/tests/unit/services/qos/drivers/test_manager.py b/neutron/tests/unit/services/qos/drivers/test_manager.py index 58d84da7a1b..f0acec6d8e2 100644 --- a/neutron/tests/unit/services/qos/drivers/test_manager.py +++ b/neutron/tests/unit/services/qos/drivers/test_manager.py @@ -143,7 +143,7 @@ class TestQoSDriversRulesValidations(TestQosDriversManagerBase): class TestQosDriversManagerRules(TestQosDriversManagerBase): """Test supported rules""" - def test_available_rules_one_in_common(self): + def test_available_rules(self): driver_manager = self._create_manager_with_drivers({ 'driver-A': { 'is_loaded': True, @@ -175,32 +175,6 @@ class TestQosDriversManagerRules(TestQosDriversManagerBase): } }) self.assertEqual(driver_manager.supported_rule_types, - set([qos_consts.RULE_TYPE_MINIMUM_BANDWIDTH])) - - def test_available_rules_no_rule_in_common(self): - driver_manager = self._create_manager_with_drivers({ - 'driver-A': { - 'is_loaded': True, - 'rules': { - qos_consts.RULE_TYPE_BANDWIDTH_LIMIT: { - "max_kbps": {'type:values': None}, - "max_burst_kbps": {'type:values': None} - } - } - }, - 'driver-B': { - 'is_loaded': True, - 'rules': { - qos_consts.RULE_TYPE_MINIMUM_BANDWIDTH: { - "min_kbps": {'type:values': None}, - 'direction': { - 'type:values': constants.VALID_DIRECTIONS} - }, - qos_consts.RULE_TYPE_DSCP_MARKING: { - "dscp_mark": { - 'type:values': constants.VALID_DSCP_MARKS} - } - } - } - }) - self.assertEqual(driver_manager.supported_rule_types, set([])) + set([qos_consts.RULE_TYPE_BANDWIDTH_LIMIT, + qos_consts.RULE_TYPE_MINIMUM_BANDWIDTH, + qos_consts.RULE_TYPE_DSCP_MARKING])) diff --git a/releasenotes/notes/qos-change-list-of-available-rule-types-5ddbc827606c293d.yaml b/releasenotes/notes/qos-change-list-of-available-rule-types-5ddbc827606c293d.yaml new file mode 100644 index 00000000000..efcd56a4f58 --- /dev/null +++ b/releasenotes/notes/qos-change-list-of-available-rule-types-5ddbc827606c293d.yaml @@ -0,0 +1,7 @@ +--- +features: + - | + With `improved validation for QoS rules + `_ + API call to /v2.0/qos/rule-types now returns rule types that are supported + by at least one of enabled backends.