OCP-Router: Fix path route to support subpath

OCP-Route supports path based routes, path based routes specify a path
component that can be compared against a URL such that multiple routes
can be served using the same host name, each with a different path.

Assuming that OCP-Route object that maps hostname:'www.test.com',
path:'/path', to service named: 'target_service' was created.
We should expect that all URL starts with  'www.test.com/path' should
be routed to 'target_service' pods.

This patch updates ocp-route handler to support the above requirement.

Change-Id: I95df37663fc7016f81ebf7b9683779e023b6d24c
Closes-Bug: 1781828
This commit is contained in:
Yossi Boaron
2018-07-16 00:26:57 +03:00
parent 6bc68ce6c2
commit b8f5e25748
2 changed files with 8 additions and 6 deletions

View File

@@ -19,6 +19,8 @@ from kuryr_kubernetes.platform.ocp.controller.handlers import route as h_route
from kuryr_kubernetes.tests import base as test_base
import mock
OCP_ROUTE_PATH_COMP_TYPE = 'STARTS_WITH'
class TestOcpRouteHandler(test_base.TestCase):
@@ -340,7 +342,7 @@ class TestOcpRouteHandler(test_base.TestCase):
ret_p_l7_rule = obj_lbaas.LBaaSL7Rule(
id='55559E11-91C2-41CF-8FD4-7970579E5C44',
compare_type='EQUAL_TO',
compare_type=OCP_ROUTE_PATH_COMP_TYPE,
l7policy_id='55559E11-91C2-41CF-8FD4-7970579E5C45',
type='PATH',
value='/nice_path')
@@ -351,7 +353,7 @@ class TestOcpRouteHandler(test_base.TestCase):
self.assertEqual(route_state.p_l7_rule, ret_p_l7_rule)
m_handler._drv_lbaas.ensure_l7_rule.assert_called_once_with(
m_handler._l7_router, route_state.l7_policy,
'EQUAL_TO', 'PATH', route['spec']['path'])
OCP_ROUTE_PATH_COMP_TYPE, 'PATH', route['spec']['path'])
def test_sync_path_l7_rule_edit_usecase(self):
m_handler = mock.Mock(spec=h_route.OcpRouteHandler)
@@ -363,7 +365,7 @@ class TestOcpRouteHandler(test_base.TestCase):
old_p_l7_rule = obj_lbaas.LBaaSL7Rule(
id='00EE9E11-91C2-41CF-8FD4-7970579E5C44',
compare_type='EQUAL_TO',
compare_type=OCP_ROUTE_PATH_COMP_TYPE,
l7policy_id='00EE9E11-91C2-41CF-8FD4-7970579E5C45',
type='PATH',
value='/cur_path')
@@ -380,7 +382,7 @@ class TestOcpRouteHandler(test_base.TestCase):
ret_p_l7_rule = obj_lbaas.LBaaSL7Rule(
id='00EE9E11-91C2-41CF-8FD4-7970579E5C44',
compare_type='EQUAL_TO',
compare_type=OCP_ROUTE_PATH_COMP_TYPE,
l7policy_id='00EE9E11-91C2-41CF-8FD4-7970579E5C45',
type='PATH',
value=route['spec']['path'])
@@ -402,7 +404,7 @@ class TestOcpRouteHandler(test_base.TestCase):
old_p_l7_rule = obj_lbaas.LBaaSL7Rule(
id='00EE9E11-91C2-41CF-8FD4-7970579E5C44',
compare_type='EQUAL_TO',
compare_type=OCP_ROUTE_PATH_COMP_TYPE,
l7policy_id='00EE9E11-91C2-41CF-8FD4-7970579E5C45',
type='PATH',
value='/cur_path')