Add posibilities to set default timeouts

Default timeouts for backend member and frontend
client can be set now via config file.
Timeouts exposed in config in section haproxy_amphora:
 * timeout_client_data
 * timeout_member_connect
 * timeout_member_data
 * timeout_tcp_inspect

Change-Id: I6e1be42c5c15c4171b012734e4c2a1fded51dbc7
Partial-Bug: 1797130
Story: 2004042
Task: 27046
This commit is contained in:
Kamil Sambor 2018-10-10 16:04:59 +02:00 committed by Nir Magnezi
parent 759cb75960
commit 8923935df2
4 changed files with 45 additions and 16 deletions

View File

@ -12,6 +12,7 @@
# 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
@ -19,6 +20,9 @@ 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 = {'admin_state_up': 'enabled',
@ -116,19 +120,19 @@ class ListenerPOST(BaseListenerType):
timeout_client_data = wtypes.wsattr(
wtypes.IntegerType(minimum=constants.MIN_TIMEOUT,
maximum=constants.MAX_TIMEOUT),
default=constants.DEFAULT_TIMEOUT_CLIENT_DATA)
default=CONF.haproxy_amphora.timeout_client_data)
timeout_member_connect = wtypes.wsattr(
wtypes.IntegerType(minimum=constants.MIN_TIMEOUT,
maximum=constants.MAX_TIMEOUT),
default=constants.DEFAULT_TIMEOUT_MEMBER_CONNECT)
default=CONF.haproxy_amphora.timeout_member_connect)
timeout_member_data = wtypes.wsattr(
wtypes.IntegerType(minimum=constants.MIN_TIMEOUT,
maximum=constants.MAX_TIMEOUT),
default=constants.DEFAULT_TIMEOUT_MEMBER_DATA)
default=CONF.haproxy_amphora.timeout_member_data)
timeout_tcp_inspect = wtypes.wsattr(
wtypes.IntegerType(minimum=constants.MIN_TIMEOUT,
maximum=constants.MAX_TIMEOUT),
default=constants.DEFAULT_TIMEOUT_TCP_INSPECT)
default=CONF.haproxy_amphora.timeout_tcp_inspect)
class ListenerRootPOST(types.BaseType):
@ -189,19 +193,19 @@ class ListenerSingleCreate(BaseListenerType):
timeout_client_data = wtypes.wsattr(
wtypes.IntegerType(minimum=constants.MIN_TIMEOUT,
maximum=constants.MAX_TIMEOUT),
default=constants.DEFAULT_TIMEOUT_CLIENT_DATA)
default=CONF.haproxy_amphora.timeout_client_data)
timeout_member_connect = wtypes.wsattr(
wtypes.IntegerType(minimum=constants.MIN_TIMEOUT,
maximum=constants.MAX_TIMEOUT),
default=constants.DEFAULT_TIMEOUT_MEMBER_CONNECT)
default=CONF.haproxy_amphora.timeout_member_connect)
timeout_member_data = wtypes.wsattr(
wtypes.IntegerType(minimum=constants.MIN_TIMEOUT,
maximum=constants.MAX_TIMEOUT),
default=constants.DEFAULT_TIMEOUT_MEMBER_DATA)
default=CONF.haproxy_amphora.timeout_member_data)
timeout_tcp_inspect = wtypes.wsattr(
wtypes.IntegerType(minimum=constants.MIN_TIMEOUT,
maximum=constants.MAX_TIMEOUT),
default=constants.DEFAULT_TIMEOUT_TCP_INSPECT)
default=CONF.haproxy_amphora.timeout_tcp_inspect)
class ListenerStatusResponse(BaseListenerType):

View File

@ -284,6 +284,18 @@ haproxy_amphora_opts = [
cfg.FloatOpt('rest_request_read_timeout', default=60,
help=_("The time in seconds to wait for a REST API "
"response.")),
cfg.IntOpt('timeout_client_data',
default=constants.DEFAULT_TIMEOUT_CLIENT_DATA,
help=_('Frontend client inactivity timeout.')),
cfg.IntOpt('timeout_member_connect',
default=constants.DEFAULT_TIMEOUT_MEMBER_CONNECT,
help=_('Backend member connection timeout.')),
cfg.IntOpt('timeout_member_data',
default=constants.DEFAULT_TIMEOUT_MEMBER_DATA,
help=_('Backend member inactivity timeout.')),
cfg.IntOpt('timeout_tcp_inspect',
default=constants.DEFAULT_TIMEOUT_TCP_INSPECT,
help=_('Time to wait for TCP packets for content inspection.')),
# REST client
cfg.StrOpt('client_cert', default='/etc/octavia/certs/client.pem',
help=_("The client certificate to talk to the agent")),

View File

@ -204,15 +204,17 @@ class JinjaTemplater(object):
'topology': listener.load_balancer.topology,
'amphorae': listener.load_balancer.amphorae,
'enabled': listener.enabled,
'timeout_client_data': (listener.timeout_client_data or
constants.DEFAULT_TIMEOUT_CLIENT_DATA),
'timeout_member_connect': (listener.timeout_member_connect or
constants.DEFAULT_TIMEOUT_MEMBER_CONNECT
),
'timeout_member_data': (listener.timeout_member_data or
constants.DEFAULT_TIMEOUT_MEMBER_DATA),
'timeout_client_data': (
listener.timeout_client_data or
CONF.haproxy_amphora.timeout_client_data),
'timeout_member_connect': (
listener.timeout_member_connect or
CONF.haproxy_amphora.timeout_member_connect),
'timeout_member_data': (
listener.timeout_member_data or
CONF.haproxy_amphora.timeout_member_data),
'timeout_tcp_inspect': (listener.timeout_tcp_inspect or
constants.DEFAULT_TIMEOUT_TCP_INSPECT),
CONF.haproxy_amphora.timeout_tcp_inspect),
}
if listener.connection_limit and listener.connection_limit > -1:
ret_value['connection_limit'] = listener.connection_limit

View File

@ -0,0 +1,11 @@
---
features:
- |
Listeners default timeouts can be set by config in section haproxy_amphora:
* `timeout_client_data`: Frontend client inactivity timeout
* `timeout_member_connect`: Backend member connection timeout
* `timeout_member_data`: Backend member inactivity timeout
* `timeout_tcp_inspect`: Time to wait for TCP packets for content inspection
The value for all of these options is expected to be in milliseconds.