<commit_before># Legend: name, clear_port, enc_port, prefer_primary_backend, health_check, balance
{% set haproxy_services = [
    [ 'horizon', 8080, 443, false, 'httpchk /', 'source' ],
    [
      'keystone',
      endpoints.keystone.port.backend_api,
      endpoints.keystone.port.haproxy_api,
      endpoints.keystone.haproxy.prefer_primary_backend,
      endpoints.keystone.haproxy.health_check,
      endpoints.keystone.haproxy.balance
    ],
    [
      'keystone-admin',
      endpoints.keystone_admin.port.backend_api,
      endpoints.keystone_admin.port.haproxy_api,
      endpoints.keystone_admin.haproxy.prefer_primary_backend,
      endpoints.keystone_admin.haproxy.health_check,
      endpoints.keystone_admin.haproxy.balance
    ],
    [
      'keystone_legacy',
      endpoints.keystone_legacy.port.backend_api,
      endpoints.keystone_legacy.port.haproxy_api,
      endpoints.keystone_legacy.haproxy.prefer_primary_backend,
      endpoints.keystone_legacy.haproxy.health_check,
      endpoints.keystone_legacy.haproxy.balance
    ],
    [
      'nova',
      endpoints.nova.port.backend_api,
      endpoints.nova.port.haproxy_api,
      endpoints.nova.haproxy.prefer_primary_backend,
      endpoints.nova.haproxy.health_check,
      endpoints.nova.haproxy.balance
    ],
    [
      'novnc',
      endpoints.novnc.port.backend_api,
      endpoints.novnc.port.haproxy_api,
      endpoints.novnc.haproxy.prefer_primary_backend,
      endpoints.novnc.haproxy.health_check,
      endpoints.novnc.haproxy.balance
    ],
    [
      'glance',
      endpoints.glance.port.backend_api,
      endpoints.glance.port.haproxy_api,
      endpoints.glance.haproxy.prefer_primary_backend,
      endpoints.glance.haproxy.health_check,
      endpoints.glance.haproxy.balance
    ],
    [
      'neutron',
      endpoints.neutron.port.backend_api,
      endpoints.neutron.port.haproxy_api,
      endpoints.neutron.haproxy.prefer_primary_backend,
      endpoints.neutron.haproxy.health_check,
      endpoints.neutron.haproxy.balance
    ],
    [
      'cinder',
      endpoints.cinder.port.backend_api,
      endpoints.cinder.port.haproxy_api,
      endpoints.cinder.haproxy.prefer_primary_backend,
      endpoints.cinder.haproxy.health_check,
      endpoints.cinder.haproxy.balance
    ]
  ]
-%}
{% if ceilometer.enabled|default('False')|bool -%}
    {% set _ = haproxy_services.append(['ceilometer',
                                        endpoints.ceilometer.port.backend_api,
                                        endpoints.ceilometer.port.haproxy_api,
                                        endpoints.ceilometer.haproxy.prefer_primary_backend,
                                        endpoints.ceilometer.haproxy.health_check,
                                        endpoints.ceilometer.haproxy.balance ]) %}
{% endif -%}
{% if magnum.enabled|default('False')|bool -%}
    {% set _ = haproxy_services.append(['magnum',
                                        9512,
                                        9511,
                                        false,
                                        'httpchk /',
                                        'source']) %}
{% endif -%}
{% if heat.enabled -%}
    {% set _ = haproxy_services.append(['heat',
                                        endpoints.heat.port.backend_api,
                                        endpoints.heat.port.haproxy_api,
                                        endpoints.heat.haproxy.prefer_primary_backend,
                                        endpoints.heat.haproxy.health_check,
                                        endpoints.heat.haproxy.balance ]) %}
    {% set _ = haproxy_services.append(['heat-cfn',
                                        endpoints.heat_cfn.port.backend_api,
                                        endpoints.heat_cfn.port.haproxy_api,
                                        endpoints.heat_cfn.haproxy.prefer_primary_backend,
                                        endpoints.heat_cfn.haproxy.health_check,
                                        endpoints.heat_cfn.haproxy.balance ]) %}
{% endif -%}
{% if ironic.enabled -%}
    {% set _ = haproxy_services.append(['ironic',
                                        endpoints.ironic.port.backend_api,
                                        endpoints.ironic.port.haproxy_api,
                                        endpoints.ironic.haproxy.prefer_primary_backend,
                                        endpoints.ironic.haproxy.health_check,
                                        endpoints.ironic.haproxy.balance ]) %}
{% endif -%}
{% if ceilometer.enabled|default('False')|bool -%}
    {% set _ = haproxy_services.append(['aodh',
                                        endpoints.aodh.port.backend_api,
                                        endpoints.aodh.port.haproxy_api,
                                        endpoints.aodh.haproxy.prefer_primary_backend,
                                        endpoints.aodh.haproxy.health_check,
                                        endpoints.aodh.haproxy.balance ]) %}
{% endif -%}

