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

[ci_lvmns_storage] Wait for all LVMS nodes to be ready #2192

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 roles/ci_lvms_storage/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ be controlled with the following parameters.

* `cifmw_lvms_delay`: (Int) Ansible `delay` passed to tasks which wait for `kubernetes.core.k8s_info` (default `10`)
* `cifmw_lvms_retries`: (Int) Ansible `retries` passed to tasks which wait for `kubernetes.core.k8s_info` (default `60`)

* `cifmw_lvms_wait_nodes_lvs_retries`: (Int) Number of retries to wait for the logical volumes to show up in each OCP node (default `120`)

### Optional parameters

Expand Down
1 change: 1 addition & 0 deletions roles/ci_lvms_storage/defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,5 @@ cifmw_lvms_thin_pool_size_percent: 90
cifmw_lvms_thin_pool_overprovision_ratio: 10
cifmw_lvms_retries: 60
cifmw_lvms_delay: 10
cifmw_lvms_wait_nodes_lvs_retries: 120
cifmw_lvms_storage_tolerations: {}
60 changes: 60 additions & 0 deletions roles/ci_lvms_storage/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -154,3 +154,63 @@
- _cifmw_lvms_storage_cluster_lvmscluster_out.resources[0].status is defined
- _cifmw_lvms_storage_cluster_lvmscluster_out.resources[0].status.ready is defined
- _cifmw_lvms_storage_cluster_lvmscluster_out.resources[0].status.ready | bool
- _cifmw_lvms_storage_cluster_lvmscluster_out.resources[0].status.deviceClassStatuses is defined
- >-
_cifmw_lvms_storage_cluster_lvmscluster_out.resources[0].status.deviceClassStatuses |
selectattr("name", "defined") |
selectattr("nodeStatus", "defined") |
selectattr("name", "equalto", cifmw_lvms_storage_class) |
map(attribute="nodeStatus") | flatten |
selectattr("status", "defined") |
map(attribute="status") | unique == ["Ready"]

- name: Wait for all the LVMVolumeGroupNodeStatus to be ready
kubernetes.core.k8s_info:
kubeconfig: "{{ cifmw_openshift_kubeconfig }}"
api_key: "{{ cifmw_openshift_token | default(omit) }}"
context: "{{ cifmw_openshift_context | default(omit) }}"
api_version: lvm.topolvm.io/v1alpha1
kind: LVMVolumeGroupNodeStatus
namespace: "{{ cifmw_lvms_namespace }}"
register: _cifmw_lvms_storage_cluster_lvmvolumegroupnodestatus_out
retries: "{{ cifmw_lvms_retries }}"
delay: "{{ cifmw_lvms_delay }}"
until:
- _cifmw_lvms_storage_cluster_lvmvolumegroupnodestatus_out.failed is false
- _cifmw_lvms_storage_cluster_lvmvolumegroupnodestatus_out.resources is defined
- >-
_cifmw_lvms_storage_cluster_lvmvolumegroupnodestatus_out.resources |
selectattr("spec.nodeStatus", "defined") |
map(attribute="spec.nodeStatus") | flatten |
selectattr("status", "defined") |
map(attribute="status") | unique == ["Ready"]

- name: Wait for all nodes to have the LVM annotation
vars:
_cifmw_lvms_storage_nodes: >-
{{
_cifmw_lvms_storage_cluster_lvmvolumegroupnodestatus_out.resources |
selectattr("metadata.name", "defined") |
map(attribute="metadata.name")
}}
environment:
KUBECONFIG: "{{ cifmw_openshift_kubeconfig }}"
PATH: "{{ cifmw_path }}"
when: _cifmw_lvms_storage_nodes | length > 0
ansible.builtin.command:
cmd: >-
oc get node
-l 'topology.topolvm.io/node in ({{ _cifmw_lvms_storage_nodes | join(", ") }})'
-o=jsonpath='{.items[*].metadata.annotations.capacity\.topolvm\.io/{{ cifmw_lvms_storage_class }}}'
changed_when: false
register: _cifmw_lvms_storage_nodes_annotations_out
retries: "{{ cifmw_lvms_wait_nodes_lvs_retries }}"
delay: "{{ cifmw_lvms_delay }}"
until:
- _cifmw_lvms_storage_nodes_annotations_out is defined
- _cifmw_lvms_storage_nodes_annotations_out.failed is false
- _cifmw_lvms_storage_nodes_annotations_out.stdout | trim | length != 0
- >-
_cifmw_lvms_storage_nodes_annotations_out.stdout | split(" ") |
map("int") | select("gt", 0) |
length == _cifmw_lvms_storage_nodes | length