Skip to content

Commit 37273ae

Browse files
authored
Stop exabgp processes before remove PTF container (for both old and new exabgp process naming convention) (#7587)
What is the motivation for this PR? While removing topo of a testbed, we have to ensure that all the exabgp processes are stopped before PTF container be removed: * For old naming convention, exabgp processes are named like exabgp-ARISTA01T0 and exabgp-ARISTA01T0-v6. * For new naming convention, exabgp processes are named like exabgpv4:exabgp-ARISTA01T0 and exabgpv6:exabgp-ARISTA01T0-v6. In this PR, I added some check to ensure both type of exabgp processes are stopped. How did you do it? 1. For the new naming convention, use ansible supervisor module to stop process group exabgpv4 and exabgpv6. 2. For the old naming convention, use exabgp.py library to stop processes one by one. How did you verify/test it? Verified on both type of PTF containers. Signed-off-by: Zhijian Li <[email protected]>
1 parent d15d4df commit 37273ae

1 file changed

Lines changed: 52 additions & 1 deletion

File tree

ansible/roles/vm_set/tasks/announce_routes.yml

Lines changed: 52 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,16 +131,67 @@
131131
ignore_errors: true
132132
delegate_to: localhost
133133

134-
- block:
134+
- name: Check and stop exabgp processes on PTF
135+
block:
136+
- name: Check exabgp processes for IPv4 running on PTF
137+
shell: "supervisorctl status exabgpv4:* | grep RUNNING | wc -l"
138+
register: exabgpv4_running
139+
delegate_to: "{{ ptf_host }}"
140+
135141
- name: Stop exabgp processes for IPv4 on PTF
136142
supervisorctl:
137143
name: "exabgpv4:"
138144
state: stopped
139145
delegate_to: "{{ ptf_host }}"
146+
when: exabgpv4_running.stdout|int > 0
147+
148+
- name: Check exabgp processes for IPv6 running on PTF
149+
shell: "supervisorctl status exabgpv6:* | grep RUNNING | wc -l"
150+
register: exabgpv6_running
151+
delegate_to: "{{ ptf_host }}"
140152

141153
- name: Stop exabgp processes for IPv6 on PTF
142154
supervisorctl:
143155
name: "exabgpv6:"
144156
state: stopped
145157
delegate_to: "{{ ptf_host }}"
158+
when: exabgpv6_running.stdout|int > 0
159+
160+
- name: Check and stop exabgp processes on PTF (for old naming convention)
161+
block:
162+
- name: Check if exabgp processes running on PTF (for old naming convention)
163+
shell: "supervisorctl status | grep RUNNING | grep ^exabgp-.* | wc -l"
164+
register: exabgp_running_old
165+
delegate_to: "{{ ptf_host }}"
166+
167+
- name: Stop exabgp processes for IPv4 on PTF (for old naming convention)
168+
exabgp:
169+
name: "{{ vm_item.key }}"
170+
state: "stopped"
171+
loop: "{{ topology['VMs']|dict2items }}"
172+
loop_control:
173+
loop_var: vm_item
174+
delegate_to: "{{ ptf_host }}"
175+
when: exabgp_running_old.stdout|int > 0
176+
177+
- name: Stop exabgp processes for IPv6 on PTF (for old naming convention)
178+
exabgp:
179+
name: "{{ vm_item.key }}-v6"
180+
state: "stopped"
181+
loop: "{{ topology['VMs']|dict2items }}"
182+
loop_control:
183+
loop_var: vm_item
184+
delegate_to: "{{ ptf_host }}"
185+
when: exabgp_running_old.stdout|int > 0
186+
187+
- name: Get count of exabgp processes running on PTF
188+
shell: "supervisorctl status | grep RUNNING | grep ^exabgp.* | wc -l"
189+
register: exabgp_running
190+
delegate_to: "{{ ptf_host }}"
191+
192+
- name: Verify no exabgp processes running on PTF
193+
assert:
194+
that: exabgp_running.stdout|int == 0
195+
fail_msg: "exabgp processes are still running on PTF, please check manually"
196+
146197
when: exabgp_action == 'stop' and ptf_accessible is defined and not ptf_accessible.failed

0 commit comments

Comments
 (0)