Skip to content
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion .github/workflows/ansible-lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:

steps:
- name: Checkout Code
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
with:
persist-credentials: false

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ansible-sanitytest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:

steps:
- name: Checkout Code
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
with:
path: ansible_collections/rhvp/cluster_utils
persist-credentials: false
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ansible-unittest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:

steps:
- name: Checkout Code
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
with:
path: ansible_collections/rhvp/cluster_utils
persist-credentials: false
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/jsonschema.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:

steps:
- name: Checkout Code
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
with:
persist-credentials: false

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/superlinter.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:

steps:
- name: Checkout Code
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
with:
# Full git history is needed to get a proper list of changed files within `super-linter`
fetch-depth: 0
Expand Down
6 changes: 6 additions & 0 deletions roles/uninstall_pattern/defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,9 @@ uninstall_wait_timeout: |
| default("3600", true)
| int
}}

patterns_operator_namespace: >-
{{
lookup("env", "PATTERNS_OPERATOR_NAMESPACE")
| default("patterns-operator", true)
}}
29 changes: 22 additions & 7 deletions roles/uninstall_pattern/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
api_version: gitops.hybrid-cloud-patterns.io/v1alpha1
kind: Pattern
name: "{{ pattern_name }}"
namespace: openshift-operators
namespace: "{{ patterns_operator_namespace }}"
register: pattern_info

- name: Check that the pattern '{{ pattern_name }}' is present on the cluster
Expand All @@ -15,10 +15,25 @@
can only be run on hub clusters, where the pattern CR and patterns operator are present,
in patterns with both hub and spoke components.

- name: Fetch the pods in the openshift-operators namespace
- name: Ensure prune annotation is set on pattern CR
kubernetes.core.k8s:
state: present
api_version: gitops.hybrid-cloud-patterns.io/v1alpha1
kind: Pattern
name: "{{ pattern_name }}"
namespace: "{{ patterns_operator_namespace }}"
definition:
metadata:
annotations:
patterns.gitops.hybrid-cloud-patterns.io/prune: "true"
when: >-
(pattern_info.resources[0].metadata.annotations | default({}))
.get('patterns.gitops.hybrid-cloud-patterns.io/prune', '') != 'true'

- name: Fetch the pods in the {{ patterns_operator_namespace }} namespace
kubernetes.core.k8s_info:
kind: Pod
namespace: openshift-operators
namespace: "{{ patterns_operator_namespace }}"
register: pod_list

- name: Find the patterns operator controller pod
Expand All @@ -29,7 +44,7 @@
ansible.builtin.assert:
that: patterns_operator_pod_name != ''
fail_msg: |
Could not find the patterns operator controller manager pod in the 'openshift-operators' namespace. Please ensure that the patterns
Could not find the patterns operator controller manager pod in the '{{ patterns_operator_namespace }}' namespace. Please ensure that the patterns
operator is currently running in your cluster.

- name: Print user-friendly uninstall message
Expand All @@ -40,16 +55,16 @@
only the pattern will be removed, to facilitate easy reinstall of this pattern or other patterns.
This command will wait for up to {{ uninstall_wait_timeout }} seconds while the pattern is uninstalled.
To view deletion progress, you can check the logs of the '{{ patterns_operator_pod_name }}' pod
pod in the 'openshift-operators' namespace with the command:
pod in the '{{ patterns_operator_namespace }}' namespace with the command:

oc logs -f --tail=50 -n openshift-operators {{ patterns_operator_pod_name }}
oc logs -f --tail=50 -n {{ patterns_operator_namespace }} {{ patterns_operator_pod_name }}

- name: Delete pattern from cluster
kubernetes.core.k8s:
state: absent
api_version: gitops.hybrid-cloud-patterns.io/v1alpha1
kind: Pattern
name: "{{ pattern_name }}"
namespace: openshift-operators
namespace: "{{ patterns_operator_namespace }}"
wait: true
wait_timeout: "{{ uninstall_wait_timeout }}"