From 89df07e8efda2a284ce357ddd91011e9fc4c5060 Mon Sep 17 00:00:00 2001 From: Mark Goddard Date: Mon, 23 Mar 2020 17:18:56 +0000 Subject: [PATCH] Fix kolla-ansible stop with heterogeneous hosts The 'kolla-ansible stop' command can be used to stop the services running on hosts. However, if you run this command in an environment with heterogeneous nodes (most real world scenarios have at least control/compute), then it fails. This is because it only checks whether a container is enabled, and not whether the host is in the correct group. For example, it fails with nova-libvirt: No such container: nova_libvirt to stop. This change fixes the issue by only attempting to stop containers on hosts to which they are mapped. Change-Id: Ibecac60d1417269bbe25a280996ca9de6e6d018f Closes-Bug: #1868596 --- ansible/roles/common/defaults/main.yml | 3 +++ ansible/roles/service-stop/tasks/main.yml | 3 +-- releasenotes/notes/fix-stop-602430003e8b3c42.yaml | 6 ++++++ 3 files changed, 10 insertions(+), 2 deletions(-) create mode 100644 releasenotes/notes/fix-stop-602430003e8b3c42.yaml diff --git a/ansible/roles/common/defaults/main.yml b/ansible/roles/common/defaults/main.yml index 455dd41230..390ae29a2a 100644 --- a/ansible/roles/common/defaults/main.yml +++ b/ansible/roles/common/defaults/main.yml @@ -8,6 +8,7 @@ common_run: False common_services: fluentd: container_name: fluentd + group: all enabled: "{{ enable_fluentd | bool }}" image: "{{ fluentd_image_full }}" environment: @@ -16,6 +17,7 @@ common_services: dimensions: "{{ fluentd_dimensions }}" kolla-toolbox: container_name: kolla_toolbox + group: all enabled: True image: "{{ kolla_toolbox_image_full }}" environment: @@ -27,6 +29,7 @@ common_services: # DUMMY_ENVIRONMENT is needed because empty environment is not supported cron: container_name: cron + group: all enabled: True image: "{{ cron_image_full }}" environment: diff --git a/ansible/roles/service-stop/tasks/main.yml b/ansible/roles/service-stop/tasks/main.yml index d65f438ce4..c8e5604c6f 100644 --- a/ansible/roles/service-stop/tasks/main.yml +++ b/ansible/roles/service-stop/tasks/main.yml @@ -8,6 +8,5 @@ common_options: "{{ docker_common_options }}" name: "{{ service.container_name }}" when: - - service.enabled | bool - service.container_name not in skip_stop_containers - with_dict: "{{ project_services }}" + with_dict: "{{ project_services | select_services_enabled_and_mapped_to_host }}" diff --git a/releasenotes/notes/fix-stop-602430003e8b3c42.yaml b/releasenotes/notes/fix-stop-602430003e8b3c42.yaml new file mode 100644 index 0000000000..a3c0c5f4dd --- /dev/null +++ b/releasenotes/notes/fix-stop-602430003e8b3c42.yaml @@ -0,0 +1,6 @@ +--- +fixes: + - | + Fixes an issue with the ``kolla-ansible stop`` command where it may fail + trying to stop non-existent containers. `LP#1868596 + `__.