From b56f4651450829451cf320788248435390eb433c Mon Sep 17 00:00:00 2001 From: Sascha Marcel Schmidt Date: Wed, 27 Jun 2018 10:12:23 +0200 Subject: [PATCH] fix creation of heketi volumes and storage provisioning validation --- .../roles/provision/tasks/setup/storage.yml | 7 ++---- .../roles/provision/tasks/setup/volumes.yml | 22 +++++++++++++++++-- 2 files changed, 22 insertions(+), 7 deletions(-) diff --git a/contrib/network-storage/heketi/roles/provision/tasks/setup/storage.yml b/contrib/network-storage/heketi/roles/provision/tasks/setup/storage.yml index 3a2d0df8a..e0ae12246 100644 --- a/contrib/network-storage/heketi/roles/provision/tasks/setup/storage.yml +++ b/contrib/network-storage/heketi/roles/provision/tasks/setup/storage.yml @@ -1,11 +1,9 @@ --- - name: "Test heketi storage." - tags: ["test"] command: "kubectl get secrets,endpoints,services,jobs --output=json" changed_when: false register: "heketi_storage_state" - name: "Create heketi storage." - tags: ["test"] command: "kubectl create -f {{ artifacts_dir }}/heketi-storage.json" vars: secret_query: "items[?metadata.name=='heketi-storage-secret' && kind=='Secret']" @@ -18,7 +16,6 @@ - "heketi_storage_state.stdout|from_json|json_query(service_query)|length == 0" - "heketi_storage_state.stdout|from_json|json_query(job_query)|length == 0" - name: "Get state of heketi storage service, endpoint, secret and job." - tags: ["test"] command: "kubectl get secrets,endpoints,services,jobs --output=json" changed_when: false register: "heketi_storage_state" @@ -26,11 +23,11 @@ secret_query: "items[?metadata.name=='heketi-storage-secret' && kind=='Secret']" endpoints_query: "items[?metadata.name=='heketi-storage-endpoints' && kind=='Endpoints']" service_query: "items[?metadata.name=='heketi-storage-endpoints' && kind=='Service']" - job_query: "items[?metadata.name=='heketi-storage-copy-job' && kind=='Job' && status.conditions[?type=='Complete']]|[0].status.conditions|[0].status" + job_query: "items[?metadata.name=='heketi-storage-copy-job' && kind=='Job']" until: - "heketi_storage_state.stdout|from_json|json_query(secret_query)|length == 1" - "heketi_storage_state.stdout|from_json|json_query(endpoints_query)|length == 1" - "heketi_storage_state.stdout|from_json|json_query(service_query)|length > 0" - - "heketi_storage_state.stdout|from_json|json_query(job_query) == 'True'" + - "heketi_storage_state.stdout|from_json|json_query(job_query)|length == 1" retries: 10 delay: 10 diff --git a/contrib/network-storage/heketi/roles/provision/tasks/setup/volumes.yml b/contrib/network-storage/heketi/roles/provision/tasks/setup/volumes.yml index d7b710c10..268ca94a2 100644 --- a/contrib/network-storage/heketi/roles/provision/tasks/setup/volumes.yml +++ b/contrib/network-storage/heketi/roles/provision/tasks/setup/volumes.yml @@ -16,5 +16,23 @@ vars: { volume: "{{ volume_information.stdout|from_json }}" } when: "volume.name == 'heketidbstorage'" - name: "Provision database volume." - command: "kubectl create -f {{ artifacts_dir }}/heketi-storage.json" - when: "heketi_database_volume_exists != true" + command: "heketi-cli -s http://localhost:48080 setup-openshift-heketi-storage" + when: "heketi_database_volume_exists is undefined" +- name: "Get heketi volume ids." + command: "heketi-cli -s http://localhost:48080 volume list --json" + changed_when: false + register: "heketi_volumes" +- name: "Get heketi volumes." + changed_when: false + command: "heketi-cli -s http://localhost:48080 volume info {{ volume_id }} --json" + with_items: "{{ heketi_volumes.stdout|from_json|json_query(\"volumes[*]\") }}" + loop_control: { loop_var: "volume_id" } + register: "volumes_information" +- name: "Test heketi database volume." + set_fact: { heketi_database_volume_created: true } + with_items: "{{ volumes_information.results }}" + loop_control: { loop_var: "volume_information" } + vars: { volume: "{{ volume_information.stdout|from_json }}" } + when: "volume.name == 'heketidbstorage'" +- name: "Ensure heketi database volume exists." + assert: { that: "heketi_database_volume_created is defined" , msg: "Heketi database volume does not exist." }