Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Checks to wait for right conditions for CNV and Nmstate installations #63

Merged
merged 1 commit into from
Oct 7, 2024
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
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