From: Filip Pytloun Date: Mon, 15 Jan 2018 12:14:16 +0000 (+0000) Subject: Merge "Remove salt-master, reclass from pkg dependencis" X-Git-Url: https://gerrit.mcp.mirantis.com/gitweb?p=salt-formulas%2Finfluxdb.git;a=commitdiff_plain;h=35a3c92b8ae82cd4e515f79deef9453c6116c3cd;hp=94c0072f59a44f13f9ac07f95b922e7be3b0225c Merge "Remove salt-master, reclass from pkg dependencis" --- diff --git a/README.rst b/README.rst index 854da83..027b030 100644 --- a/README.rst +++ b/README.rst @@ -264,6 +264,16 @@ InfluxDB client for configuring databases, users and retention policies: database: mydb1 privilege: all +InfluxDB client state's that uses curl can be forced to retry query if curl call fails: + +.. code-block:: yaml + + influxdb: + client: + enabled: true + retry: + count: 3 + delay: 3 Create an continuous queries: diff --git a/influxdb/client.sls b/influxdb/client.sls index 5ef378e..566c516 100644 --- a/influxdb/client.sls +++ b/influxdb/client.sls @@ -2,7 +2,7 @@ {%- if client.get('enabled') %} -{%- set curl_command = 'curl' %} +{%- set curl_command = 'curl --retry {} --retry-delay {}'.format(client.retry.count, client.retry.delay) %} {%- if grains.get('noservices') %} {%- set curl_command = 'true ' + curl_command %} {%- endif %} @@ -91,7 +91,7 @@ influxdb_grant_{{ grant_name }}: influxdb_continuous_query_{{db_name}}_{{ cq_name }}: cmd.run: - shell: /bin/bash - - name: fail_on() { echo $2; if [[ "$2" == *"$1"* ]]; then return 1; return 0; fi; }; fail_on "already exist" $({{ curl_command }} -s -S -POST "{{ auth_url }}" --data-urlencode "q=CREATE {{ query_continuous_query }}") || fail_on error $({{ curl_command }} -s -S -POST "{{ auth_url }}" --data-urlencode $'q=DROP {{ cq_name_on }};\nCREATE {{ query_continuous_query }}') + - name: fail_on() { echo "${@:2}"; if [[ "${@:2}" == *"$1"* ]]; then return 1; return 0; fi; }; fail_on "already exist" $({{ curl_command }} -s -S -POST "{{ auth_url }}" --data-urlencode "q=CREATE {{ query_continuous_query }}") || fail_on error $({{ curl_command }} -s -S -POST "{{ auth_url }}" --data-urlencode $'q=DROP {{ cq_name_on }};\nCREATE {{ query_continuous_query }}') - onlyif: {{ curl_command }} -s -S -POST "{{ auth_url }}" --data-urlencode "q=SHOW DATABASES" | grep {{ db_name }} {%- endfor %} diff --git a/influxdb/map.jinja b/influxdb/map.jinja index 83047b6..80c64a9 100644 --- a/influxdb/map.jinja +++ b/influxdb/map.jinja @@ -52,6 +52,10 @@ default: {%- set client = salt['grains.filter_by']({ 'default': { + 'retry': { + 'count': 0, + 'delay': 0 + } }, }, merge=salt['pillar.get']('influxdb:client')) %} diff --git a/tests/pillar/client.sls b/tests/pillar/client.sls index d352076..ca190c0 100644 --- a/tests/pillar/client.sls +++ b/tests/pillar/client.sls @@ -1,6 +1,9 @@ influxdb: client: enabled: true + retry: + count: 3 + delay: 3 server: protocol: http host: 127.0.0.1