global
  log /dev/log local0
  maxconn 256
  user haproxy
  group haproxy
  daemon
  pidfile /var/run/haproxy/haproxy.pid
  tune.bufsize {{ haproxy.bufsize }}
  stats socket /var/run/haproxy/stats.sock mode 770 group {{ haproxy.stats_group }}

defaults
  log global
  mode http
  option httplog
  option dontlognull
  option redispatch
  option forwardfor
  option httpclose # needed for empty reponse body 204's
  timeout client 300s
  timeout server 300s
  timeout connect 1s
  timeout http-keep-alive 60s
  timeout http-request 30s

  stats enable
  stats refresh 10s
  stats uri /haproxy_stats
  stats auth admin:{{ secrets.admin_password }}

{% for name, clear_port, enc_port, prefer_primary_backend, health_check, balance in haproxy_services -%}
frontend {{ name }}
  # Require TLS with AES
  bind :::{{ enc_port }} ssl crt /etc/haproxy/openstack.pem no-sslv3 ciphers AES128-SHA:AES256-SHA
  default_backend {{ name }}
  reqadd X-Forwarded-Proto:\ https
  {% if name=="keystone" -%}
  reqadd X-Forwarded-Port:\ 5000
  {% endif %}

  {% if name == "horizon" -%}
  bind :::80
  redirect scheme https if !{ ssl_fc }
  {% endif -%}

backend {{ name }}

  {% if name == "magnum" -%}
  # option {{ health_check }}
  {% else -%}
  option {{ health_check }}
  {% endif -%}

  balance {{ balance }}
  {% for host in groups['controller'] -%}

  {% if not prefer_primary_backend or hostvars[host][primary_interface]['ipv4']['address'] == primary_ip -%}
    {% if  name == "keystone" -%}
    cookie {{ endpoints.keystone.haproxy.oidc_cookie }}
    server {{ host }} {{ hostvars[host][primary_interface]['ipv4']['address'] }}:{{ clear_port }} cookie check maxconn 40
    {% else -%}
    server {{ host }} {{ hostvars[host][primary_interface]['ipv4']['address'] }}:{{ clear_port }} check maxconn 40
    {% endif -%}
  {% else -%}
    server {{ host }} {{ hostvars[host][primary_interface]['ipv4']['address'] }}:{{ clear_port }} backup check maxconn 40
  {% endif -%}
  {% endfor %}

