Skip to content

Commit

Permalink
Merge pull request #454 from redhatci/revert-452-fix_csv
Browse files Browse the repository at this point in the history
Revert "Improve Subs/CSV validation"
  • Loading branch information
betoredhat authored Oct 3, 2024
2 parents 578353e + b505968 commit 4df2721
Showing 1 changed file with 33 additions and 3 deletions.
36 changes: 33 additions & 3 deletions roles/olm_operator/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@
namespace: "{{ namespace }}"
spec:
channel: "{{ desired_channel }}"
installPlanApproval: "Automatic"
installPlanApproval: "{{ starting_csv | default('') | length | ternary('Manual', 'Automatic') }}"
config:
resources: {}
name: "{{ operator }}"
Expand All @@ -151,8 +151,38 @@
- sub.resources is defined
- sub.resources | length == 1
- "'status' in sub.resources[0]"
- "'installedCSV' in sub.resources[0].status"
- sub.resources[0].status.installedCSV == operator_csv
- "'currentCSV' in sub.resources[0].status"
- sub.resources[0].status.currentCSV | length > 0

- name: Handle with a starting CSV
when:
- starting_csv | default('') | length
block:
- name: Get Install plans for {{ operator }}
community.kubernetes.k8s_info:
api: operators.coreos.com/v1alpha1
kind: InstallPlan
namespace: "{{ namespace }}"
register: _oo_install_plans
retries: 5
delay: 5
until:
- _oo_install_plans.resources is defined
- _oo_install_plans.resources | length

- name: Approve install plan for specific CSV
community.kubernetes.k8s:
definition:
apiVersion: operators.coreos.com/v1alpha1
kind: InstallPlan
metadata:
name: "{{ install_plan }}"
namespace: "{{ namespace }}"
spec:
approved: true
vars:
query: "resources[? spec.approved == `false` && contains(spec.clusterServiceVersionNames, '{{ operator_csv }}')]"
install_plan: "{{ (_oo_install_plans | json_query(query) | first).metadata.name }}"

- name: Wait for CSV to be ready
community.kubernetes.k8s_info:
Expand Down

0 comments on commit 4df2721

Please sign in to comment.