summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorewolinetz <ewolinet@redhat.com>2017-04-24 11:02:38 -0500
committerewolinetz <ewolinet@redhat.com>2017-04-27 10:35:54 -0500
commit58db866c0ccfa72a1a20381b3abcae1286d68c9f (patch)
tree6c141fc17cf15e34adf8ad3a00ab31ce90677509
parent38e832422a92124bd17a97f4cf65f4bec55cb516 (diff)
downloadopenshift-58db866c0ccfa72a1a20381b3abcae1286d68c9f.tar.gz
openshift-58db866c0ccfa72a1a20381b3abcae1286d68c9f.tar.bz2
openshift-58db866c0ccfa72a1a20381b3abcae1286d68c9f.tar.xz
openshift-58db866c0ccfa72a1a20381b3abcae1286d68c9f.zip
Updating logic for generating pvcs and their counts to prevent reuse when looping
-rw-r--r--roles/openshift_logging/tasks/install_elasticsearch.yaml22
-rw-r--r--roles/openshift_logging/tasks/set_es_storage.yaml6
2 files changed, 21 insertions, 7 deletions
diff --git a/roles/openshift_logging/tasks/install_elasticsearch.yaml b/roles/openshift_logging/tasks/install_elasticsearch.yaml
index b80f37892..667d7d9c4 100644
--- a/roles/openshift_logging/tasks/install_elasticsearch.yaml
+++ b/roles/openshift_logging/tasks/install_elasticsearch.yaml
@@ -5,6 +5,9 @@
- set_fact: openshift_logging_es_pvc_prefix="logging-es"
when: "not openshift_logging_es_pvc_prefix or openshift_logging_es_pvc_prefix == ''"
+- set_fact: es_indices={{ es_indices | default([]) + [item | int - 1] }}
+ with_sequence: count={{ openshift_logging_facts.elasticsearch.deploymentconfigs.keys() | count }}
+
### evaluate if the PVC attached to the dc currently matches the provided vars
## if it does then we reuse that pvc in the DC
- include: set_es_storage.yaml
@@ -12,8 +15,9 @@
es_component: es
es_name: "{{ deployment.0 }}"
es_spec: "{{ deployment.1 }}"
+ es_pvc_count: "{{ deployment.2 | int }}"
es_node_selector: "{{ openshift_logging_es_nodeselector | default({}) }}"
- es_pvc_names: "{{ openshift_logging_facts.elasticsearch.pvcs.keys() }}"
+ es_pvc_names_count: "{{ openshift_logging_facts.elasticsearch.pvcs.keys() | count }}"
es_pvc_size: "{{ openshift_logging_es_pvc_size }}"
es_pvc_prefix: "{{ openshift_logging_es_pvc_prefix }}"
es_pvc_dynamic: "{{ openshift_logging_es_pvc_dynamic | bool }}"
@@ -25,6 +29,7 @@
with_together:
- "{{ openshift_logging_facts.elasticsearch.deploymentconfigs.keys() }}"
- "{{ openshift_logging_facts.elasticsearch.deploymentconfigs.values() }}"
+ - "{{ es_indices }}"
loop_control:
loop_var: deployment
## if it does not then we should create one that does and attach it
@@ -35,8 +40,9 @@
es_component: es
es_name: "logging-es-{{'abcdefghijklmnopqrstuvwxyz0123456789'|random_word(8)}}"
es_spec: "{}"
+ es_pvc_count: "{{ item | int - 1 }}"
es_node_selector: "{{ openshift_logging_es_nodeselector | default({}) }}"
- es_pvc_names: "{{ openshift_logging_facts.elasticsearch.pvcs.keys() }}"
+ es_pvc_names_count: "{{ [openshift_logging_facts.elasticsearch.pvcs.keys() | count, openshift_logging_facts.elasticsearch.deploymentconfigs.keys() | count] | max }}"
es_pvc_size: "{{ openshift_logging_es_pvc_size }}"
es_pvc_prefix: "{{ openshift_logging_es_pvc_prefix }}"
es_pvc_dynamic: "{{ openshift_logging_es_pvc_dynamic | bool }}"
@@ -67,13 +73,19 @@
- set_fact: openshift_logging_es_ops_pvc_prefix="logging-es-ops"
when: "not openshift_logging_es_ops_pvc_prefix or openshift_logging_es_ops_pvc_prefix == ''"
+- set_fact: es_ops_indices={{ es_ops_indices | default([]) + [item | int - 1] }}
+ with_sequence: count={{ openshift_logging_facts.elasticsearch_ops.deploymentconfigs.keys() | count }}
+ when:
+ - openshift_logging_use_ops | bool
+
- include: set_es_storage.yaml
vars:
es_component: es-ops
es_name: "{{ deployment.0 }}"
es_spec: "{{ deployment.1 }}"
+ es_pvc_count: "{{ deployment.2 | int }}"
es_node_selector: "{{ openshift_logging_es_ops_nodeselector | default({}) }}"
- es_pvc_names: "{{ openshift_logging_facts.elasticsearch_ops.pvcs.keys() }}"
+ es_pvc_names_count: "{{ openshift_logging_facts.elasticsearch_ops.pvcs.keys() | count }}"
es_pvc_size: "{{ openshift_logging_es_ops_pvc_size }}"
es_pvc_prefix: "{{ openshift_logging_es_ops_pvc_prefix }}"
es_pvc_dynamic: "{{ openshift_logging_es_ops_pvc_dynamic | bool }}"
@@ -85,6 +97,7 @@
with_together:
- "{{ openshift_logging_facts.elasticsearch_ops.deploymentconfigs.keys() }}"
- "{{ openshift_logging_facts.elasticsearch_ops.deploymentconfigs.values() }}"
+ - "{{ es_ops_indices }}"
loop_control:
loop_var: deployment
when:
@@ -97,8 +110,9 @@
es_component: es-ops
es_name: "logging-es-ops-{{'abcdefghijklmnopqrstuvwxyz0123456789'|random_word(8)}}"
es_spec: "{}"
+ es_pvc_count: "{{ item | int - 1 }}"
es_node_selector: "{{ openshift_logging_es_ops_nodeselector | default({}) }}"
- es_pvc_names: "{{ openshift_logging_facts.elasticsearch_ops.pvcs.keys() }}"
+ es_pvc_names_count: "{{ [openshift_logging_facts.elasticsearch_ops.pvcs.keys() | count, openshift_logging_facts.elasticsearch_ops.deploymentconfigs.keys() | count] | max }}"
es_pvc_size: "{{ openshift_logging_es_ops_pvc_size }}"
es_pvc_prefix: "{{ openshift_logging_es_ops_pvc_prefix }}"
es_pvc_dynamic: "{{ openshift_logging_es_ops_pvc_dynamic | bool }}"
diff --git a/roles/openshift_logging/tasks/set_es_storage.yaml b/roles/openshift_logging/tasks/set_es_storage.yaml
index 198b1d04d..b2961aed4 100644
--- a/roles/openshift_logging/tasks/set_es_storage.yaml
+++ b/roles/openshift_logging/tasks/set_es_storage.yaml
@@ -36,7 +36,7 @@
- name: Generating PersistentVolumeClaims
template: src=pvc.j2 dest={{mktemp.stdout}}/templates/logging-{{obj_name}}-pvc.yaml
vars:
- obj_name: "{{ es_pvc_prefix }}-{{ es_pvc_names | count }}"
+ obj_name: "{{ es_pvc_prefix }}-{{ es_pvc_names_count | int + es_pvc_count | int }}"
size: "{{ es_pvc_size }}"
access_modes: "{{ openshift_logging_storage_access_modes }}"
pv_selector: "{{ es_pv_selector }}"
@@ -47,7 +47,7 @@
- name: Generating PersistentVolumeClaims - Dynamic
template: src=pvc.j2 dest={{mktemp.stdout}}/templates/logging-{{obj_name}}-pvc.yaml
vars:
- obj_name: "{{ es_pvc_prefix }}-{{ es_pvc_names | count }}"
+ obj_name: "{{ es_pvc_prefix }}-{{ es_pvc_names_count | int + es_pvc_count | int }}"
annotations:
volume.alpha.kubernetes.io/storage-class: "dynamic"
size: "{{ es_pvc_size }}"
@@ -57,7 +57,7 @@
check_mode: no
changed_when: no
- - set_fact: es_storage_claim="{{ es_pvc_prefix }}-{{ es_pvc_names | count }}"
+ - set_fact: es_storage_claim="{{ es_pvc_prefix }}-{{ es_pvc_names_count | int + es_pvc_count | int }}"
when:
- es_pvc_size | search('^\d.*')