More containers are restarted when combine with with_dict and notify

Bug #1871548 reported by Xing Zhang
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
kolla-ansible
New
Undecided
Unassigned

Bug Description

**Bug Report**

What happened:
When a container changed, such as we changes configurations in nova-api,
this will restart all nova containers, which is not the expected result
especially in production environment.
See logs at [1] pasted below.

What you expected to happen:
Only restart the one needs to be restarted

How to reproduce it (minimal and precise):
1. create or modify config file in "{{ node_custom_config }}/nova/nova-api.conf"
2. add or change some config
[DEFAULT]
reserved_host_memory_mb = 64
3. deploy/reconfigure/upgrade using kolla-ansible

**Environment**:
config tasks using with_dict and notify after https://review.opendev.org/#/c/647699/
e.g.
some tasks in tasks/config.yml
- name: Copying over extra CA certificates
  become: true
  copy:
    src: "{{ node_config }}/certificates/ca/"
    dest: "{{ node_config_directory }}/{{ item.key }}/ca-certificates"
    mode: "0644"
  when:
    - item.value.enabled | bool
    - inventory_hostname in groups[item.value.group]
    - kolla_copy_ca_into_containers | bool
  with_dict: "{{ nova_services }}"
  notify:
    - "Restart {{ item.key }} container"

- name: Copying over nova.conf
  become: true
  vars:
    service_name: "{{ item.key }}"
  merge_configs:
    sources:
      - "{{ role_path }}/templates/nova.conf.j2"
      - "{{ node_custom_config }}/global.conf"
      - "{{ node_custom_config }}/nova.conf"
      - "{{ node_custom_config }}/nova/{{ item.key }}.conf"
      - "{{ node_custom_config }}/nova/{{ inventory_hostname }}/nova.conf"
    dest: "{{ node_config_directory }}/{{ item.key }}/nova.conf"
    mode: "0660"
  when:
    - inventory_hostname in groups[item.value.group]
    - item.value.enabled | bool
    - item.key in nova_services_require_nova_conf
  with_dict: "{{ nova_services }}"
  notify:
    - "Restart {{ item.key }} container"

[1] ansible logs
TASK [nova : Copying over nova.conf] *****
skipping: [control1] ...
skipping: [control2] ...
...
ok: [control3] ...
...
changed: [control1] ...
...
RUNNING HANDLER [nova : Restart placement-api container] *****
changed: [control1]

RUNNING HANDLER [nova : Restart nova-api container] *****
changed: [control1]

RUNNING HANDLER [nova : Restart nova-scheduler container] *****
changed: [control1]

RUNNING HANDLER [nova : Restart nova-conductor container] *****
changed: [control1]

RUNNING HANDLER [nova : Restart nova-consoleauth container] *****
changed: [control1]

RUNNING HANDLER [nova : Restart nova-novncproxy container] *****
changed: [control1]

Revision history for this message
Xing Zhang (xingzhang) wrote :

Add ansible logs

description: updated
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.