Browse Source

Merge "Fix overriding default listener timeout values in config file" into stable/train

changes/49/778949/1
Zuul 2 months ago
committed by Gerrit Code Review
parent
commit
ec60849c77
5 changed files with 100 additions and 21 deletions
  1. +8
    -20
      octavia/api/v2/types/listener.py
  2. +14
    -0
      octavia/db/prepare.py
  3. +17
    -0
      octavia/tests/functional/api/v2/test_listener.py
  4. +55
    -1
      octavia/tests/functional/api/v2/test_load_balancer.py
  5. +6
    -0
      releasenotes/notes/fix-default-timeout-values-for-listeners-108c8048ba8beb9a.yaml

+ 8
- 20
octavia/api/v2/types/listener.py View File

@ -12,7 +12,6 @@
# License for the specific language governing permissions and limitations
# under the License.
from oslo_config import cfg
from wsme import types as wtypes
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.common import constants
CONF = cfg.CONF
CONF.import_group('haproxy_amphora', 'octavia.common.config')
class BaseListenerType(types.BaseType):
_type_to_model_map = {
@ -130,20 +126,16 @@ class ListenerPOST(BaseListenerType):
loadbalancer_id = wtypes.wsattr(wtypes.UuidType(), mandatory=True)
timeout_client_data = wtypes.wsattr(
wtypes.IntegerType(minimum=constants.MIN_TIMEOUT,
maximum=constants.MAX_TIMEOUT),
default=CONF.haproxy_amphora.timeout_client_data)
maximum=constants.MAX_TIMEOUT))
timeout_member_connect = wtypes.wsattr(
wtypes.IntegerType(minimum=constants.MIN_TIMEOUT,
maximum=constants.MAX_TIMEOUT),
default=CONF.haproxy_amphora.timeout_member_connect)
maximum=constants.MAX_TIMEOUT))
timeout_member_data = wtypes.wsattr(
wtypes.IntegerType(minimum=constants.MIN_TIMEOUT,
maximum=constants.MAX_TIMEOUT),
default=CONF.haproxy_amphora.timeout_member_data)
maximum=constants.MAX_TIMEOUT))
timeout_tcp_inspect = wtypes.wsattr(
wtypes.IntegerType(minimum=constants.MIN_TIMEOUT,
maximum=constants.MAX_TIMEOUT),
default=CONF.haproxy_amphora.timeout_tcp_inspect)
maximum=constants.MAX_TIMEOUT))
tags = wtypes.wsattr(wtypes.ArrayType(wtypes.StringType(max_length=255)))
client_ca_tls_container_ref = wtypes.StringType(max_length=255)
client_authentication = wtypes.wsattr(
@ -217,20 +209,16 @@ class ListenerSingleCreate(BaseListenerType):
wtypes.DictType(str, wtypes.StringType(max_length=255)))
timeout_client_data = wtypes.wsattr(
wtypes.IntegerType(minimum=constants.MIN_TIMEOUT,
maximum=constants.MAX_TIMEOUT),
default=CONF.haproxy_amphora.timeout_client_data)
maximum=constants.MAX_TIMEOUT))
timeout_member_connect = wtypes.wsattr(
wtypes.IntegerType(minimum=constants.MIN_TIMEOUT,
maximum=constants.MAX_TIMEOUT),
default=CONF.haproxy_amphora.timeout_member_connect)
maximum=constants.MAX_TIMEOUT))
timeout_member_data = wtypes.wsattr(
wtypes.IntegerType(minimum=constants.MIN_TIMEOUT,
maximum=constants.MAX_TIMEOUT),
default=CONF.haproxy_amphora.timeout_member_data)
maximum=constants.MAX_TIMEOUT))
timeout_tcp_inspect = wtypes.wsattr(
wtypes.IntegerType(minimum=constants.MIN_TIMEOUT,
maximum=constants.MAX_TIMEOUT),
default=CONF.haproxy_amphora.timeout_tcp_inspect)
maximum=constants.MAX_TIMEOUT))
tags = wtypes.wsattr(wtypes.ArrayType(wtypes.StringType(max_length=255)))
client_ca_tls_container_ref = wtypes.StringType(max_length=255)
client_authentication = wtypes.wsattr(


+ 14
- 0
octavia/db/prepare.py View File

@ -103,6 +103,20 @@ def create_listener(listener_dict, lb_id):
if 'client_authentication' not in listener_dict:
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


+ 17
- 0
octavia/tests/functional/api/v2/test_listener.py View File

@ -661,6 +661,23 @@ class TestListener(base.BaseAPITest):
self.assertEqual(constants.MAX_TIMEOUT,
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):
optionals = {
'timeout_client_data': 1,


+ 55
- 1
octavia/tests/functional/api/v2/test_load_balancer.py View File

@ -2645,7 +2645,15 @@ class TestLoadBalancerGraph(base.BaseAPITest):
create_client_crl_container=None,
expected_client_crl_container=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 = {
'name': name,
'protocol_port': protocol_port,
@ -2716,6 +2724,31 @@ class TestLoadBalancerGraph(base.BaseAPITest):
if 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
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)
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):
create_listener1, expected_listener1 = self._get_listener_bodies()
create_listener2, expected_listener2 = self._get_listener_bodies(


+ 6
- 0
releasenotes/notes/fix-default-timeout-values-for-listeners-108c8048ba8beb9a.yaml View File

@ -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…
Cancel
Save