{% endfor %}<commit_msg>Fix the broken httpcheck check for keystone in haproxy config (#2229)<commit_after># Legend: name, clear_port, enc_port, prefer_primary_backend, health_check, balance
{% set haproxy_services = [
    [ 'horizon', 8080, 443, false, 'httpchk /', 'source' ],
    [
      'keystone',
      endpoints.keystone.port.backend_api,
      endpoints.keystone.port.haproxy_api,
      endpoints.keystone.haproxy.prefer_primary_backend,
      endpoints.keystone.haproxy.health_check,
      endpoints.keystone.haproxy.balance
    ],
    [
      'keystone-admin',
      endpoints.keystone_admin.port.backend_api,
      endpoints.keystone_admin.port.haproxy_api,
      endpoints.keystone_admin.haproxy.prefer_primary_backend,
      endpoints.keystone_admin.haproxy.health_check,
      endpoints.keystone_admin.haproxy.balance
    ],
    [
      'keystone_legacy',
      endpoints.keystone_legacy.port.backend_api,
      endpoints.keystone_legacy.port.haproxy_api,
      endpoints.keystone_legacy.haproxy.prefer_primary_backend,
      endpoints.keystone_legacy.haproxy.health_check,
      endpoints.keystone_legacy.haproxy.balance
    ],
    [
      'nova',
      endpoints.nova.port.backend_api,
      endpoints.nova.port.haproxy_api,
      endpoints.nova.haproxy.prefer_primary_backend,
      endpoints.nova.haproxy.health_check,
      endpoints.nova.haproxy.balance
    ],
    [
      'novnc',
      endpoints.novnc.port.backend_api,
      endpoints.novnc.port.haproxy_api,
      endpoints.novnc.haproxy.prefer_primary_backend,
      endpoints.novnc.haproxy.health_check,
      endpoints.novnc.haproxy.balance
    ],
    [
      'glance',
      endpoints.glance.port.backend_api,
      endpoints.glance.port.haproxy_api,
      endpoints.glance.haproxy.prefer_primary_backend,
      endpoints.glance.haproxy.health_check,
      endpoints.glance.haproxy.balance
    ],
    [
      'neutron',
      endpoints.neutron.port.backend_api,
      endpoints.neutron.port.haproxy_api,
      endpoints.neutron.haproxy.prefer_primary_backend,
      endpoints.neutron.haproxy.health_check,
      endpoints.neutron.haproxy.balance
    ],
    [
      'cinder',
      endpoints.cinder.port.backend_api,
      endpoints.cinder.port.haproxy_api,
      endpoints.cinder.haproxy.prefer_primary_backend,
      endpoints.cinder.haproxy.health_check,
      endpoints.cinder.haproxy.balance
    ]
  ]
-%}
{% if ceilometer.enabled|default('False')|bool -%}
    {% set _ = haproxy_services.append(['ceilometer',
                                        endpoints.ceilometer.port.backend_api,
                                        endpoints.ceilometer.port.haproxy_api,
                                        endpoints.ceilometer.haproxy.prefer_primary_backend,
                                        endpoints.ceilometer.haproxy.health_check,
                                        endpoints.ceilometer.haproxy.balance ]) %}
{% endif -%}
{% if magnum.enabled|default('False')|bool -%}
    {% set _ = haproxy_services.append(['magnum',
                                        9512,
                                        9511,
                                        false,
                                        'httpchk /',
                                        'source']) %}
{% endif -%}
{% if heat.enabled -%}
    {% set _ = haproxy_services.append(['heat',
                                        endpoints.heat.port.backend_api,
                                        endpoints.heat.port.haproxy_api,
                                        endpoints.heat.haproxy.prefer_primary_backend,
                                        endpoints.heat.haproxy.health_check,
                                        endpoints.heat.haproxy.balance ]) %}
    {% set _ = haproxy_services.append(['heat-cfn',
                                        endpoints.heat_cfn.port.backend_api,
                                        endpoints.heat_cfn.port.haproxy_api,
                                        endpoints.heat_cfn.haproxy.prefer_primary_backend,
                                        endpoints.heat_cfn.haproxy.health_check,
                                        endpoints.heat_cfn.haproxy.balance ]) %}
{% endif -%}
{% if ironic.enabled -%}
    {% set _ = haproxy_services.append(['ironic',
                                        endpoints.ironic.port.backend_api,
                                        endpoints.ironic.port.haproxy_api,
                                        endpoints.ironic.haproxy.prefer_primary_backend,
                                        endpoints.ironic.haproxy.health_check,
                                        endpoints.ironic.haproxy.balance ]) %}
{% endif -%}
{% if ceilometer.enabled|default('False')|bool -%}
    {% set _ = haproxy_services.append(['aodh',
                                        endpoints.aodh.port.backend_api,
                                        endpoints.aodh.port.haproxy_api,
                                        endpoints.aodh.haproxy.prefer_primary_backend,
                                        endpoints.aodh.haproxy.health_check,
                                        endpoints.aodh.haproxy.balance ]) %}
{% endif -%}

global
  log /dev/log local0
  maxconn 256
  user haproxy
  group haproxy
  daemon
  pidfile /var/run/haproxy/haproxy.pid
  tune.bufsize {{ haproxy.bufsize }}
  stats socket /var/run/haproxy/stats.sock mode 770 group {{ haproxy.stats_group }}

defaults
  log global
  mode http
  option httplog
  option dontlognull
  option redispatch
  option forwardfor
  option httpclose # needed for empty reponse body 204's
  timeout client 300s
  timeout server 300s
  timeout connect 1s
  timeout http-keep-alive 60s
  timeout http-request 30s

  stats enable
  stats refresh 10s
  stats uri /haproxy_stats
  stats auth admin:{{ secrets.admin_password }}

{% for name, clear_port, enc_port, prefer_primary_backend, health_check, balance in haproxy_services -%}
frontend {{ name }}
  # Require TLS with AES
  bind :::{{ enc_port }} ssl crt /etc/haproxy/openstack.pem no-sslv3 ciphers AES128-SHA:AES256-SHA
  default_backend {{ name }}
  reqadd X-Forwarded-Proto:\ https
  {% if name=="keystone" -%}
  reqadd X-Forwarded-Port:\ 5000
  {% endif %}

  {% if name == "horizon" -%}
  bind :::80
  redirect scheme https if !{ ssl_fc }
  {% endif -%}

backend {{ name }}

  {% if name == "magnum" -%}
  # option {{ health_check }}
  {% else -%}
  option {{ health_check }}
  {% endif -%}

  balance {{ balance }}
  {% for host in groups['controller'] -%}

  {% if not prefer_primary_backend or hostvars[host][primary_interface]['ipv4']['address'] == primary_ip -%}
    {% if  name == "keystone" -%}
    cookie {{ endpoints.keystone.haproxy.oidc_cookie }}
    server {{ host }} {{ hostvars[host][primary_interface]['ipv4']['address'] }}:{{ clear_port }} check maxconn 40 cookie {{ host }}
    {% else -%}
    server {{ host }} {{ hostvars[host][primary_interface]['ipv4']['address'] }}:{{ clear_port }} check maxconn 40
    {% endif -%}
  {% else -%}
    server {{ host }} {{ hostvars[host][primary_interface]['ipv4']['address'] }}:{{ clear_port }} backup check maxconn 40
  {% endif -%}
  {% endfor %}

{% endfor %}
{'fraction_non_alphanumeric': 0.1100988156142687, 'fraction_numerical': 0.008830331487840773, 'mean_word_length': 1.9289819376026272, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 60, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7484605', 'n_tokens_mistral': 4658, 'n_tokens_neox': 4272, 'n_words': 597}