From 6ebe8650fa37ff6c33acaed3f510e229798e4a38 Mon Sep 17 00:00:00 2001 From: David Ames Date: Thu, 3 Dec 2015 15:02:21 -0800 Subject: [PATCH 1/2] Fix lp:1522130 Add sane haproxy timeout defaults and make them configurable. --- config.yaml | 24 +++++++++++++++++++ .../contrib/openstack/templates/haproxy.cfg | 12 ++++++++-- 2 files changed, 34 insertions(+), 2 deletions(-) diff --git a/config.yaml b/config.yaml index 6294eb65..d2421afc 100644 --- a/config.yaml +++ b/config.yaml @@ -103,3 +103,27 @@ options: the following public endpoint for the ceph-radosgw: https://files.example.com:80/swift/v1 + haproxy-server-timeout: + type: int + default: + description: | + Server timeout configuration in ms for haproxy, used in HA + configurations. If not provided, default value of 30000ms is used. + haproxy-client-timeout: + type: int + default: + description: | + Client timeout configuration in ms for haproxy, used in HA + configurations. If not provided, default value of 30000ms is used. + haproxy-queue-timeout: + type: int + default: + description: | + Queue timeout configuration in ms for haproxy, used in HA + configurations. If not provided, default value of 5000ms is used. + haproxy-connect-timeout: + type: int + default: + description: | + Connect timeout configuration in ms for haproxy, used in HA + configurations. If not provided, default value of 5000ms is used. diff --git a/hooks/charmhelpers/contrib/openstack/templates/haproxy.cfg b/hooks/charmhelpers/contrib/openstack/templates/haproxy.cfg index ad875f16..4a3e2d7a 100644 --- a/hooks/charmhelpers/contrib/openstack/templates/haproxy.cfg +++ b/hooks/charmhelpers/contrib/openstack/templates/haproxy.cfg @@ -12,8 +12,16 @@ defaults option tcplog option dontlognull retries 3 - timeout queue 1000 - timeout connect 1000 +{% if haproxy_queue_timeout -%} + timeout queue {{ haproxy_queue_timeout }} +{% else -%} + timeout queue 5000 +{% endif -%} +{% if haproxy_connect_timeout -%} + timeout connect {{ haproxy_connect_timeout }} +{% else -%} + timeout connect 5000 +{% endif -%} {% if haproxy_client_timeout -%} timeout client {{ haproxy_client_timeout }} {% else -%} From 07989e5cdcdca47d91475f0b5a84d44b7a0832d2 Mon Sep 17 00:00:00 2001 From: David Ames Date: Mon, 7 Dec 2015 14:51:36 -0800 Subject: [PATCH 2/2] Add haproxy context for new timeout values. Fix template whitespace --- .../charmhelpers/contrib/openstack/context.py | 6 +++++ .../contrib/openstack/templates/haproxy.cfg | 25 +++++++++---------- 2 files changed, 18 insertions(+), 13 deletions(-) diff --git a/hooks/charmhelpers/contrib/openstack/context.py b/hooks/charmhelpers/contrib/openstack/context.py index 49c04de0..1aee3caa 100644 --- a/hooks/charmhelpers/contrib/openstack/context.py +++ b/hooks/charmhelpers/contrib/openstack/context.py @@ -626,6 +626,12 @@ class HAProxyContext(OSContextGenerator): if config('haproxy-client-timeout'): ctxt['haproxy_client_timeout'] = config('haproxy-client-timeout') + if config('haproxy-queue-timeout'): + ctxt['haproxy_queue_timeout'] = config('haproxy-queue-timeout') + + if config('haproxy-connect-timeout'): + ctxt['haproxy_connect_timeout'] = config('haproxy-connect-timeout') + if config('prefer-ipv6'): ctxt['ipv6'] = True ctxt['local_host'] = 'ip6-localhost' diff --git a/hooks/charmhelpers/contrib/openstack/templates/haproxy.cfg b/hooks/charmhelpers/contrib/openstack/templates/haproxy.cfg index 4a3e2d7a..8721d8a1 100644 --- a/hooks/charmhelpers/contrib/openstack/templates/haproxy.cfg +++ b/hooks/charmhelpers/contrib/openstack/templates/haproxy.cfg @@ -12,27 +12,26 @@ defaults option tcplog option dontlognull retries 3 -{% if haproxy_queue_timeout -%} +{%- if haproxy_queue_timeout %} timeout queue {{ haproxy_queue_timeout }} -{% else -%} +{%- else %} timeout queue 5000 -{% endif -%} -{% if haproxy_connect_timeout -%} +{%- endif %} +{%- if haproxy_connect_timeout %} timeout connect {{ haproxy_connect_timeout }} -{% else -%} +{%- else %} timeout connect 5000 -{% endif -%} -{% if haproxy_client_timeout -%} +{%- endif %} +{%- if haproxy_client_timeout %} timeout client {{ haproxy_client_timeout }} -{% else -%} +{%- else %} timeout client 30000 -{% endif -%} - -{% if haproxy_server_timeout -%} +{%- endif %} +{%- if haproxy_server_timeout %} timeout server {{ haproxy_server_timeout }} -{% else -%} +{%- else %} timeout server 30000 -{% endif -%} +{%- endif %} listen stats {{ stat_port }} mode http