Merge "Add way to change weight of haproxy backend per service"

This commit is contained in:
Zuul 2021-09-28 12:22:55 +00:00 committed by Gerrit Code Review
commit 56938253a7
3 changed files with 33 additions and 1 deletions

View File

@ -93,7 +93,12 @@ backend {{ service_name }}_back
{% for host in groups[host_group] %}
{% set host_name = hostvars[host].ansible_facts.hostname %}
{% set host_ip = 'api' | kolla_address(host) %}
server {{ host_name }} {{ host_ip }}:{{ listen_port }} {{ haproxy_health_check_final }} {{ backend_tls_info }}
{% set service_weight = 'haproxy_' + service_name + '_weight' %}
{% set backend_weight_info = '' %}
{% if hostvars[host][service_weight] is defined and hostvars[host][service_weight] | int != 0 and hostvars[host][service_weight] <= 256 %}
{% set backend_weight_info = 'weight %s'|format(hostvars[host][service_weight]) %}
{% endif %}
server {{ host_name }} {{ host_ip }}:{{ listen_port }} {{ haproxy_health_check_final }} {{ backend_tls_info }} {{ backend_weight_info }}
{% endfor %}
{% endif %}
{% endmacro %}

View File

@ -45,3 +45,20 @@ This is especially helpful for connections to MariaDB. See
`here <https://blog.cloudflare.com/when-tcp-sockets-refuse-to-die/>`__ and
`here <https://access.redhat.com/solutions/726753>`__ for
further information about this kernel option.
Backend weights
---------------
When different baremetal are used in infrastructure as haproxy backends
or they are overloaded for some reason, kolla-ansible is able to change
weight of backend per sevice. Weight can be any integer value from 1 to
256.
To set weight of backend per service, modify inventory file as below:
.. code-block:: ini
[control]
server1 haproxy_nova_api_weight=10
server2 haproxy_nova_api_weight=2 haproxy_keystone_internal_weight=10
server3 haproxy_keystone_admin_weight=50

View File

@ -0,0 +1,10 @@
---
features:
- |
The haproxy-config role now allows user to set weight per
haproxy's backend. This can be achieved by setting a hostvar
``haproxy_{{ service }}_weight`` in inventory file to any integer
value in range from 1 to 256, so the higher the weight, the higher
the load. This can be set per ``{{ service }}``. If hostvar is not
specified, backend's weight is not rendered in final haproxy
configuration.