diff --git a/octavia/api/v2/types/listener.py b/octavia/api/v2/types/listener.py index f8378d2be2..60058877ee 100644 --- a/octavia/api/v2/types/listener.py +++ b/octavia/api/v2/types/listener.py @@ -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): diff --git a/octavia/common/config.py b/octavia/common/config.py index 0f4e560fdd..29fd729f35 100644 --- a/octavia/common/config.py +++ b/octavia/common/config.py @@ -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")), diff --git a/octavia/common/jinja/haproxy/jinja_cfg.py b/octavia/common/jinja/haproxy/jinja_cfg.py index 2f1b5c64ba..ede11ffd0b 100644 --- a/octavia/common/jinja/haproxy/jinja_cfg.py +++ b/octavia/common/jinja/haproxy/jinja_cfg.py @@ -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 diff --git a/releasenotes/notes/bug-1797130-8c9bfa50d9b6c955.yaml b/releasenotes/notes/bug-1797130-8c9bfa50d9b6c955.yaml new file mode 100644 index 0000000000..09f385b7a6 --- /dev/null +++ b/releasenotes/notes/bug-1797130-8c9bfa50d9b6c955.yaml @@ -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. \ No newline at end of file