Merge "Fix for situation when haproxy has nothing for listen to"
diff --git a/.kitchen.travis.yml b/.kitchen.travis.yml
deleted file mode 100644
index 82923c2..0000000
--- a/.kitchen.travis.yml
+++ /dev/null
@@ -1,6 +0,0 @@
-suites:
-
- - name: <%= ENV['SUITE'] %>
- provisioner:
- pillars-from-files:
- haproxy.sls: tests/pillar/<%= ENV['SUITE'] %>.sls
diff --git a/.travis.yml b/.travis.yml
index 77b9e3c..9846a72 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -19,12 +19,12 @@
env:
- PLATFORM=trevorj/salty-whales:trusty SUITE=admin
- PLATFORM=trevorj/salty-whales:xenial SUITE=admin
- - PLATFORM=trevorj/salty-whales:trusty SUITE=single_contrail
- - PLATFORM=trevorj/salty-whales:xenial SUITE=single_contrail
- - PLATFORM=trevorj/salty-whales:trusty SUITE=single_general_service
- - PLATFORM=trevorj/salty-whales:xenial SUITE=single_general_service
- - PLATFORM=trevorj/salty-whales:trusty SUITE=single_openstack_service
- - PLATFORM=trevorj/salty-whales:xenial SUITE=single_openstack_service
+ - PLATFORM=trevorj/salty-whales:trusty SUITE=single-contrail
+ - PLATFORM=trevorj/salty-whales:xenial SUITE=single-contrail
+ - PLATFORM=trevorj/salty-whales:trusty SUITE=single-general-service
+ - PLATFORM=trevorj/salty-whales:xenial SUITE=single-general-service
+ - PLATFORM=trevorj/salty-whales:trusty SUITE=single-openstack-service
+ - PLATFORM=trevorj/salty-whales:xenial SUITE=single-openstack-service
- PLATFORM=trevorj/salty-whales:trusty SUITE=stats
- PLATFORM=trevorj/salty-whales:xenial SUITE=stats
@@ -33,7 +33,8 @@
- make test | tail
script:
- - KITCHEN_LOCAL_YAML=.kitchen.travis.yml bundle exec kitchen test -t tests/integration
+ - test ! -e .kitchen.yml || bundle exec kitchen converge ${SUITE} || true
+ - test ! -e .kitchen.yml || bundle exec kitchen verify ${SUITE} -t tests/integration
notifications:
webhooks:
diff --git a/README.rst b/README.rst
index da53030..06fd886 100644
--- a/README.rst
+++ b/README.rst
@@ -54,19 +54,19 @@
connect: 5000
client: 50000
server: 50000
- listens:
- - name: https-in
- bind:
- address: 0.0.0.0
- port: 443
- servers:
- - name: server1
- host: 10.0.0.1
- port: 8443
- - name: server2
- host: 10.0.0.2
- port: 8443
- params: 'maxconn 256'
+ listen:
+ https-in:
+ binds:
+ - address: 0.0.0.0
+ port: 443
+ servers:
+ - name: server1
+ host: 10.0.0.1
+ port: 8443
+ - name: server2
+ host: 10.0.0.2
+ port: 8443
+ params: 'maxconn 256'
Sample pillar with custom logging
@@ -83,19 +83,19 @@
connect: 5000
client: 50000
server: 50000
- listens:
- - name: https-in
- bind:
- address: 0.0.0.0
- port: 443
- servers:
- - name: server1
- host: 10.0.0.1
- port: 8443
- - name: server2
- host: 10.0.0.2
- port: 8443
- params: 'maxconn 256'
+ listen:
+ https-in:
+ binds:
+ address: 0.0.0.0
+ port: 443
+ servers:
+ - name: server1
+ host: 10.0.0.1
+ port: 8443
+ - name: server2
+ host: 10.0.0.2
+ port: 8443
+ params: 'maxconn 256'
.. code-block:: yaml
@@ -105,53 +105,53 @@
mode: tcp
logging: syslog
max_connections: 1024
- listens:
- - name: mysql
- type: mysql
- binds:
- - address: 10.0.88.70
- port: 3306
- servers:
- - name: node1
- host: 10.0.88.13
- port: 3306
- params: check inter 15s fastinter 2s downinter 1s rise 5 fall 3
- - name: node2
- host: 10.0.88.14
- port: 3306
- params: check inter 15s fastinter 2s downinter 1s rise 5 fall 3 backup
- - name: node3
- host: 10.0.88.15
- port: 3306
- params: check inter 15s fastinter 2s downinter 1s rise 5 fall 3 backup
- - name: rabbitmq
- type: rabbitmq
- binds:
- - address: 10.0.88.70
- port: 5672
- servers:
- - name: node1
- host: 10.0.88.13
- port: 5673
- params: check inter 5000 rise 2 fall 3
- - name: node2
- host: 10.0.88.14
- port: 5673
- params: check inter 5000 rise 2 fall 3 backup
- - name: node3
- host: 10.0.88.15
- port: 5673
- params: check inter 5000 rise 2 fall 3 backup
- -name: keystone-1
- type: general-service
- bins:
- - address: 10.0.106.170
- port: 5000
- servers:
- -name: node1
- host: 10.0.88.13
- port: 5000
- params: check
+ listen:
+ mysql:
+ type: mysql
+ binds:
+ - address: 10.0.88.70
+ port: 3306
+ servers:
+ - name: node1
+ host: 10.0.88.13
+ port: 3306
+ params: check inter 15s fastinter 2s downinter 1s rise 5 fall 3
+ - name: node2
+ host: 10.0.88.14
+ port: 3306
+ params: check inter 15s fastinter 2s downinter 1s rise 5 fall 3 backup
+ - name: node3
+ host: 10.0.88.15
+ port: 3306
+ params: check inter 15s fastinter 2s downinter 1s rise 5 fall 3 backup
+ rabbitmq:
+ type: rabbitmq
+ binds:
+ - address: 10.0.88.70
+ port: 5672
+ servers:
+ - name: node1
+ host: 10.0.88.13
+ port: 5673
+ params: check inter 5000 rise 2 fall 3
+ - name: node2
+ host: 10.0.88.14
+ port: 5673
+ params: check inter 5000 rise 2 fall 3 backup
+ - name: node3
+ host: 10.0.88.15
+ port: 5673
+ params: check inter 5000 rise 2 fall 3 backup
+ keystone-1:
+ type: general-service
+ binds:
+ - address: 10.0.106.170
+ port: 5000
+ servers:
+ - name: node1
+ host: 10.0.88.13
+ port: 5000
+ params: check
.. code-block:: yaml
@@ -161,53 +161,53 @@
mode: tcp
logging: syslog
max_connections: 1024
- listens:
- - name: mysql
- type: mysql
- binds:
- - address: 10.0.88.70
- port: 3306
- servers:
- - name: node1
- host: 10.0.88.13
- port: 3306
- params: check inter 15s fastinter 2s downinter 1s rise 5 fall 3
- - name: node2
- host: 10.0.88.14
- port: 3306
- params: check inter 15s fastinter 2s downinter 1s rise 5 fall 3 backup
- - name: node3
- host: 10.0.88.15
- port: 3306
- params: check inter 15s fastinter 2s downinter 1s rise 5 fall 3 backup
- - name: rabbitmq
- type: rabbitmq
- binds:
- - address: 10.0.88.70
- port: 5672
- servers:
- - name: node1
- host: 10.0.88.13
- port: 5673
- params: check inter 5000 rise 2 fall 3
- - name: node2
- host: 10.0.88.14
- port: 5673
- params: check inter 5000 rise 2 fall 3 backup
- - name: node3
- host: 10.0.88.15
- port: 5673
- params: check inter 5000 rise 2 fall 3 backup
- -name: keystone-1
- type: general-service
- bins:
- - address: 10.0.106.170
- port: 5000
- servers:
- -name: node1
- host: 10.0.88.13
- port: 5000
- params: check
+ listen:
+ mysql:
+ type: mysql
+ binds:
+ - address: 10.0.88.70
+ port: 3306
+ servers:
+ - name: node1
+ host: 10.0.88.13
+ port: 3306
+ params: check inter 15s fastinter 2s downinter 1s rise 5 fall 3
+ - name: node2
+ host: 10.0.88.14
+ port: 3306
+ params: check inter 15s fastinter 2s downinter 1s rise 5 fall 3 backup
+ - name: node3
+ host: 10.0.88.15
+ port: 3306
+ params: check inter 15s fastinter 2s downinter 1s rise 5 fall 3 backup
+ rabbitmq:
+ type: rabbitmq
+ binds:
+ - address: 10.0.88.70
+ port: 5672
+ servers:
+ - name: node1
+ host: 10.0.88.13
+ port: 5673
+ params: check inter 5000 rise 2 fall 3
+ - name: node2
+ host: 10.0.88.14
+ port: 5673
+ params: check inter 5000 rise 2 fall 3 backup
+ - name: node3
+ host: 10.0.88.15
+ port: 5673
+ params: check inter 5000 rise 2 fall 3 backup
+ keystone-1:
+ type: general-service
+ binds:
+ - address: 10.0.106.170
+ port: 5000
+ servers:
+ - name: node1
+ host: 10.0.88.13
+ port: 5000
+ params: check
Custom more complex listener (for Artifactory and subdomains for docker
registries)
@@ -391,6 +391,42 @@
header: X-Real-IP
if-none: false
+Sample pillar with multiprocess multicore configuration
+
+.. code-block:: yaml
+
+ haproxy:
+ proxy:
+ enabled: True
+ nbproc: 4
+ cpu_map:
+ 1: 0
+ 2: 1
+ 3: 2
+ 4: 3
+ stats_bind_process: "1 2"
+ mode: http/tcp
+ logging: syslog
+ maxconn: 1024
+ timeout:
+ connect: 5000
+ client: 50000
+ server: 50000
+ listen:
+ https-in:
+ bind_process: "1 2 3 4"
+ binds:
+ - address: 0.0.0.0
+ port: 443
+ servers:
+ - name: server1
+ host: 10.0.0.1
+ port: 8443
+ - name: server2
+ host: 10.0.0.2
+ port: 8443
+ params: 'maxconn 256'
+
Read more
=========
diff --git a/debian/control b/debian/control
index 7f2b6c1..f4743b4 100644
--- a/debian/control
+++ b/debian/control
@@ -10,6 +10,6 @@
Package: salt-formula-haproxy
Architecture: all
-Depends: ${misc:Depends}, salt-master, reclass
+Depends: ${misc:Depends}
Description: HAproxy salt formula
Configure HAproxy service.
diff --git a/haproxy/files/haproxy.cfg b/haproxy/files/haproxy.cfg
index 1bb2029..f86f379 100644
--- a/haproxy/files/haproxy.cfg
+++ b/haproxy/files/haproxy.cfg
@@ -1,11 +1,20 @@
{%- from "haproxy/map.jinja" import proxy with context -%}
global
+{%- if proxy.nbproc is defined %}
+ nbproc {{ proxy.nbproc }}
+{%- endif %}
+{%- for process, cpu in proxy.get('cpu_map', {}).iteritems() %}
+ cpu-map {{ process }} {{ cpu }}
+{%- endfor %}
log /dev/log local0
log /dev/log local1 notice
chroot /var/lib/haproxy
stats socket {{ proxy.stats_socket }} mode 660 level admin
stats timeout 30s
+{%- if proxy.stats_bind_process is defined %}
+ stats bind-process {{ proxy.stats_bind_process }}
+{%- endif %}
user haproxy
group haproxy
daemon
@@ -68,6 +77,9 @@
{%- for bind in listen.binds %}
bind {{ bind.address }}:{{ bind.port }} {% if bind.get('ssl', {}).enabled|default(False) %}{% if bind.ssl.pem_file is defined %}ssl crt {{ bind.ssl.pem_file }}{% else %}ssl crt /etc/haproxy/ssl/{{ listen_name }}{% endif %}{% endif %}
{%- endfor %}
+ {%- if listen.bind_process is defined %}
+ bind-process {{ listen.bind_process }}
+ {%- endif %}
{%- if listen.get('type', None) == 'http' %}
mode http
balance {{ listen.get('balance', 'roundrobin') }}
diff --git a/tests/pillar/single_general_service.sls b/tests/pillar/single_general_service.sls
index 9887419..ab689e2 100644
--- a/tests/pillar/single_general_service.sls
+++ b/tests/pillar/single_general_service.sls
@@ -4,9 +4,17 @@
mode: tcp
logging: syslog
max_connections: 1024
+ nbproc: 4
+ cpu_map:
+ 1: 0
+ 2: 1
+ 3: 2
+ 4: 3
+ stats_bind_process: "1 2"
listen:
glance_api:
type: openstack-service
+ bind_process: "1 2 3 4"
binds:
- address: 127.0.0.1
port: 9292
diff --git a/tests/run_tests.sh b/tests/run_tests.sh
index c2f7f77..3e3cf91 100755
--- a/tests/run_tests.sh
+++ b/tests/run_tests.sh
@@ -124,7 +124,7 @@
}
salt_run() {
- [ -e ${VEN_DIR}/bin/activate ] && source ${VENV_DIR}/bin/activate
+ [ -e ${VENV_DIR}/bin/activate ] && source ${VENV_DIR}/bin/activate
salt-call ${SALT_OPTS} $*
}