Scott Shambarger aea9bf3550 monasca-thresh: Fix topology submission to storm
monasca-thresh currently runs a local copy of the storm
to handle the threshold topology.  However, it doesn't setup
the environment correctly, and the executable fails, causing
the container to continually restart.

This patch updates the container command to correctly
submit the topology to the running Apache storm.  The
container will exit after it finishes the submission,
so the restart_policy is updated to on-failure, this way
if the storm is temporarily unavailable, the submission
will be retried. (NOTE: further deploys will see the
container as "changed" as it won't be running)

Patch uses KOLLA_BOOTSTRAP to trigger the container to
check if the topology is already submitted, and if so skips
the submission command so the container doesn't fail.

The config task now triggers a new reconfigure handler that
spawns a one-shot container to replace any existing topology
if the configuration has changed.

Also, all the storm.* variables in storm.yml.j2 are
removed as they were only needed for local mode and
make submitted topologies fail to load when the storm
is restarted (the referenced directories not mounted
on nimbus).

Depends-On: https://review.opendev.org/c/openstack/kolla/+/792751
Closes-Bug: #1808805
Change-Id: Ib225d76076782d695c9387e1c2693bae9a4521d7
2021-06-06 13:41:29 -07:00

350 lines
11 KiB
YAML

---
- name: Ensuring config directories exist
file:
path: "{{ node_config_directory }}/{{ item.key }}"
state: "directory"
owner: "{{ config_owner_user }}"
group: "{{ config_owner_group }}"
mode: "0770"
become: true
when:
- inventory_hostname in groups[item.value.group]
- item.value.enabled | bool
with_dict: "{{ monasca_services }}"
- include_tasks: copy-certs.yml
when:
- kolla_copy_ca_into_containers | bool
- name: Copying over config.json files for services
template:
src: "{{ item.key }}/{{ item.key }}.json.j2"
dest: "{{ node_config_directory }}/{{ item.key }}/config.json"
mode: "0660"
become: true
when:
- inventory_hostname in groups[item.value.group]
- item.value.enabled | bool
with_dict: "{{ monasca_services }}"
notify:
- "Restart {{ item.key }} container"
- name: Copying over monasca-agent-collector config
vars:
service: "{{ monasca_services['monasca-agent-collector'] }}"
merge_yaml:
sources:
- "{{ role_path }}/templates/monasca-agent-collector/{{ item }}.j2"
- "{{ node_custom_config }}/monasca/{{ item }}"
- "{{ node_custom_config }}/monasca/{{ inventory_hostname }}/{{ item }}"
dest: "{{ node_config_directory }}/monasca-agent-collector/{{ item }}"
mode: "0660"
become: true
with_items:
- agent-collector.yml
when:
- inventory_hostname in groups[service['group']]
- service.enabled | bool
notify:
- Restart monasca-agent-collector container
- name: Ensuring monasca-agent collector plugin config directory exists
vars:
service: "{{ monasca_services['monasca-agent-collector'] }}"
file:
path: "{{ node_config_directory }}/monasca-agent-collector/plugins"
state: "directory"
owner: "{{ config_owner_user }}"
group: "{{ config_owner_group }}"
mode: "0770"
become: true
when:
- inventory_hostname in groups[service['group']]
- service.enabled | bool
- name: Find monasca-agent-collector plugin configuration files
find:
paths:
- "{{ role_path }}/templates/monasca-agent-collector/plugins/"
- "{{ node_custom_config }}/monasca/agent_plugins/"
- "{{ node_custom_config }}/monasca/{{ inventory_hostname }}/agent_plugins/"
patterns: '*.yaml'
delegate_to: localhost
register: agent_plugins
- name: Copying over monasca-agent-collector plugins
vars:
service: "{{ monasca_services['monasca-agent-collector'] }}"
template:
src: "{{ item.path }}"
dest: "{{ node_config_directory }}/monasca-agent-collector/plugins/{{ item.path | basename }}"
mode: "0660"
become: true
with_items:
"{{ agent_plugins.files }}"
when:
- inventory_hostname in groups[service['group']]
- service.enabled | bool
notify:
- Restart monasca-agent-collector container
- name: Copying over monasca-agent-forwarder config
vars:
service: "{{ monasca_services['monasca-agent-forwarder'] }}"
merge_yaml:
sources:
- "{{ role_path }}/templates/monasca-agent-forwarder/{{ item }}.j2"
- "{{ node_custom_config }}/monasca/{{ item }}"
- "{{ node_custom_config }}/monasca/{{ inventory_hostname }}/{{ item }}"
dest: "{{ node_config_directory }}/monasca-agent-forwarder/{{ item }}"
mode: "0660"
become: true
with_items:
- agent-forwarder.yml
when:
- inventory_hostname in groups[service['group']]
- service.enabled | bool
notify:
- Restart monasca-agent-forwarder container
- name: Copying over monasca-agent-statsd config
vars:
service: "{{ monasca_services['monasca-agent-statsd'] }}"
merge_yaml:
sources:
- "{{ role_path }}/templates/monasca-agent-statsd/{{ item }}.j2"
- "{{ node_custom_config }}/monasca/{{ item }}"
- "{{ node_custom_config }}/monasca/{{ inventory_hostname }}/{{ item }}"
dest: "{{ node_config_directory }}/monasca-agent-statsd/{{ item }}"
mode: "0660"
become: true
with_items:
- agent-statsd.yml
when:
- inventory_hostname in groups[service['group']]
- service.enabled | bool
notify:
- Restart monasca-agent-statsd container
- name: Copying over monasca-api config
vars:
service: "{{ monasca_services['monasca-api'] }}"
merge_configs:
sources:
- "{{ role_path }}/templates/monasca-api/{{ item }}.j2"
- "{{ node_custom_config }}/monasca/{{ item }}"
- "{{ node_custom_config }}/monasca/{{ inventory_hostname }}/{{ item }}"
dest: "{{ node_config_directory }}/monasca-api/{{ item }}"
mode: "0660"
become: true
with_items:
- api.conf
- api-config.ini
when:
- inventory_hostname in groups[service['group']]
- service.enabled | bool
notify:
- Restart monasca-api container
- name: Copying over monasca-api wsgi config
vars:
service: "{{ monasca_services['monasca-api'] }}"
template:
src: "{{ role_path }}/templates/monasca-api/wsgi-api.conf.j2"
dest: "{{ node_config_directory }}/monasca-api/wsgi-api.conf"
mode: "0660"
become: true
when:
- inventory_hostname in groups[service['group']]
- service.enabled | bool
notify:
- Restart monasca-api container
- name: Ensuring logstash patterns folder exists
vars:
service: "{{ monasca_services['monasca-log-persister'] }}"
file:
path: "{{ node_config_directory }}/monasca-log-persister/logstash_patterns"
state: "directory"
mode: "0770"
become: true
when:
- inventory_hostname in groups[service['group']]
- service.enabled | bool
- name: Find custom logstash patterns
find:
path: "{{ node_custom_config }}/monasca/logstash_patterns"
pattern: "*"
delegate_to: localhost
run_once: True
register: monasca_custom_logstash_patterns
- name: Copying over custom logstash patterns
vars:
service: "{{ monasca_services['monasca-log-persister'] }}"
template:
src: "{{ item.path }}"
dest: "{{ node_config_directory }}/monasca-log-persister/logstash_patterns/{{ item.path | basename }}"
mode: "0660"
with_items: "{{ monasca_custom_logstash_patterns.files }}"
become: true
when:
- inventory_hostname in groups[service['group']]
- service.enabled | bool
notify:
- Restart monasca-log-persister container
- name: Copying over monasca-log-persister config
vars:
service: "{{ monasca_services['monasca-log-persister'] }}"
template:
src: "{{ item }}"
dest: "{{ node_config_directory }}/monasca-log-persister/log-persister.conf"
mode: "0660"
become: true
with_first_found:
- "{{ node_custom_config }}/monasca/{{ inventory_hostname }}/log-persister.conf"
- "{{ node_custom_config }}/monasca/log-persister.conf"
- "{{ role_path }}/templates/monasca-log-persister/log-persister.conf.j2"
when:
- inventory_hostname in groups[service['group']]
- service.enabled | bool
notify:
- Restart monasca-log-persister container
- name: Copying over monasca-log-persister elasticsearch template
vars:
service: "{{ monasca_services['monasca-log-persister'] }}"
template:
src: "{{ item }}"
dest: "{{ node_config_directory }}/monasca-log-persister/elasticsearch-template.json"
mode: "0660"
become: true
with_first_found:
- "{{ node_custom_config }}/monasca/{{ inventory_hostname }}/elasticsearch-template.json"
- "{{ node_custom_config }}/monasca/elasticsearch-template.json"
- "{{ role_path }}/templates/monasca-log-persister/elasticsearch-template.json"
when:
- inventory_hostname in groups[service['group']]
- service.enabled | bool
notify:
- Restart monasca-log-persister container
- name: Copying over monasca-log-metrics config
vars:
service: "{{ monasca_services['monasca-log-metrics'] }}"
template:
src: "{{ item }}"
dest: "{{ node_config_directory }}/monasca-log-metrics/log-metrics.conf"
mode: "0660"
become: true
with_first_found:
- "{{ node_custom_config }}/monasca/{{ inventory_hostname }}/log-metrics.conf"
- "{{ node_custom_config }}/monasca/log-metrics.conf"
- "{{ role_path }}/templates/monasca-log-metrics/log-metrics.conf.j2"
when:
- inventory_hostname in groups[service['group']]
- service.enabled | bool
notify:
- Restart monasca-log-metrics container
- name: Copying over monasca-thresh config
vars:
service: "{{ monasca_services['monasca-thresh'] }}"
# NOTE(dszumski): We can't use merge_yaml since it replaces empty values
# with `null`. This breaks the thresholder config file parsing (which should
# probably be more robust).
template:
src: "{{ item }}"
dest: "{{ node_config_directory }}/monasca-thresh/thresh-config.yml"
mode: "0660"
become: true
with_first_found:
- "{{ node_custom_config }}/monasca/{{ inventory_hostname }}/thresh-config.yml"
- "{{ node_custom_config }}/monasca/thresh-config.yml"
- "{{ role_path }}/templates/monasca-thresh/thresh-config.yml.j2"
when:
- inventory_hostname in groups[service['group']]
- service.enabled | bool
notify:
- Resubmitting monasca-thresh topology
- name: Copying over monasca-thresh storm config
vars:
service: "{{ monasca_services['monasca-thresh'] }}"
template:
src: "{{ item }}"
dest: "{{ node_config_directory }}/monasca-thresh/storm.yml"
mode: "0660"
become: true
with_first_found:
- "{{ node_custom_config }}/monasca/{{ inventory_hostname }}/storm.yml"
- "{{ node_custom_config }}/monasca/storm.yml"
- "{{ role_path }}/templates/monasca-thresh/storm.yml.j2"
when:
- inventory_hostname in groups[service['group']]
- service.enabled | bool
notify:
- Resubmitting monasca-thresh topology
- name: Copying over monasca-notification config
vars:
service: "{{ monasca_services['monasca-notification'] }}"
merge_configs:
sources:
- "{{ role_path }}/templates/monasca-notification/{{ item }}.j2"
- "{{ node_custom_config }}/monasca/{{ item }}"
- "{{ node_custom_config }}/monasca/{{ inventory_hostname }}/{{ item }}"
dest: "{{ node_config_directory }}/monasca-notification/{{ item }}"
mode: "0660"
become: true
with_items:
- notification.conf
when:
- inventory_hostname in groups[service['group']]
- service.enabled | bool
notify:
- Restart monasca-notification container
- name: Check for monasca-notification templates
stat:
path: "{{ node_custom_config }}/monasca/notification_templates"
delegate_to: localhost
run_once: True
register: notification_templates
- name: Copying over monasca-notification templates
vars:
service: "{{ monasca_services['monasca-notification'] }}"
copy:
src: "{{ node_custom_config }}/monasca/notification_templates"
dest: "{{ node_config_directory }}/monasca-notification/"
mode: "0660"
become: true
when:
- notification_templates.stat.exists and notification_templates.stat.isdir
- inventory_hostname in groups[service['group']]
- service.enabled | bool
notify:
- Restart monasca-notification container
- name: Copying over monasca-persister config
vars:
service: "{{ monasca_services['monasca-persister'] }}"
merge_configs:
sources:
- "{{ role_path }}/templates/monasca-persister/{{ item }}.j2"
- "{{ node_custom_config }}/monasca/{{ item }}"
- "{{ node_custom_config }}/monasca/{{ inventory_hostname }}/{{ item }}"
dest: "{{ node_config_directory }}/monasca-persister/{{ item }}"
mode: "0660"
become: true
with_items:
- persister.conf
when:
- inventory_hostname in groups[service['group']]
- service.enabled | bool
notify:
- Restart monasca-persister container