Skip to content

Commit

Permalink
sap_hypervisor_node_preconfigure: Checks to wait for right conditions…
Browse files Browse the repository at this point in the history
… for CNV and Nmstate installations

Signed-off-by: Geetika Kapoor <[email protected]>
  • Loading branch information
geetikakay committed Sep 24, 2024
1 parent 3ba7939 commit be49fdd
Show file tree
Hide file tree
Showing 2 changed files with 71 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,6 @@
sourceNamespace: openshift-marketplace
name: kubevirt-hyperconverged

- name: Wait
ansible.builtin.pause:
seconds: 300

- name: Get Install Plan Name from Subscription
retries: 10
delay: 10
Expand Down Expand Up @@ -76,10 +72,6 @@
msg: "Install Plan is not Complete after the specified wait period."
when: __sap_hypervisor_node_preconfigure_register_wait_for_installplan.resources[0].status.phase != "Complete"

- name: Wait
ansible.builtin.pause:
seconds: 300

- name: Create CNV HyperConverged
kubernetes.core.k8s:
state: present
Expand All @@ -89,8 +81,35 @@
metadata:
name: kubevirt-hyperconverged
namespace: "{{ sap_hypervisor_node_preconfigure_ocpv_namespace }}"
spec:

- name: Wait
ansible.builtin.pause:
seconds: 300
- name: Retrieve HyperConverged Status
kubernetes.core.k8s_info:
api_version: hco.kubevirt.io/v1beta1
kind: HyperConverged
name: kubevirt-hyperconverged
namespace: "{{ sap_hypervisor_node_preconfigure_ocpv_namespace }}"
register: hyperconverged_status
until: >
{{
(hyperconverged_status.resources[0].status.conditions |
selectattr('type', 'equalto', 'Available') |
selectattr('status', 'equalto', 'True') |
list | length > 0) | bool
}}
retries: 60
delay: 10

- name: Set HyperConverged Available Fact
ansible.builtin.set_fact:
hyperconverged_available: >-
{{
(hyperconverged_status.resources[0].status.conditions |
selectattr('type', 'equalto', 'Available') |
selectattr('status', 'equalto', 'True') |
list | length > 0) | bool
}}
- name: Fail if HyperConverged is not Available after waiting
ansible.builtin.fail:
msg: "HyperConverged is not Available after the specified wait period."
when: not hyperconverged_available
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,16 @@
targetNamespaces:
- openshift-nmstate

- name: Pause to give operator a chance to install
ansible.builtin.pause:
minutes: 2
- name: Wait for nmstate OperatorGroup to be created
kubernetes.core.k8s_info:
api_version: operators.coreos.com/v1
kind: OperatorGroup
name: openshift-nmstate-tn6k8
namespace: openshift-nmstate
register: operatorgroup_status
retries: 30
delay: 10
until: operatorgroup_status.resources | length > 0

- name: Subscribe to the nmstate Operator
kubernetes.core.k8s:
Expand All @@ -52,9 +59,27 @@
source: redhat-operators
sourceNamespace: openshift-marketplace

- name: Pause to give operator a chance to install
ansible.builtin.pause:
minutes: 5
- name: Wait for Subscription to have an InstallPlan
kubernetes.core.k8s_info:
api_version: operators.coreos.com/v1alpha1
kind: Subscription
name: kubernetes-nmstate-operator
namespace: openshift-nmstate
register: subscription_status
retries: 30
delay: 10
until: subscription_status.resources[0].status.installplan.name is defined

- name: Wait for InstallPlan to complete
kubernetes.core.k8s_info:
api_version: operators.coreos.com/v1alpha1
kind: InstallPlan
name: "{{ subscription_status.resources[0].status.installplan.name }}"
namespace: openshift-nmstate
register: installplan_status
retries: 30
delay: 10
until: installplan_status.resources[0].status.phase == "Complete"

- name: Create instance of the nmstate operator
kubernetes.core.k8s:
Expand All @@ -65,6 +90,12 @@
metadata:
name: nmstate

- name: Pause to give instance a chance to come up
ansible.builtin.pause:
minutes: 5
- name: Wait for NMState instance to be created
kubernetes.core.k8s_info:
api_version: nmstate.io/v1
kind: NMState
name: nmstate
register: nmstate_status
retries: 30
delay: 10
until: nmstate_status.resources | length > 0

0 comments on commit be49fdd

Please sign in to comment.