From a71874f24f6da1361a1ccb7958780816e0dbc830 Mon Sep 17 00:00:00 2001 From: Eduardo Gonzalez Date: Thu, 22 Sep 2016 17:27:14 +0200 Subject: [PATCH] Fix mistral service - Add mistral in HAproxy - Set mistral api to bind on api_interface - Fix mistral endpoint - Add database population on bootstraping - Add mistral port prechecks Change-Id: If1617fb9dcd8b3bbd4f94c68ca87c36e39711016 Closes-Bug: #1626570 --- ansible/roles/haproxy/templates/haproxy.cfg.j2 | 16 ++++++++++++++++ ansible/roles/mistral/defaults/main.yml | 6 +++--- ansible/roles/mistral/templates/mistral.conf.j2 | 11 ++++++----- ansible/roles/prechecks/tasks/port_checks.yml | 16 ++++++++++++++++ docker/mistral/mistral-api/extend_start.sh | 1 + 5 files changed, 42 insertions(+), 8 deletions(-) diff --git a/ansible/roles/haproxy/templates/haproxy.cfg.j2 b/ansible/roles/haproxy/templates/haproxy.cfg.j2 index 959e0da358..f95eeddf06 100644 --- a/ansible/roles/haproxy/templates/haproxy.cfg.j2 +++ b/ansible/roles/haproxy/templates/haproxy.cfg.j2 @@ -552,6 +552,22 @@ listen congress_api_external {% endif %} {% endif %} +{% if enable_mistral | bool %} +listen mistral_api + bind {{ kolla_internal_vip_address }}:{{ mistral_api_port }} +{% for host in groups['mistral-api'] %} + server {{ hostvars[host]['ansible_hostname'] }} {{ hostvars[host]['ansible_' + hostvars[host]['api_interface']]['ipv4']['address'] }}:{{ mistral_api_port }} check inter 2000 rise 2 fall 5 +{% endfor %} +{% if haproxy_enable_external_vip | bool %} + +listen mistral_api_external + bind {{ kolla_external_vip_address }}:{{ mistral_api_port }} {{ tls_bind_info }} +{% for host in groups['mistral-api'] %} + server {{ hostvars[host]['ansible_hostname'] }} {{ hostvars[host]['ansible_' + hostvars[host]['api_interface']]['ipv4']['address'] }}:{{ mistral_api_port }} check inter 2000 rise 2 fall 5 +{% endfor %} +{% endif %} +{% endif %} + # (NOTE): This defaults section deletes forwardfor as recomended by: # https://marc.info/?l=haproxy&m=141684110710132&w=1 diff --git a/ansible/roles/mistral/defaults/main.yml b/ansible/roles/mistral/defaults/main.yml index b1e4eb1809..cca068623d 100644 --- a/ansible/roles/mistral/defaults/main.yml +++ b/ansible/roles/mistral/defaults/main.yml @@ -28,9 +28,9 @@ mistral_api_image_full: "{{ mistral_api_image }}:{{ mistral_api_tag }}" #################### # OpenStack #################### -mistral_admin_endpoint: "{{ admin_protocol }}://{{ kolla_internal_fqdn }}:{{ mistral_api_port }}" -mistral_internal_endpoint: "{{ internal_protocol }}://{{ kolla_internal_fqdn }}:{{ mistral_api_port }}" -mistral_public_endpoint: "{{ public_protocol }}://{{ kolla_external_fqdn }}:{{ mistral_api_port }}" +mistral_admin_endpoint: "{{ admin_protocol }}://{{ kolla_internal_fqdn }}:{{ mistral_api_port }}/v2" +mistral_internal_endpoint: "{{ internal_protocol }}://{{ kolla_internal_fqdn }}:{{ mistral_api_port }}/v2" +mistral_public_endpoint: "{{ public_protocol }}://{{ kolla_external_fqdn }}:{{ mistral_api_port }}/v2" mistral_logging_debug: "{{ openstack_logging_debug }}" diff --git a/ansible/roles/mistral/templates/mistral.conf.j2 b/ansible/roles/mistral/templates/mistral.conf.j2 index 7cdbcd35a3..27639dfca0 100644 --- a/ansible/roles/mistral/templates/mistral.conf.j2 +++ b/ansible/roles/mistral/templates/mistral.conf.j2 @@ -7,13 +7,14 @@ log_dir = /var/log/kolla/mistral # stderr and collected by Docker use_stderr = False -{% if service_name == 'mistral-api' %} -bind_host = {{ hostvars[inventory_hostname]['ansible_' + api_interface]['ipv4']['address'] }} -bind_port = {{ mistral_api_port }} -{% endif %} - transport_url = rabbit://{% for host in groups['rabbitmq'] %}{{ rabbitmq_user }}:{{ rabbitmq_password }}@{{ hostvars[host]['ansible_' + hostvars[host]['api_interface']]['ipv4']['address'] }}:{{ rabbitmq_port }}{% if not loop.last %},{% endif %}{% endfor %} +{% if service_name == 'mistral-api' %} +[api] +host = {{ hostvars[inventory_hostname]['ansible_' + api_interface]['ipv4']['address'] }} +port = {{ mistral_api_port }} +{% endif %} + [database] connection = mysql+pymysql://{{ mistral_database_user }}:{{ mistral_database_password }}@{{ mistral_database_address }}/{{ mistral_database_name }} max_retries = -1 diff --git a/ansible/roles/prechecks/tasks/port_checks.yml b/ansible/roles/prechecks/tasks/port_checks.yml index 6c741cd8ac..c0f2bd88f6 100644 --- a/ansible/roles/prechecks/tasks/port_checks.yml +++ b/ansible/roles/prechecks/tasks/port_checks.yml @@ -553,6 +553,22 @@ state: stopped when: inventory_hostname in groups['haproxy'] +- name: Checking free port for Mistral API + wait_for: + host: "{{ hostvars[inventory_hostname]['ansible_' + api_interface]['ipv4']['address'] }}" + port: "{{ mistral_api_port }}" + connect_timeout: 1 + state: stopped + when: inventory_hostname in groups['mistral-api'] + +- name: Checking free port for Mistral API HAProxy + wait_for: + host: "{{ kolla_internal_vip_address }}" + port: "{{ mistral_api_port }}" + connect_timeout: 1 + state: stopped + when: inventory_hostname in groups['haproxy'] + - name: Checking if kolla_internal_vip_address and kolla_external_vip_address are not pingable from any node command: ping -c 3 {{ item }} register: ping_output diff --git a/docker/mistral/mistral-api/extend_start.sh b/docker/mistral/mistral-api/extend_start.sh index 4316395acb..113adb8a21 100644 --- a/docker/mistral/mistral-api/extend_start.sh +++ b/docker/mistral/mistral-api/extend_start.sh @@ -4,5 +4,6 @@ # of the KOLLA_BOOTSTRAP variable being set, including empty. if [[ "${!KOLLA_BOOTSTRAP[@]}" ]]; then mistral-db-manage --config-file /etc/mistral/mistral.conf upgrade head + mistral-db-manage --config-file /etc/mistral/mistral.conf populate exit 0 fi