Merge "Fix overriding default listener timeout values in config file" into stable/train
This commit is contained in:
commit
ec60849c77
|
@ -12,7 +12,6 @@
|
||||||
# License for the specific language governing permissions and limitations
|
# License for the specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
from oslo_config import cfg
|
|
||||||
from wsme import types as wtypes
|
from wsme import types as wtypes
|
||||||
|
|
||||||
from octavia.api.common import types
|
from octavia.api.common import types
|
||||||
|
@ -20,9 +19,6 @@ from octavia.api.v2.types import l7policy
|
||||||
from octavia.api.v2.types import pool
|
from octavia.api.v2.types import pool
|
||||||
from octavia.common import constants
|
from octavia.common import constants
|
||||||
|
|
||||||
CONF = cfg.CONF
|
|
||||||
CONF.import_group('haproxy_amphora', 'octavia.common.config')
|
|
||||||
|
|
||||||
|
|
||||||
class BaseListenerType(types.BaseType):
|
class BaseListenerType(types.BaseType):
|
||||||
_type_to_model_map = {
|
_type_to_model_map = {
|
||||||
|
@ -130,20 +126,16 @@ class ListenerPOST(BaseListenerType):
|
||||||
loadbalancer_id = wtypes.wsattr(wtypes.UuidType(), mandatory=True)
|
loadbalancer_id = wtypes.wsattr(wtypes.UuidType(), mandatory=True)
|
||||||
timeout_client_data = wtypes.wsattr(
|
timeout_client_data = wtypes.wsattr(
|
||||||
wtypes.IntegerType(minimum=constants.MIN_TIMEOUT,
|
wtypes.IntegerType(minimum=constants.MIN_TIMEOUT,
|
||||||
maximum=constants.MAX_TIMEOUT),
|
maximum=constants.MAX_TIMEOUT))
|
||||||
default=CONF.haproxy_amphora.timeout_client_data)
|
|
||||||
timeout_member_connect = wtypes.wsattr(
|
timeout_member_connect = wtypes.wsattr(
|
||||||
wtypes.IntegerType(minimum=constants.MIN_TIMEOUT,
|
wtypes.IntegerType(minimum=constants.MIN_TIMEOUT,
|
||||||
maximum=constants.MAX_TIMEOUT),
|
maximum=constants.MAX_TIMEOUT))
|
||||||
default=CONF.haproxy_amphora.timeout_member_connect)
|
|
||||||
timeout_member_data = wtypes.wsattr(
|
timeout_member_data = wtypes.wsattr(
|
||||||
wtypes.IntegerType(minimum=constants.MIN_TIMEOUT,
|
wtypes.IntegerType(minimum=constants.MIN_TIMEOUT,
|
||||||
maximum=constants.MAX_TIMEOUT),
|
maximum=constants.MAX_TIMEOUT))
|
||||||
default=CONF.haproxy_amphora.timeout_member_data)
|
|
||||||
timeout_tcp_inspect = wtypes.wsattr(
|
timeout_tcp_inspect = wtypes.wsattr(
|
||||||
wtypes.IntegerType(minimum=constants.MIN_TIMEOUT,
|
wtypes.IntegerType(minimum=constants.MIN_TIMEOUT,
|
||||||
maximum=constants.MAX_TIMEOUT),
|
maximum=constants.MAX_TIMEOUT))
|
||||||
default=CONF.haproxy_amphora.timeout_tcp_inspect)
|
|
||||||
tags = wtypes.wsattr(wtypes.ArrayType(wtypes.StringType(max_length=255)))
|
tags = wtypes.wsattr(wtypes.ArrayType(wtypes.StringType(max_length=255)))
|
||||||
client_ca_tls_container_ref = wtypes.StringType(max_length=255)
|
client_ca_tls_container_ref = wtypes.StringType(max_length=255)
|
||||||
client_authentication = wtypes.wsattr(
|
client_authentication = wtypes.wsattr(
|
||||||
|
@ -217,20 +209,16 @@ class ListenerSingleCreate(BaseListenerType):
|
||||||
wtypes.DictType(str, wtypes.StringType(max_length=255)))
|
wtypes.DictType(str, wtypes.StringType(max_length=255)))
|
||||||
timeout_client_data = wtypes.wsattr(
|
timeout_client_data = wtypes.wsattr(
|
||||||
wtypes.IntegerType(minimum=constants.MIN_TIMEOUT,
|
wtypes.IntegerType(minimum=constants.MIN_TIMEOUT,
|
||||||
maximum=constants.MAX_TIMEOUT),
|
maximum=constants.MAX_TIMEOUT))
|
||||||
default=CONF.haproxy_amphora.timeout_client_data)
|
|
||||||
timeout_member_connect = wtypes.wsattr(
|
timeout_member_connect = wtypes.wsattr(
|
||||||
wtypes.IntegerType(minimum=constants.MIN_TIMEOUT,
|
wtypes.IntegerType(minimum=constants.MIN_TIMEOUT,
|
||||||
maximum=constants.MAX_TIMEOUT),
|
maximum=constants.MAX_TIMEOUT))
|
||||||
default=CONF.haproxy_amphora.timeout_member_connect)
|
|
||||||
timeout_member_data = wtypes.wsattr(
|
timeout_member_data = wtypes.wsattr(
|
||||||
wtypes.IntegerType(minimum=constants.MIN_TIMEOUT,
|
wtypes.IntegerType(minimum=constants.MIN_TIMEOUT,
|
||||||
maximum=constants.MAX_TIMEOUT),
|
maximum=constants.MAX_TIMEOUT))
|
||||||
default=CONF.haproxy_amphora.timeout_member_data)
|
|
||||||
timeout_tcp_inspect = wtypes.wsattr(
|
timeout_tcp_inspect = wtypes.wsattr(
|
||||||
wtypes.IntegerType(minimum=constants.MIN_TIMEOUT,
|
wtypes.IntegerType(minimum=constants.MIN_TIMEOUT,
|
||||||
maximum=constants.MAX_TIMEOUT),
|
maximum=constants.MAX_TIMEOUT))
|
||||||
default=CONF.haproxy_amphora.timeout_tcp_inspect)
|
|
||||||
tags = wtypes.wsattr(wtypes.ArrayType(wtypes.StringType(max_length=255)))
|
tags = wtypes.wsattr(wtypes.ArrayType(wtypes.StringType(max_length=255)))
|
||||||
client_ca_tls_container_ref = wtypes.StringType(max_length=255)
|
client_ca_tls_container_ref = wtypes.StringType(max_length=255)
|
||||||
client_authentication = wtypes.wsattr(
|
client_authentication = wtypes.wsattr(
|
||||||
|
|
|
@ -103,6 +103,20 @@ def create_listener(listener_dict, lb_id):
|
||||||
|
|
||||||
if 'client_authentication' not in listener_dict:
|
if 'client_authentication' not in listener_dict:
|
||||||
listener_dict['client_authentication'] = constants.CLIENT_AUTH_NONE
|
listener_dict['client_authentication'] = constants.CLIENT_AUTH_NONE
|
||||||
|
|
||||||
|
if listener_dict.get('timeout_client_data') is None:
|
||||||
|
listener_dict['timeout_client_data'] = (
|
||||||
|
CONF.haproxy_amphora.timeout_client_data)
|
||||||
|
if listener_dict.get('timeout_member_connect') is None:
|
||||||
|
listener_dict['timeout_member_connect'] = (
|
||||||
|
CONF.haproxy_amphora.timeout_member_connect)
|
||||||
|
if listener_dict.get('timeout_member_data') is None:
|
||||||
|
listener_dict['timeout_member_data'] = (
|
||||||
|
CONF.haproxy_amphora.timeout_member_data)
|
||||||
|
if listener_dict.get('timeout_tcp_inspect') is None:
|
||||||
|
listener_dict['timeout_tcp_inspect'] = (
|
||||||
|
CONF.haproxy_amphora.timeout_tcp_inspect)
|
||||||
|
|
||||||
return listener_dict
|
return listener_dict
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -661,6 +661,23 @@ class TestListener(base.BaseAPITest):
|
||||||
self.assertEqual(constants.MAX_TIMEOUT,
|
self.assertEqual(constants.MAX_TIMEOUT,
|
||||||
listener_api.get('timeout_tcp_inspect'))
|
listener_api.get('timeout_tcp_inspect'))
|
||||||
|
|
||||||
|
def test_create_with_default_timeouts(self):
|
||||||
|
self.conf = self.useFixture(oslo_fixture.Config(cfg.CONF))
|
||||||
|
self.conf.config(group='haproxy_amphora', timeout_client_data=20)
|
||||||
|
self.conf.config(group='haproxy_amphora', timeout_member_connect=21)
|
||||||
|
self.conf.config(group='haproxy_amphora',
|
||||||
|
timeout_member_data=constants.MIN_TIMEOUT)
|
||||||
|
self.conf.config(group='haproxy_amphora',
|
||||||
|
timeout_tcp_inspect=constants.MAX_TIMEOUT)
|
||||||
|
|
||||||
|
listener_api = self.test_create()
|
||||||
|
self.assertEqual(20, listener_api.get('timeout_client_data'))
|
||||||
|
self.assertEqual(21, listener_api.get('timeout_member_connect'))
|
||||||
|
self.assertEqual(constants.MIN_TIMEOUT,
|
||||||
|
listener_api.get('timeout_member_data'))
|
||||||
|
self.assertEqual(constants.MAX_TIMEOUT,
|
||||||
|
listener_api.get('timeout_tcp_inspect'))
|
||||||
|
|
||||||
def test_create_with_timeouts_too_high(self):
|
def test_create_with_timeouts_too_high(self):
|
||||||
optionals = {
|
optionals = {
|
||||||
'timeout_client_data': 1,
|
'timeout_client_data': 1,
|
||||||
|
|
|
@ -2645,7 +2645,15 @@ class TestLoadBalancerGraph(base.BaseAPITest):
|
||||||
create_client_crl_container=None,
|
create_client_crl_container=None,
|
||||||
expected_client_crl_container=None,
|
expected_client_crl_container=None,
|
||||||
create_allowed_cidrs=None,
|
create_allowed_cidrs=None,
|
||||||
expected_allowed_cidrs=None):
|
expected_allowed_cidrs=None,
|
||||||
|
create_timeout_client_data=None,
|
||||||
|
expected_timeout_client_data=None,
|
||||||
|
create_timeout_member_connect=None,
|
||||||
|
expected_timeout_member_connect=None,
|
||||||
|
create_timeout_member_data=None,
|
||||||
|
expected_timeout_member_data=None,
|
||||||
|
create_timeout_tcp_inspect=None,
|
||||||
|
expected_timeout_tcp_inspect=None):
|
||||||
create_listener = {
|
create_listener = {
|
||||||
'name': name,
|
'name': name,
|
||||||
'protocol_port': protocol_port,
|
'protocol_port': protocol_port,
|
||||||
|
@ -2716,6 +2724,31 @@ class TestLoadBalancerGraph(base.BaseAPITest):
|
||||||
if expected_allowed_cidrs:
|
if expected_allowed_cidrs:
|
||||||
expected_listener['allowed_cidrs'] = expected_allowed_cidrs
|
expected_listener['allowed_cidrs'] = expected_allowed_cidrs
|
||||||
|
|
||||||
|
if create_timeout_client_data is not None:
|
||||||
|
create_listener['timeout_client_data'] = (
|
||||||
|
create_timeout_client_data)
|
||||||
|
if expected_timeout_client_data is not None:
|
||||||
|
expected_listener['timeout_client_data'] = (
|
||||||
|
expected_timeout_client_data)
|
||||||
|
if create_timeout_member_connect is not None:
|
||||||
|
create_listener['timeout_member_connect'] = (
|
||||||
|
create_timeout_member_connect)
|
||||||
|
if expected_timeout_member_connect is not None:
|
||||||
|
expected_listener['timeout_member_connect'] = (
|
||||||
|
expected_timeout_member_connect)
|
||||||
|
if create_timeout_member_data is not None:
|
||||||
|
create_listener['timeout_member_data'] = (
|
||||||
|
create_timeout_member_data)
|
||||||
|
if expected_timeout_member_data is not None:
|
||||||
|
expected_listener['timeout_member_data'] = (
|
||||||
|
expected_timeout_member_data)
|
||||||
|
if create_timeout_tcp_inspect is not None:
|
||||||
|
create_listener['timeout_tcp_inspect'] = (
|
||||||
|
create_timeout_tcp_inspect)
|
||||||
|
if expected_timeout_tcp_inspect is not None:
|
||||||
|
expected_listener['timeout_tcp_inspect'] = (
|
||||||
|
expected_timeout_tcp_inspect)
|
||||||
|
|
||||||
return create_listener, expected_listener
|
return create_listener, expected_listener
|
||||||
|
|
||||||
def _get_pool_bodies(self, name='pool1', create_members=None,
|
def _get_pool_bodies(self, name='pool1', create_members=None,
|
||||||
|
@ -2869,6 +2902,27 @@ class TestLoadBalancerGraph(base.BaseAPITest):
|
||||||
api_lb = response.json.get(self.root_tag)
|
api_lb = response.json.get(self.root_tag)
|
||||||
self._assert_graphs_equal(expected_lb, api_lb)
|
self._assert_graphs_equal(expected_lb, api_lb)
|
||||||
|
|
||||||
|
def test_with_one_listener_with_default_timeouts(self):
|
||||||
|
self.conf = self.useFixture(oslo_fixture.Config(cfg.CONF))
|
||||||
|
self.conf.config(group='haproxy_amphora', timeout_client_data=20)
|
||||||
|
self.conf.config(group='haproxy_amphora', timeout_member_connect=21)
|
||||||
|
self.conf.config(group='haproxy_amphora',
|
||||||
|
timeout_member_data=constants.MIN_TIMEOUT)
|
||||||
|
self.conf.config(group='haproxy_amphora',
|
||||||
|
timeout_tcp_inspect=constants.MAX_TIMEOUT)
|
||||||
|
|
||||||
|
create_listener, expected_listener = self._get_listener_bodies(
|
||||||
|
expected_timeout_client_data=20,
|
||||||
|
expected_timeout_member_connect=21,
|
||||||
|
expected_timeout_member_data=constants.MIN_TIMEOUT,
|
||||||
|
expected_timeout_tcp_inspect=constants.MAX_TIMEOUT)
|
||||||
|
create_lb, expected_lb = self._get_lb_bodies([create_listener],
|
||||||
|
[expected_listener])
|
||||||
|
body = self._build_body(create_lb)
|
||||||
|
response = self.post(self.LBS_PATH, body)
|
||||||
|
api_lb = response.json.get(self.root_tag)
|
||||||
|
self._assert_graphs_equal(expected_lb, api_lb)
|
||||||
|
|
||||||
def test_with_many_listeners(self):
|
def test_with_many_listeners(self):
|
||||||
create_listener1, expected_listener1 = self._get_listener_bodies()
|
create_listener1, expected_listener1 = self._get_listener_bodies()
|
||||||
create_listener2, expected_listener2 = self._get_listener_bodies(
|
create_listener2, expected_listener2 = self._get_listener_bodies(
|
||||||
|
|
|
@ -0,0 +1,6 @@
|
||||||
|
---
|
||||||
|
fixes:
|
||||||
|
- |
|
||||||
|
Fix default value override for timeout values for listeners. Changing the
|
||||||
|
default timeouts in the configuration file wasn't correctly applied in the
|
||||||
|
default listener parameters.
|
Loading…
Reference in New Issue