Browse Source
This patch adds support for groups in the Hash Ring mechanism. Prior to this patch there was an assumption that all members of the ring were able to handle the same events but, once we start expanding the use of the hash ring on different parts of the code such as the Octavia driver, that assumption is not true anymore because they have their own events. With the group mechanism, multiple groups can be created (resulting in a separated hash ring for each group) that way we can group workers based on the events they are able to handle. This patch includes a new migration script that adds a new column called "group_name" to the "ovn_hash_ring" table. Change-Id: Ifc489afb764cddeec58597399d7d641c0d7ff279 Signed-off-by: Lucas Alvares Gomes <lucasagomes@gmail.com>changes/07/670307/4
13 changed files with 180 additions and 47 deletions
@ -1 +1 @@
|
||||
4a478c5c1e16 |
||||
e55d09277410 |
||||
|
@ -0,0 +1,53 @@
|
||||
# Copyright 2019 Red Hat, Inc. |
||||
# |
||||
# 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 |
||||
import sqlalchemy as sa |
||||
from sqlalchemy.engine.reflection import Inspector as insp |
||||
|
||||
"""ovn_hash_ring_add_group_column |
||||
|
||||
Revision ID: e55d09277410 |
||||
Revises: 4a478c5c1e16 |
||||
Create Date: 2019-07-09 13:26:31.356414 |
||||
|
||||
""" |
||||
|
||||
# revision identifiers, used by Alembic. |
||||
revision = 'e55d09277410' |
||||
down_revision = '4a478c5c1e16' |
||||
|
||||
MYSQL_ENGINE = 'mysql' |
||||
|
||||
|
||||
def upgrade(): |
||||
op.add_column( |
||||
'ovn_hash_ring', |
||||
sa.Column('group_name', sa.String(length=256), nullable=False)) |
||||
|
||||
# Make node_uuid and group_name a composite PK |
||||
bind = op.get_bind() |
||||
engine = bind.engine |
||||
|
||||
if (engine.name == MYSQL_ENGINE): |
||||
op.execute("ALTER TABLE ovn_hash_ring DROP PRIMARY KEY," |
||||
"ADD PRIMARY KEY (node_uuid, group_name);") |
||||
else: |
||||
inspector = insp.from_engine(bind) |
||||
pk_constraint = inspector.get_pk_constraint('ovn_hash_ring') |
||||
op.drop_constraint(pk_constraint.get('name'), 'ovn_hash_ring', |
||||
type_='primary') |
||||
op.create_primary_key(op.f('pk_ovn_hash_ring'), |
||||
'ovn_hash_ring', ['node_uuid', 'group_name']) |
Loading…
Reference in new issue