Quality of Service advanced service is designed as a service plugin. The service is decoupled from the rest of Neutron code on multiple levels (see below).
QoS extends core resources (ports, networks) without using mixins inherited from plugins but through an ml2 extension driver.
Details about the DB models, API extension, and use cases can be found here: qos spec .
Any plugin or Ml2 mechanism driver can claim support for some QoS rule types by providing a plugin/driver class property called ‘supported_qos_rule_types’ that should return a list of strings that correspond to QoS rule types (for the list of all rule types, see: neutron.extensions.qos.VALID_RULE_TYPES).
In the most simple case, the property can be represented by a simple Python list defined on the class.
For Ml2 plugin, the list of supported QoS rule types is defined as a common subset of rules supported by all active mechanism drivers.
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 any rules while at least one ml2 driver in gate lacks support for QoS (at the moment of writing, linuxbridge is such a driver).
QoS design defines the following two conceptual resources to apply QoS rules for a port or a network:
Each QoS policy contains zero or more QoS rules. A policy is then applied to a network or a port, making all rules of the policy applied to the corresponding Neutron resource.
When applied through a network association, policy rules could apply or not to neutron internal ports (like router, dhcp, load balancer, etc..). The QosRule base object provides a default should_apply_to_port method which could be overridden. In the future we may want to have a flag in QoSNetworkPolicyBinding or QosRule to enforce such type of application (for example when limiting all the ingress of routers devices on an external network automatically).
From database point of view, following objects are defined in schema:
All database models are defined under:
There is a long history of passing database dictionaries directly into business logic of Neutron. This path is not the one we wanted to take for QoS effort, so we’ve also introduced a new objects middleware to encapsulate the database logic from the rest of the Neutron code that works with QoS resources. For this, we’ve adopted oslo.versionedobjects library and introduced a new NeutronObject class that is a base for all other objects that will belong to the middle layer. There is an expectation that Neutron will evolve into using objects for all resources it handles, though that part was obviously out of scope for the QoS effort.
Every NeutronObject supports the following operations:
Base object class is defined in:
For QoS, new neutron objects were implemented:
Those are defined in:
For QosPolicy neutron object, the following public methods were implemented:
In addition to the fields that belong to QoS policy database object itself, synthetic fields were added to the object that represent lists of rules that belong to the policy. To get a list of all rules for a specific policy, a consumer of the object can just access the corresponding attribute via:
Implementation is done in a way that will allow adding a new rule list field with little or no modifications in the policy object itself. This is achieved by smart introspection of existing available rule object definitions and automatic definition of those fields on the policy class.
Note that rules are loaded in a non lazy way, meaning they are all fetched from the database on policy fetch.
For Qos<type>Rule objects, an extendable approach was taken to allow easy addition of objects for new rule types. To accomodate this, fields common to all types are put into a base class called QosRule that is then inherited into type-specific rule implementations that, ideally, only define additional fields and some other minor things.
Note that the QosRule base class is not registered with oslo.versionedobjects registry, because it’s not expected that ‘generic’ rules should be instantiated (and to suggest just that, the base rule class is marked as ABC).
QoS objects rely on some primitive database API functions that are added in:
Details on RPC communication implemented in reference backend driver are discussed in a separate page.
One thing that should be mentioned here explicitly is that RPC callback endpoints communicate using real versioned objects (as defined by serialization for oslo.versionedobjects library), not vague json dictionaries. Meaning, oslo.versionedobjects are on the wire and not just used internally inside a component.
One more thing to note is that though RPC interface relies on versioned objects, it does not yet rely on versioning features the oslo.versionedobjects library provides. This is because Liberty is the first release where we start using the RPC interface, so we have no way to get different versions in a cluster. That said, the versioning strategy for QoS is thought through and described in the separate page.
There is expectation that after RPC callbacks are introduced in Neutron, we will be able to migrate propagation from server to agents for other resources (f.e. security groups) to the new mechanism. This will need to wait until those resources get proper NeutronObject implementations.
The flow of updates is as follows:
To ease code reusability between agents and to avoid the need to patch an agent for each new core resource extension, pluggable L2 agent extensions were introduced. They can be especially interesting to third parties that don’t want to maintain their code in Neutron tree.
Extensions are meant to receive handle_port events, and do whatever they need with them.
At the moment, QoS is supported by Open vSwitch and SR-IOV ml2 drivers.
Each agent backend defines a QoS driver that implements the QosAgentDriver interface:
Open vSwitch implementation relies on the new ovs_lib OVSBridge functions:
An egress bandwidth limit is effectively configured on the port by setting the port Interface parameters ingress_policing_rate and ingress_policing_burst.
That approach is less flexible than linux-htb, Queues and OvS QoS profiles, which we may explore in the future, but which will need to be used in combination with openflow rules.
SR-IOV bandwidth limit implementation relies on the new pci_lib function:
As the name of the function suggests, the limit is applied on a Virtual Function (VF).
ip link interface has the following limitation for bandwidth limit: it uses Mbps as units of bandwidth measurement, not kbps, and does not support float numbers. So in case the limit is set to something less than 1000 kbps, it’s set to 1 Mbps only. If the limit is set to something that does not divide to 1000 kbps chunks, then the effective limit is rounded to the nearest integer Mbps value.
To enable the service, the following steps should be followed:
On server side:
On agent side (OVS):
All the code added or extended as part of the effort got reasonable unit test coverage.
Base unit test classes to validate neutron objects were implemented in a way that allows code reuse when introducing a new object type.
There are two test classes that are utilized for that:
Every new object implemented on top of one of those classes is expected to either inherit existing test cases as is, or reimplement it, if it makes sense in terms of how those objects are implemented. Specific test classes can obviously extend the set of test cases as they see needed (f.e. you need to define new test cases for those additional methods that you may add to your object implementations on top of base semantics common to all neutron objects).
Additions to ovs_lib to set bandwidth limits on ports are covered in:
API tests for basic CRUD operations for ports, networks, policies, and rules were added in: