diff --git a/api-ref/source/parameters.yaml b/api-ref/source/parameters.yaml index e99b33ad46..d1b52097c6 100644 --- a/api-ref/source/parameters.yaml +++ b/api-ref/source/parameters.yaml @@ -909,7 +909,7 @@ l7rules-status-object-list: lb-algorithm: description: | The load balancing algorithm for the pool. One of ``LEAST_CONNECTIONS``, - ``ROUND_ROBIN``, or ``SOURCE_IP``. + ``ROUND_ROBIN``, ``SOURCE_IP``, or ``SOURCE_IP_PORT``. in: body required: true type: string diff --git a/api-ref/source/v2/pool.inc b/api-ref/source/v2/pool.inc index f57ec983b2..142dd7df27 100644 --- a/api-ref/source/v2/pool.inc +++ b/api-ref/source/v2/pool.inc @@ -103,8 +103,8 @@ At a minimum, you must specify these pool attributes: listen. A valid value is ``HTTP``, ``HTTPS``, ``PROXY``, ``TCP``, or ``UDP``. - ``lb_algorithm`` The load-balancer algorithm, such as - ``ROUND_ROBIN``, ``LEAST_CONNECTIONS``, and ``SOURCE_IP``, that - distributes traffic to the pool members. The load-balancer + ``ROUND_ROBIN``, ``LEAST_CONNECTIONS``, ``SOURCE_IP`` and ``SOURCE_IP_PORT``, + that distributes traffic to the pool members. The load-balancer provider must support this algorithm. - ``listener_id`` The ID of the listener in which this pool @@ -144,6 +144,9 @@ specifying the additional elements or attributes in the request. To create a pool, the parent load balancer must have an ``ACTIVE`` provisioning status. +``SOURCE_IP_PORT`` algorithm is available from version 2.13. + + .. rest_status_code:: success ../http-status.yaml - 201 diff --git a/doc/source/contributor/guides/providers.rst b/doc/source/contributor/guides/providers.rst index d4f7aa85ae..dab1b0bd3a 100644 --- a/doc/source/contributor/guides/providers.rst +++ b/doc/source/contributor/guides/providers.rst @@ -755,8 +755,8 @@ contain the following: | healthmonitor | object | A `Healthmonitor object`_. | +-----------------------+--------+------------------------------------------+ | lb_algorithm | string | Load balancing algorithm: One of | -| | | ROUND_ROBIN, LEAST_CONNECTIONS, or | -| | | SOURCE_IP. | +| | | ROUND_ROBIN, LEAST_CONNECTIONS, | +| | | SOURCE_IP or SOURCE_IP_PORT. | +-----------------------+--------+------------------------------------------+ | loadbalancer_id | string | ID of load balancer. | +-----------------------+--------+------------------------------------------+ diff --git a/doc/source/user/feature-classification/feature-matrix-pool.ini b/doc/source/user/feature-classification/feature-matrix-pool.ini index c8dd6de13d..2e1cd1776c 100644 --- a/doc/source/user/feature-classification/feature-matrix-pool.ini +++ b/doc/source/user/feature-classification/feature-matrix-pool.ini @@ -62,9 +62,16 @@ driver.ovn=missing [operation.lb_algorithm.SOURCE_IP] title=lb_algorithm - SOURCE_IP -notes=The pool will direct connections to the member server based on a has of the source IP. +notes=The pool will direct connections to the member server based on a hash of the source IP. cli=openstack loadbalancer pool create --lb-algorithm SOURCE_IP --listener driver.amphora=complete +driver.ovn=missing + +[operation.lb_algorithm.SOURCE_IP_PORT] +title=lb_algorithm - SOURCE_IP_PORT +notes=The pool will direct connections to the member server based on a hash of the source IP and Port. +cli=openstack loadbalancer pool create --lb-algorithm SOURCE_IP_PORT --listener +driver.amphora=missing driver.ovn=complete [operation.description] diff --git a/octavia/api/root_controller.py b/octavia/api/root_controller.py index 3067c7dfee..68bbeaa461 100644 --- a/octavia/api/root_controller.py +++ b/octavia/api/root_controller.py @@ -85,6 +85,9 @@ class RootController(rest.RestController): self._add_a_version(versions, 'v2.11', 'v2', 'SUPPORTED', '2019-06-24T00:00:00Z', host_url) # VIP ACL - self._add_a_version(versions, 'v2.12', 'v2', 'CURRENT', + self._add_a_version(versions, 'v2.12', 'v2', 'SUPPORTED', '2019-09-11T00:00:00Z', host_url) + # SOURCE_IP_PORT algorithm + self._add_a_version(versions, 'v2.13', 'v2', 'CURRENT', + '2019-09-13T00:00:00Z', host_url) return {'versions': versions} diff --git a/octavia/db/migration/alembic_migrations/versions/dcf88e59aae4_add_lb_algorithm_source_ip_port.py b/octavia/db/migration/alembic_migrations/versions/dcf88e59aae4_add_lb_algorithm_source_ip_port.py new file mode 100644 index 0000000000..ed6277576d --- /dev/null +++ b/octavia/db/migration/alembic_migrations/versions/dcf88e59aae4_add_lb_algorithm_source_ip_port.py @@ -0,0 +1,67 @@ +# +# 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. +# + +"""Add LB_ALGORITHM_SOURCE_IP_PORT + +Revision ID: dcf88e59aae4 +Revises: da371b422669 +Create Date: 2019-07-23 12:50:49.722003 + +""" + +from alembic import op +import sqlalchemy as sa + +# revision identifiers, used by Alembic. +revision = 'dcf88e59aae4' +down_revision = 'da371b422669' + + +def migrate_pools(): + conn = op.get_bind() + lb_table = sa.sql.table( + 'load_balancer', + sa.sql.column('id', sa.String), + sa.sql.column('provider', sa.String), + sa.sql.column('provisioning_status', sa.String)) + pool_table = sa.sql.table( + 'pool', + sa.sql.column('id', sa.String), + sa.sql.column('load_balancer_id', sa.String), + sa.sql.column('lb_algorithm', sa.String)) + + j = pool_table.join(lb_table, + pool_table.c.load_balancer_id == lb_table.c.id) + stmt = sa.select([pool_table.c.id]).select_from(j).where( + lb_table.c.provider == 'ovn') + result = conn.execute(stmt) + + for row in result: + stmt = pool_table.update().values(lb_algorithm='SOURCE_IP_PORT').where( + pool_table.c.id == row[0]) + op.execute(stmt) + + +def upgrade(): + insert_table = sa.table( + u'algorithm', + sa.column(u'name', sa.String(255)), + ) + op.bulk_insert( + insert_table, + [ + {'name': 'SOURCE_IP_PORT'} + ] + ) + migrate_pools() diff --git a/octavia/tests/functional/api/test_root_controller.py b/octavia/tests/functional/api/test_root_controller.py index 3c3dedd021..09d44cc6bf 100644 --- a/octavia/tests/functional/api/test_root_controller.py +++ b/octavia/tests/functional/api/test_root_controller.py @@ -43,7 +43,7 @@ class TestRootController(base_db_test.OctaviaDBTestBase): def test_api_versions(self): versions = self._get_versions_with_config() version_ids = tuple(v.get('id') for v in versions) - self.assertEqual(13, len(version_ids)) + self.assertEqual(14, len(version_ids)) self.assertIn('v2.0', version_ids) self.assertIn('v2.1', version_ids) self.assertIn('v2.2', version_ids) @@ -57,6 +57,7 @@ class TestRootController(base_db_test.OctaviaDBTestBase): self.assertIn('v2.10', version_ids) self.assertIn('v2.11', version_ids) self.assertIn('v2.12', version_ids) + self.assertIn('v2.13', version_ids) # Each version should have a 'self' 'href' to the API version URL # [{u'rel': u'self', u'href': u'http://localhost/v2'}] diff --git a/releasenotes/notes/add-lb-algorithm-source-ip-port-ff86433143e43136.yaml b/releasenotes/notes/add-lb-algorithm-source-ip-port-ff86433143e43136.yaml new file mode 100644 index 0000000000..b5b808a1c9 --- /dev/null +++ b/releasenotes/notes/add-lb-algorithm-source-ip-port-ff86433143e43136.yaml @@ -0,0 +1,16 @@ +--- +features: + - | + New Load Balancing algorithm SOURCE_IP_PORT has been added. + It is supported only by OVN provider driver. +upgrade: + - | + All pools configured under OVN provider driver are + automatically migrated to SOURCE_IP_PORT algorithm. + Previously algorithm was named as ROUND_ROBIN, but in + fact it was not working like ROUND_ROBIN. After + investigating, it was observed that core OVN actually + utilizes a 5 Tuple Hash/RSS Hash in DPDK/Kernel as a Load + Balancing algorithm. The 5 Tuple Hash has Source IP, Destination + IP, Protocol, Source Port, Destination Port. + To reflect this the name was changed to SOURCE_IP_PORT.