From: mcp-jenkins Date: Tue, 16 Jan 2018 08:53:54 +0000 (+0000) Subject: Merge "Optimize kitchen tests for Travis CI and fix test repo" X-Git-Url: https://gerrit.mcp.mirantis.com/gitweb?p=salt-formulas%2Finfluxdb.git;a=commitdiff_plain;h=63a7863f5b37773ed15bc2a4fe46abab3b613b91;hp=5dc4197223fd976dad72fe485a84ee4fcc55a2ec Merge "Optimize kitchen tests for Travis CI and fix test repo" --- 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/debian/control b/debian/control index e12718a..92fbf8e 100644 --- a/debian/control +++ b/debian/control @@ -10,6 +10,6 @@ Vcs-Git: https://github.com/tcpcloud/salt-formula-influxdb.git Package: salt-formula-influxdb Architecture: all -Depends: ${misc:Depends}, salt-master, reclass +Depends: ${misc:Depends} Description: InfluxDB Salt formula Install and configure InfluxDB server. diff --git a/influxdb/client.sls b/influxdb/client.sls index 31d91dc..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 %} @@ -90,7 +90,8 @@ influxdb_grant_{{ grant_name }}: {%- set query_continuous_query = '{} BEGIN {} END'.format(cq_name_on, cq) %} influxdb_continuous_query_{{db_name}}_{{ cq_name }}: cmd.run: - - name: {{ curl_command }} -s -S -POST "{{ auth_url }}" --data-urlencode "q=CREATE {{ query_continuous_query }}"|grep -v "already exists" || {{ curl_command }} -s -S -POST "{{ auth_url }}" --data-urlencode $'q=DROP {{ cq_name_on }};\nCREATE {{ query_continuous_query }}'| egrep -v error + - 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 }}') - 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