-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Code enhancement and bug fix in ocp-descheduler role
Signed-off-by: Aditya Honkalas <[email protected]>
- Loading branch information
1 parent
2f8c38f
commit f959f60
Showing
6 changed files
with
115 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
59 changes: 59 additions & 0 deletions
59
playbooks/roles/ocp-descheduler/tasks/descheduler-operator-cleanup.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
--- | ||
|
||
## Descheduler operator cleanup | ||
|
||
- name: Check the given namespace is correct | ||
shell: "oc get namespaces | grep {{ operator_namespace }}" | ||
register: namespace_output | ||
ignore_errors: true | ||
|
||
- name: Operator resource cleanup block | ||
block: | ||
- name: Get the Subscriptions in the {{ operator_namespace }} | ||
shell: oc get subscription {{ operator_subscription }} -n {{ operator_namespace }} | ||
register: subscription_output | ||
|
||
- name: Get the ClusterServiceVersion for operator | ||
shell: oc get subscription {{ operator_subscription }} -n {{ operator_namespace }} -o json | jq '.status.currentCSV' | ||
register: operator_csv | ||
when: subscription_output.stdout != "" | ||
|
||
- name: Get the OperatorGroups in {{ operator_namespace }} | ||
shell: oc get operatorgroup {{ operator_group }} -n {{ operator_namespace }} | ||
register: operatorgroup_output | ||
|
||
- name: Delete operator Subscription | ||
kubernetes.core.k8s: | ||
api_version: operators.coreos.com/v1alpha1 | ||
kind: Subscription | ||
name: "{{ operator_subscription }}" | ||
namespace: "{{ operator_namespace }}" | ||
state: absent | ||
when: subscription_output.stdout != "" | ||
|
||
- name: Delete Cluster Service Version | ||
shell: oc delete csv {{ operator_csv.stdout }} -n {{ operator_namespace }} | ||
when: operator_csv.stdout != "" or operator_csv.stdout != None | ||
|
||
- name: Delete OperatorGroup | ||
kubernetes.core.k8s: | ||
api_version: operators.coreos.com/v1 | ||
kind: OperatorGroup | ||
name: "{{ operator_group }}" | ||
namespace: "{{ operator_namespace }}" | ||
state: absent | ||
when: operatorgroup_output.stdout != "" | ||
|
||
- name: Verify the operator cleanup | ||
shell: oc get csv -n {{ operator_namespace }} | ||
register: cleanup_verification_output | ||
|
||
- debug: | ||
msg: "Resources cleaned up suceessfully !" | ||
when: cleanup_verification_output.stdout == "" | ||
when: | ||
- operator_namespace != "" | ||
- operator_subscription != "" | ||
- operator_group != "" | ||
- namespace_output.stdout != "" | ||
ignore_errors: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters