Fix the redis_connection_string for osprofiler and make it generic

* When using redis as the backend of osprofiler, it cannot connect to
redis because the redis_connection_string is incorrect.

* Let other places that use redis also use this variable.

Change-Id: I14de6597932d05cd7f804a35c6764ba4ae9087cd
Closes-Bug: #1833200
Signed-off-by: ZijianGuo <guozijn@gmail.com>
(cherry picked from commit cd836dd39f)
This commit is contained in:
ZijianGuo 2019-06-18 18:05:39 +08:00 committed by Mark Goddard
parent 4f036a6b11
commit f2b3f0acc6
4 changed files with 5 additions and 6 deletions

View File

@ -681,7 +681,7 @@ enable_kibana: "{{ 'yes' if enable_central_logging | bool or enable_monasca | bo
####################
# Redis options
####################
redis_address: "{{ kolla_internal_fqdn }}"
redis_connection_string: "redis://{% for host in groups['redis'] %}{% if host == groups['redis'][0] %}admin:{{ redis_master_password }}@{{ hostvars[host]['ansible_' + hostvars[host]['api_interface']]['ipv4']['address'] }}:{{ redis_sentinel_port }}?sentinel=kolla{% else %}&sentinel_fallback={{ hostvars[host]['ansible_' + hostvars[host]['api_interface']]['ipv4']['address'] }}:{{ redis_sentinel_port }}{% endif %}{% endfor %}&socket_timeout=60&retry_on_timeout=yes"
####################
# Osprofiler options
@ -689,7 +689,6 @@ redis_address: "{{ kolla_internal_fqdn }}"
# valid values: ["elasticsearch", "redis"]
osprofiler_backend: "elasticsearch"
elasticsearch_connection_string: "elasticsearch://{{ elasticsearch_address }}:{{ elasticsearch_port }}"
redis_connection_string: "redis://:{{ redis_master_password }}@{{ redis_address }}:{{ redis_port }}"
osprofiler_backend_connection_string: "{{ redis_connection_string if osprofiler_backend == 'redis' else elasticsearch_connection_string }}"
####################

View File

@ -221,7 +221,7 @@ auth_endpoint = {{ keystone_internal_url }}
[coordination]
{% if enable_redis | bool %}
backend_url = redis://{% for host in groups['redis'] %}{% if host == groups['redis'][0] %}admin:{{ redis_master_password }}@{{ hostvars[host]['ansible_' + hostvars[host]['api_interface']]['ipv4']['address'] }}:{{ redis_sentinel_port }}?sentinel=kolla{% else %}&sentinel_fallback={{ hostvars[host]['ansible_' + hostvars[host]['api_interface']]['ipv4']['address'] }}:{{ redis_sentinel_port }}{% endif %}{% endfor %}&socket_timeout=60&retry_on_timeout=yes
backend_url = {{ redis_connection_string }}
{% elif enable_etcd | bool %}
# NOTE(jeffrey4l): python-etcd3 module do not support multi endpoint here.
backend_url = etcd3://{{ hostvars[groups['etcd'][0]]['ansible_' + hostvars[groups['etcd'][0]]['api_interface']]['ipv4']['address'] }}:{{ etcd_client_port }}

View File

@ -4,7 +4,7 @@ debug = {{ gnocchi_logging_debug }}
log_dir = /var/log/kolla/gnocchi
{% if enable_redis | bool %}
coordination_url = redis://{% for host in groups['redis'] %}{% if host == groups['redis'][0] %}admin:{{ redis_master_password }}@{{ hostvars[host]['ansible_' + hostvars[host]['api_interface']]['ipv4']['address'] }}:{{ redis_sentinel_port }}?sentinel=kolla{% else %}&sentinel_fallback={{ hostvars[host]['ansible_' + hostvars[host]['api_interface']]['ipv4']['address'] }}:{{ redis_sentinel_port }}{% endif %}{% endfor %}&socket_timeout=60&retry_on_timeout=yes
coordination_url = {{ redis_connection_string }}
{% endif %}
{% if service_name == 'gnocchi-api' %}
@ -63,7 +63,7 @@ policy_file = {{ gnocchi_policy_file }}
[incoming]
{% if gnocchi_incoming_storage == 'redis' %}
driver = redis
redis_url = redis://{% for host in groups['redis'] %}{% if host == groups['redis'][0] %}admin:{{ redis_master_password }}@{{ hostvars[host]['ansible_' + hostvars[host]['api_interface']]['ipv4']['address'] }}:{{ redis_sentinel_port }}?sentinel=kolla{% else %}&sentinel_fallback={{ hostvars[host]['ansible_' + hostvars[host]['api_interface']]['ipv4']['address'] }}:{{ redis_sentinel_port }}{% endif %}{% endfor %}&db=0&socket_timeout=60&retry_on_timeout=yes
redis_url = {{ redis_connection_string }}
{% endif %}
[storage]

View File

@ -76,4 +76,4 @@ connection_string = {{ osprofiler_backend_connection_string }}
{% endif %}
[coordination]
backend_url = redis://{% for host in groups['redis'] %}{% if host == groups['redis'][0] %}admin:{{ redis_master_password }}@{{ hostvars[host]['ansible_' + hostvars[host]['api_interface']]['ipv4']['address'] }}:{{ redis_sentinel_port }}?sentinel=kolla{% else %}&sentinel_fallback={{ hostvars[host]['ansible_' + hostvars[host]['api_interface']]['ipv4']['address'] }}:{{ redis_sentinel_port }}{% endif %}{% endfor %}
backend_url = {{ redis_connection_string }}