Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve reset #7094

Merged
merged 1 commit into from
Jan 5, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 35 additions & 17 deletions roles/reset/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,20 @@

- name: reset | remove services
file:
path: "/etc/systemd/system/{{ item }}.service"
path: "/etc/systemd/system/{{ item }}"
state: absent
with_items:
- kubelet
- vault
- calico-node
- kubelet.service
- vault.service
- calico-node.service
- containerd.service.d/http-proxy.conf
- crio.service.d/http-proxy.conf
- vault.service.d/http-proxy.conf
register: services_removed
tags:
- services
- containerd
- crio

- name: reset | remove docker dropins
file:
Expand All @@ -30,6 +35,7 @@
- docker-dns.conf
- docker-options.conf
- http-proxy.conf
- docker-orphan-cleanup.conf
register: docker_dropins_removed
tags:
- docker
Expand Down Expand Up @@ -59,8 +65,13 @@
tags:
- docker

- name: reset | check if crictl is present
stat:
path: "{{ bin_dir }}/crictl"
register: crictl

- name: reset | stop all cri containers
shell: "set -o pipefail && {{ bin_dir }}/crictl ps -aq | xargs -r {{ bin_dir }}/crictl -t 60s stop"
shell: "set -o pipefail && {{ bin_dir }}/crictl ps -q | xargs -r {{ bin_dir }}/crictl -t 60s stop"
args:
executable: /bin/bash
register: remove_all_cri_containers
Expand All @@ -70,20 +81,24 @@
tags:
- crio
- containerd
when: container_manager in ["crio", "containerd"]
when:
- crictl.stat.exists
- container_manager in ["crio", "containerd"]
ignore_errors: true

- name: reset | remove all cri containers
shell: "set -o pipefail && {{ bin_dir }}/crictl ps -aq | xargs -r {{ bin_dir }}/crictl -t 60s rm"
args:
executable: /bin/bash
- name: reset | force remove all cri containers
command: "{{ bin_dir }}/crictl rm -a -f"
register: remove_all_cri_containers
retries: 5
until: remove_all_cri_containers.rc == 0
delay: 5
tags:
- crio
- containerd
when: container_manager in ["crio", "containerd"] and deploy_container_engine|default(true)
when:
- crictl.stat.exists
- container_manager in ["crio", "containerd"]
- deploy_container_engine|default(true)

- name: reset | stop and disable crio service
service:
Expand All @@ -109,18 +124,21 @@
until: remove_all_cri_containers.rc == 0
delay: 5
tags: [ containerd ]
when: container_manager == "containerd"
when:
- crictl.stat.exists
- container_manager == "containerd"
ignore_errors: true

- name: reset | remove all cri pods
shell: "set -o pipefail && {{ bin_dir }}/crictl pods -q | xargs -r {{ bin_dir }}/crictl -t 60s rmp"
args:
executable: /bin/bash
- 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: container_manager == "containerd"
when:
- crictl.stat.exists
- container_manager == "containerd"

- name: reset | stop etcd services
service:
Expand Down