Add new indexes to RBAC DB models
Added two new indexes to all RBAC DB models: "target_tenant" and
"action".
The DB models affected are "networkrbacs", "qospolicyrbacs",
"securitygrouprbacs", "addressscoperbacs", "subnetpoolrbacs" and
"addressgrouprbacs".
The goal of this patch is to speed up the model query if RBAC apply to
this object. If the object query scope is a project, [1] will be added
to the DB query. If "action" and "target_tenant" are indexed, the exact
match filtering will be faster.
[1]890d62a3df/neutron_lib/db/model_query.py (L123-L131)
Change-Id: I0a70a1a500fad52ca55006d6e2ebc1044aef0fc8
Closes-Bug: #1918145
This commit is contained in:
@@ -1 +1 @@
|
|||||||
c181bb1d89e4
|
ba859d649675
|
||||||
|
@@ -0,0 +1,41 @@
|
|||||||
|
# Copyright 2021 OpenStack Foundation
|
||||||
|
#
|
||||||
|
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||||
|
# not use this file except in compliance with the License. You may obtain
|
||||||
|
# a copy of the License at
|
||||||
|
#
|
||||||
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
#
|
||||||
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
|
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||||
|
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||||
|
# License for the specific language governing permissions and limitations
|
||||||
|
# under the License.
|
||||||
|
#
|
||||||
|
|
||||||
|
from alembic import op
|
||||||
|
|
||||||
|
|
||||||
|
"""Add indexes to RBACs
|
||||||
|
|
||||||
|
Revision ID: ba859d649675
|
||||||
|
Revises: c181bb1d89e4
|
||||||
|
Create Date: 2021-09-20 15:22:04.668376
|
||||||
|
|
||||||
|
"""
|
||||||
|
|
||||||
|
# revision identifiers, used by Alembic.
|
||||||
|
revision = 'ba859d649675'
|
||||||
|
down_revision = 'c181bb1d89e4'
|
||||||
|
|
||||||
|
OBJECTS = ('network', 'qospolicy', 'securitygroup', 'addressscope',
|
||||||
|
'subnetpool', 'addressgroup')
|
||||||
|
COLUMNS = ('target_tenant', 'action')
|
||||||
|
|
||||||
|
|
||||||
|
def upgrade():
|
||||||
|
for object in OBJECTS:
|
||||||
|
table = object + 'rbacs'
|
||||||
|
ix = 'ix_' + table + '_'
|
||||||
|
for column in COLUMNS:
|
||||||
|
op.create_index(op.f(ix + column), table, [column], unique=False)
|
@@ -47,9 +47,9 @@ class RBACColumns(model_base.HasId, model_base.HasProject):
|
|||||||
# also be a wildcard '*' to indicate all tenants or it may be a role if
|
# also be a wildcard '*' to indicate all tenants or it may be a role if
|
||||||
# neutron gets better integration with keystone
|
# neutron gets better integration with keystone
|
||||||
target_tenant = sa.Column(sa.String(db_const.PROJECT_ID_FIELD_SIZE),
|
target_tenant = sa.Column(sa.String(db_const.PROJECT_ID_FIELD_SIZE),
|
||||||
nullable=False)
|
nullable=False, index=True)
|
||||||
|
|
||||||
action = sa.Column(sa.String(255), nullable=False)
|
action = sa.Column(sa.String(255), nullable=False, index=True)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
@abc.abstractmethod
|
@abc.abstractmethod
|
||||||
|
Reference in New Issue
Block a user