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

fix: ignore pod not found errors when removing kube specs #186

Merged
merged 1 commit into from
Oct 25, 2024
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
13 changes: 13 additions & 0 deletions tasks/cleanup_kube_spec.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,11 @@
path: "{{ __podman_kube_file }}"
register: __podman_kube_file_stat

# NOTE: removing kube specs is not idempotent and will give an error on
# RHEL 8.8 and 9.2 - seems ok on other platforms - this was fixed in the
# module but is not released yet (as of 20241024)
# https://github.com/containers/ansible-podman-collections/pull/863/files#diff-6672fb7f52e2bec3450c2dd7ed9a4385accd9bab8429ea6eecf4d56447f5a1b8R304
# remove this hack when the fix is available
- name: Remove pod/containers
containers.podman.podman_play: "{{ __podman_kube_spec |
combine({'kube_file': __podman_kube_file}) }}"
Expand All @@ -38,9 +43,17 @@
become: "{{ __podman_rootless | ternary(true, omit) }}"
become_user: "{{ __podman_rootless | ternary(__podman_user, omit) }}"
register: __podman_removed
failed_when:
- __podman_removed is failed
- not __podman_removed.msg is search(__err_msg)
- not __is_affected_platform
when:
- not __podman_rootless or __podman_xdg_stat.stat.exists
- __podman_kube_file_stat.stat.exists
vars:
__err_msg: Failed to delete .* with {{ __podman_kube_file }}
__is_affected_platform: "{{ ansible_facts['distribution'] == 'RedHat' and
ansible_facts['distribution_version'] in ['8.8', '9.2'] }}"

- name: Remove kubernetes yaml file
file:
Expand Down
Loading