yahoo-eng-team team mailing list archive
-
yahoo-eng-team team
-
Mailing list archive
-
Message #84753
[Bug 1889431] Re: [RFE] Add local-ip-prefix to Neutron metering label rules
** Changed in: neutron
Status: In Progress => Fix Released
--
You received this bug notification because you are a member of Yahoo!
Engineering Team, which is subscribed to neutron.
https://bugs.launchpad.net/bugs/1889431
Title:
[RFE] Add local-ip-prefix to Neutron metering label rules
Status in neutron:
Fix Released
Bug description:
Problem Description
=================
Neutron metering label rules have a parameter called "remote-ip-prefix", which would allow operators to filter traffic based on the remote IP address. However, since [1], its meaning was changed to the exact opposite, which makes a bit of confusion. Instead of matching on the remote prefix (towards the external interface), it matches the local prefix (towards the OS tenant network).
Ideally, to satisfy the use case presented in [1] (which was achieved
by inverting the use of "remote-ip-prefix"), operators should be able
to create rules based on local-ip-prefix and remote-ip-prefix.
[1]
https://opendev.org/openstack/neutron/commit/92db1d4a2c49b1f675b6a9552a8cc5a417973b64
Proposed Change
===============
Therefore, we propose to introduce a new parameter in the Neutron metering rule API. This new parameter would be called "local_ip_prefix", representing the local IP of the traffic.
This change would also introduce a change in behavior of the
"remote_ip_prefix", which would start to match the remote IP, instead
of the local IP as it is doing since [1].
The "remote_ip_prefix" and "local_ip_prefix" could be used together,
or only one of them can be defined. However, a metering rule must
always have at least one of them (local_ip_prefix or remote_ip_prefix)
defined.
## API JSON
Current JSON for "v2.0/metering/metering-label-rules" endpoint:
{
"remote_ip_prefix": "0.0.0.0/0",
"direction": "egress",
"metering_label_id": "9ffd6512-9d2a-4dd2-9657-6a605126264d",
"id": "f1694467-d866-4d8e-a8dc-18da516caedc",
"excluded": false
}
Adding new attributes :
{
"remote_ip_prefix": "0.0.0.0/0",
"local_ip_prefix": "192.168.0.14/32",
"direction": "egress",
"metering_label_id": "9ffd6512-9d2a-4dd2-9657-6a605126264d",
"id": "f1694467-d866-4d8e-a8dc-18da516caedc",
"excluded": false
}
## Database table changes
Currently, the table "meteringlabelrules" is defined as:
+-------------------+--------------------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+-------------------+--------------------------+------+-----+---------+-------+
| id | varchar(36) | NO | PRI | NULL | |
| direction | enum('ingress','egress') | YES | | NULL | |
| remote_ip_prefix | varchar(64) | YES | | NULL | |
| metering_label_id | varchar(36) | NO | MUL | NULL | |
| excluded | tinyint(1) | YES | | 0 | |
+-------------------+--------------------------+------+-----+---------+-------+
We would add a new field to it. Therefore, it would look like:
+-------------------+--------------------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+-------------------+--------------------------+------+-----+---------+-------+
| id | varchar(36) | NO | PRI | NULL | |
| direction | enum('ingress','egress') | YES | | NULL | |
| remote_ip_prefix | varchar(64) | YES | | NULL | |
| local_ip_prefix | varchar(64) | YES | | NULL | |
| metering_label_id | varchar(36) | NO | MUL | NULL | |
| excluded | tinyint(1) | YES | | 0 | |
+-------------------+--------------------------+------+-----+---------+-------+
Moreover, during the upgrade process, the "remote_ip_prefix" would be
set to "local_ip_prefix", and then we would set null in the
"remote_ip_prefix" column. This is done to maintain compatibility with
the changes introduced via [1].
## Neutron Metering agent changes
The IPtables driver in the metering agent will need to handle the new parameters "local_ip_prefix" and "remote_ip_prefix" properly. When building the IPtable rules the parameter "remote_ip_prefix" (if defined) will be used with the option "-d" (IPtables option) for egress rules and "-s" (IPtables option) for ingress rules. On the other hand, the parameter "local_ip_prefix" (if defined) will be used with option "-s"(IPtables option) for egress rules, and "-d"(IPtables option) for ingress rules.
## API impacts
People using the API to configure local IP prefixes via the "remote_ip_prefix" parameter would need to start using the "local_ip_prefix" parameter.
## Validations
To simplify validations, we propose to remove the overlapping IP_prefixes validations. The rationally behind this removal is that if the operator wants to somehow create rules that overlap, we should not be the ones blocking it.
We will implement the following validation:
* The remote IP prefix must be a valid IPv4 CIDR
* The local IP prefix must be a valid IPv4 CIDR
* Each metering label rule requires at least remote or local IP prefix to be informed. One can also use both.
## Foreseen tasks
- neutron_lib
-- add new attribute in api/definitions/metering.py
-- fix JSON of examples and documentation
-- YAML of documentation
- neutron
-- Add the new DB field in objects.metering.MeteringLabelRule and neutron/db/models/metering.MeteringLabelRule
-- DB script in neutron/db/migration/alembic_migrations/versions/victoria
--- add new field nullable
--- migration to fix the legacy data
-- Change execution flow in Neutron and Neutron meteting agent to use the new field.
- OpenStack SDK
-- add the new field
- OpenStack python client
-- add the new field
To manage notifications about this bug go to:
https://bugs.launchpad.net/neutron/+bug/1889431/+subscriptions
References