Skip to content

Commit

Permalink
Merge pull request #495 from redhatci/starting_csv_case
Browse files Browse the repository at this point in the history
Remove special case for starting_csv
  • Loading branch information
betoredhat authored Nov 27, 2024
2 parents dcf7cab + 5a78d8d commit 576981d
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 48 deletions.
2 changes: 1 addition & 1 deletion roles/olm_operator/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Role to deploy an OLM-based operator.
Name | Required | Default | Description
--------------------------- |-----------|------------------------|--------------------------------------
channel | No | \<defaultChannel\> | The default channel of the operator is calculated and used when undefined
install_approval | No | Manual | Operator install plan approval mode, either Automatic or Manual (default)
install_approval | No | Manual | Operator install plan approval mode after initial installation, either Automatic or Manual
namespace | Yes | undefined | Namespace where the operator will be installed
ns_labels | No | {} | Dictionary of labels (name: value) to be assigned to the operator namespace
operator | Yes | undefined | Name of the operator to install
Expand Down
48 changes: 1 addition & 47 deletions roles/olm_operator/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -130,60 +130,14 @@
namespace: "{{ namespace }}"
spec:
channel: "{{ desired_channel }}"
installPlanApproval: "{{ starting_csv | default('') | length | ternary('Manual', 'Automatic') }}"
installPlanApproval: "Automatic"
config:
resources: {}
name: "{{ operator }}"
source: "{{ source }}"
sourceNamespace: "{{ source_ns }}"
startingCSV: "{{ operator_csv }}"

- name: Wait for subscription to be ready
community.kubernetes.k8s_info:
api: operators.coreos.com/v1alpha1
kind: Subscription
namespace: "{{ namespace }}"
name: "{{ operator }}"
register: sub
retries: 20
delay: 30
until:
- sub.resources is defined
- sub.resources | length == 1
- "'status' in sub.resources[0]"
- sub.resources[0].status.installedCSV is defined
- sub.resources[0].status.installedCSV == operator_csv

- 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:
api: operators.coreos.com/v1alpha1
Expand Down

0 comments on commit 576981d

Please sign in to comment.