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: (PSKD-398) Update v4m storage class deletion behavior #559

Merged
merged 4 commits into from
Jul 12, 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
27 changes: 26 additions & 1 deletion roles/monitoring/tasks/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -50,15 +50,40 @@
tags:
- cluster-logging

- name: V4M - check if storage class is being used
ansible.builtin.shell: |
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a note, used shell here rather than the ansible kubernetes.core.k8s_info module since PVs are not filterable using field selectors. This was the cleanest way to search if any PVs using a particular SC that I found.

Field Selector Support: https://kubernetes.io/docs/concepts/overview/working-with-objects/field-selectors/#list-of-supported-fields

kubectl --kubeconfig {{ KUBECONFIG }} get pv --output=custom-columns='PORT:.spec.storageClassName' | grep -o v4m | wc -l
register: sc_users
when:
- PROVIDER is not none
- PROVIDER in ["azure","aws","gcp"]
- V4_CFG_MANAGE_STORAGE is not none
- V4_CFG_MANAGE_STORAGE|bool
tags:
- uninstall

- name: V4M - storageclass uninstall status
ansible.builtin.debug:
msg: "Persistent Volumes still referring to the v4m Storage Class, skipping deletion"
when:
- PROVIDER is not none
- PROVIDER in ["azure","aws","gcp"]
- V4_CFG_MANAGE_STORAGE is not none
- V4_CFG_MANAGE_STORAGE|bool
- sc_users.stdout | int > 0
tags:
- uninstall

- name: V4M - remove storageclass
kubernetes.core.k8s:
kubeconfig: "{{ KUBECONFIG }}"
state: absent
src: "{{ role_path }}/files/{{ PROVIDER }}-storageclass.yaml"
when:
- PROVIDER is not none
- PROVIDER == "azure"
- PROVIDER in ["azure","aws","gcp"]
- V4_CFG_MANAGE_STORAGE is not none
- V4_CFG_MANAGE_STORAGE|bool
- sc_users.stdout | int == 0
tags:
- uninstall
Loading