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 @@
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_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 @@
{%- 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