From 1314f345fac2695ce1aef180880d6b1beb630a83 Mon Sep 17 00:00:00 2001 From: David Vallee Delisle Date: Wed, 27 Oct 2021 09:45:20 -0400 Subject: [PATCH] [ovn] Deleting ovn agents during scale down tasks When we scale down nodes, we need to make sure that the ovn agents are deleted otherwise it's going to cause issues. Related: https://bugzilla.redhat.com/show_bug.cgi?id=2017827 Closes-Bug: #1949203 Change-Id: I9a253e77178bfe1cdd867a31e8b9adc310238819 --- .../ovn/ovn-controller-container-puppet.yaml | 44 +++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/deployment/ovn/ovn-controller-container-puppet.yaml b/deployment/ovn/ovn-controller-container-puppet.yaml index 25da994f27..6707a48df3 100644 --- a/deployment/ovn/ovn-controller-container-puppet.yaml +++ b/deployment/ovn/ovn-controller-container-puppet.yaml @@ -428,3 +428,47 @@ outputs: ovn_bridge_mappings: {get_attr: [OVNBridgeMappingsValue, value, ovn_bridge_mappings]} ovn_static_bridge_mac_mappings: {get_attr: [OVNBridgeMappingsValue, value, ovn_static_bridge_mac_mappings]} upgrade_tasks: [] + scale_tasks: + - when: + - step|int == 1 + - container_cli == 'podman' + tags: down + environment: + OS_CLOUD: {get_param: RootStackName} + block: + # Some tasks are running from the Undercloud which has + # the OpenStack clients installed. + - name: Get neutron agents ID + command: openstack network agent list --column ID --column Host --column Binary --format yaml + register: neutron_agents_result + delegate_to: "{{ groups['Undercloud'] | first }}" + check_mode: false + changed_when: false + - name: Filter only current host + set_fact: + neutron_agents: "{{ neutron_agents_result.stdout | from_yaml | selectattr('Host', 'match', ansible_facts['fqdn'] ~ '.*') | list }}" + delegate_to: "{{ groups['Undercloud'] | first }}" + check_mode: false + - name: Deleting OVN agents + block: + - name: Stop OVN containers + loop: + - tripleo_ovn_controller + - tripleo_ovn_metadata_agent + service: + name: "{{ item }}" + state: stopped + enabled: false + become: true + register: stop_containers + failed_when: "('msg' in stop_containers and + 'Could not find the requested service' not in stop_containers.msg) or + ('rc' in stop_containers and stop_containers.rc != 0)" + - name: Delete neutron agents + loop: "{{ neutron_agents }}" + loop_control: + loop_var: agent + label: "{{ agent.Host }}/{{ agent.Binary }}" + command: openstack network agent delete {{ agent.ID }} + delegate_to: "{{ groups['Undercloud'] | first }}" + check_mode: false