From ed2b4b805e937aab8118600d3f83b48fe980d3ff Mon Sep 17 00:00:00 2001
From: Etienne Champetier <e.champetier@ateme.com>
Date: Mon, 22 Feb 2021 15:44:03 -0500
Subject: [PATCH] Fix reset when using containerd (#7308)

Signed-off-by: Etienne Champetier <e.champetier@ateme.com>
---
 roles/reset/tasks/main.yml | 25 +++++++++++++++----------
 1 file changed, 15 insertions(+), 10 deletions(-)

diff --git a/roles/reset/tasks/main.yml b/roles/reset/tasks/main.yml
index c17b096ac..dcc7649cb 100644
--- a/roles/reset/tasks/main.yml
+++ b/roles/reset/tasks/main.yml
@@ -132,16 +132,21 @@
     - container_manager == "containerd"
   ignore_errors: true
 
-- name: reset | force remove all cri pods
-  command: "{{ bin_dir }}/crictl rmp -a -f"
-  register: remove_all_cri_containers
-  retries: 5
-  until: remove_all_cri_containers.rc == 0
-  delay: 5
-  tags: [ containerd ]
-  when:
-    - crictl.stat.exists
-    - container_manager == "containerd"
+- block:
+    - name: reset | force remove all cri pods
+      command: "{{ bin_dir }}/crictl rmp -a -f"
+      register: remove_all_cri_containers
+      retries: 5
+      until: remove_all_cri_containers.rc == 0
+      delay: 5
+      tags: [ containerd ]
+      when:
+        - crictl.stat.exists
+        - container_manager == "containerd"
+
+  rescue:
+    - name: reset | force remove all cri pods (rescue)
+      shell: "ip netns list | cut -d' ' -f 1 | xargs -n1 ip netns delete && {{ bin_dir }}/crictl rmp -a -f"
 
 - name: reset | stop etcd services
   service:
-- 
GitLab