From 81e6bc54b0838b8c0341acc15e936cc8ed3f7f5a Mon Sep 17 00:00:00 2001 From: Petr Michalec Date: Tue, 9 Jan 2018 16:48:03 +0100 Subject: [PATCH] Allow states using curl to retry if transient problem. Change-Id: Ibd9016530083127fc2b6274897a51dfca5d01f7b --- README.rst | 10 ++++++++++ influxdb/client.sls | 2 +- influxdb/map.jinja | 4 ++++ tests/pillar/client.sls | 3 +++ 4 files changed, 18 insertions(+), 1 deletion(-) 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 3015a53..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 %} 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 -- 2.32.7