X-Git-Url: https://gerrit.mcp.mirantis.com/gitweb?p=salt-formulas%2Felasticsearch.git;a=blobdiff_plain;f=elasticsearch%2Fclient%2Finit.sls;h=b8ceb57a1c7c58566b15f2c563f577f3abb752d1;hp=cd6f2fa58408281b0e23d3692d2a19b13cb48b33;hb=9a9f382a09402533cf32f3ea90c0f769d885aa62;hpb=8af57d4a767c5e63f255691eda77968a5145536b diff --git a/elasticsearch/client/init.sls b/elasticsearch/client/init.sls index cd6f2fa..b8ceb57 100644 --- a/elasticsearch/client/init.sls +++ b/elasticsearch/client/init.sls @@ -13,10 +13,21 @@ include: {%- endif %} {%- for index_name, index in client.get('index', {}).iteritems() %} +# TODO: "Replace with module.run when bug is fixed". +# Since bug in retry logic in salt (#49895) we need to use a workaround for now. +elasticsearch_check_cluster_status_before_creating_index_{{ index_name }}: + cmd.run: + - name: curl -sfk {{ client.server.get("scheme", "http") }}://{{ client.server.host }}:{{ client.server.port }}/_cat/health | awk '{print $4}' | grep green + - retry: + attempts: 5 + until: True + interval: 10 + splay: 5 + elasticsearch_index_{{ index_name }}: {%- if index.get('enabled', False) %} - {% set operation = 'create' %} + {% set operation = 'present' %} {%- if index.definition is defined %} {% set definition = index.definition %} @@ -56,14 +67,8 @@ elasticsearch_index_{{ index_name }}: {%- if index.get('force_operation', False) %} elasticsearch_index_{{ index_name }}_{{ operation }}: {% set curdate = None | strftime('%Y.%m.%d') %} - module.run: - - name: elasticsearch.index_{{ operation }} - - index: {{ index_name }}-{{ curdate }} -{%- else %} -elasticsearch_index_{{ index_name }}_{{ operation }}: - module.run: - - name: elasticsearch.index_{{ operation }} - - index: {{ index_name }} + elasticsearch.index_{{ operation }}: + - name: {{ index_name }}-{{ curdate }} {%- endif %} {%- endfor %}