Skip to content

Commit

Permalink
Merge "Fix VIP address DB storage size to support IPv6"
Browse files Browse the repository at this point in the history
  • Loading branch information
Zuul authored and openstack-gerrit committed Feb 15, 2019
2 parents f026372 + 8d45d48 commit 52822fe
Show file tree
Hide file tree
Showing 4 changed files with 91 additions and 0 deletions.
@@ -0,0 +1,30 @@
# Copyright 2017 Rackspace, US 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.

"""Fix_IPv6_VIP
Revision ID: 11e4bb2bb8ef
Revises: 211982b05afc
Create Date: 2019-01-28 08:35:35.333616
"""
from alembic import op
import sqlalchemy as sa

# revision identifiers, used by Alembic.
revision = '11e4bb2bb8ef'
down_revision = '211982b05afc'


def upgrade():
op.alter_column(u'vip', u'ip_address', type_=sa.String(64))
34 changes: 34 additions & 0 deletions octavia/tests/functional/api/v2/test_load_balancer.py
Expand Up @@ -316,6 +316,40 @@ def test_create_with_vip_network_and_address_ipv6(self):
self.assertEqual(network.id, api_lb.get('vip_network_id'))
self.assertEqual(ip_address, api_lb.get('vip_address'))

# Note: This test is using the unique local address range to
# validate that we handle a fully expaned IP address properly.
# This is not possible with the documentation/testnet range.
def test_create_with_vip_network_and_address_full_ipv6(self):
ip_address = 'fdff:ffff:ffff:ffff:ffff:ffff:ffff:ffff'
network_id = uuidutils.generate_uuid()
subnet1 = network_models.Subnet(id=uuidutils.generate_uuid(),
network_id=network_id,
cidr='fc00::/7',
ip_version=6)
subnet2 = network_models.Subnet(id=uuidutils.generate_uuid(),
network_id=network_id,
cidr='198.51.100.0/24',
ip_version=4)
network = network_models.Network(id=network_id,
subnets=[subnet1.id, subnet2.id])
lb_json = {'vip_network_id': network.id,
'vip_address': ip_address,
'project_id': self.project_id}
body = self._build_body(lb_json)
with mock.patch(
"octavia.network.drivers.noop_driver.driver.NoopManager"
".get_network") as mock_get_network, mock.patch(
"octavia.network.drivers.noop_driver.driver.NoopManager"
".get_subnet") as mock_get_subnet:
mock_get_network.return_value = network
mock_get_subnet.side_effect = [subnet1, subnet2]
response = self.post(self.LBS_PATH, body)
api_lb = response.json.get(self.root_tag)
self._assert_request_matches_response(lb_json, api_lb)
self.assertEqual(subnet1.id, api_lb.get('vip_subnet_id'))
self.assertEqual(network.id, api_lb.get('vip_network_id'))
self.assertEqual(ip_address, api_lb.get('vip_address'))

def test_create_with_vip_port_1_fixed_ip(self):
ip_address = '198.51.100.1'
subnet = network_models.Subnet(id=uuidutils.generate_uuid())
Expand Down
17 changes: 17 additions & 0 deletions octavia/tests/functional/db/test_repositories.py
Expand Up @@ -2958,6 +2958,23 @@ def test_delete(self):
self.assertIsNotNone(new_lb)
self.assertIsNone(new_lb.vip)

def test_create_ipv6(self):
vip = self.vip_repo.create(self.session, load_balancer_id=self.lb.id,
ip_address="2001:DB8::10")
self.assertEqual(self.lb.id, vip.load_balancer_id)
self.assertEqual("2001:DB8::10", vip.ip_address)

# Note: This test is using the unique local address range to
# validate that we handle a fully expaned IP address properly.
# This is not possible with the documentation/testnet range.
def test_create_ipv6_full(self):
vip = self.vip_repo.create(
self.session, load_balancer_id=self.lb.id,
ip_address="fdff:ffff:ffff:ffff:ffff:ffff:ffff:ffff")
self.assertEqual(self.lb.id, vip.load_balancer_id)
self.assertEqual("fdff:ffff:ffff:ffff:ffff:ffff:ffff:ffff",
vip.ip_address)


class SNIRepositoryTest(BaseRepositoryTest):

Expand Down
10 changes: 10 additions & 0 deletions releasenotes/notes/fix-IPv6-vip-079a3285f78686ee.yaml
@@ -0,0 +1,10 @@
---
upgrade:
- |
To fix IPv6 VIP addresses, you must run the "octavia-db-manage upgrade
head" migration script.
fixes:
- |
Fully expanded IPv6 VIP addresses would fail to store with "Data too long
for column 'ip_address' at row 1". This patch includes a database migration
to fix this column.

0 comments on commit 52822fe

Please sign in to comment.