From 9529d5fcfe3bea44aa683bb3312fcb0eff41e192 Mon Sep 17 00:00:00 2001 From: Arend Hummeling Date: Wed, 2 Feb 2022 16:05:28 +0100 Subject: [PATCH] fix(archive): make sure special commandline flags are accepted Attempt to resolve the issue of being unable to pass the `--storage.tsdb.retention.time` flag. Signed-off-by: Arend Hummeling --- prometheus/archive/install.sls | 33 +++++++++++++++++++++------------ test/salt/pillar/default.sls | 1 + 2 files changed, 22 insertions(+), 12 deletions(-) diff --git a/prometheus/archive/install.sls b/prometheus/archive/install.sls index 47ad4f0..439b9a3 100644 --- a/prometheus/archive/install.sls +++ b/prometheus/archive/install.sls @@ -129,19 +129,28 @@ prometheus-archive-install-{{ name }}-managed-service: env: {{ p.pkg.component[name]['service'].get('env', [])|tojson }} workdir: {{ p.dir.var }}/{{ name }} stop: '' - {%- if name in ('node_exporter', 'consul_exporter') or 'config_file' not in p.pkg.component[name] %} - {%- set args = [] %} - {%- for param, value in p.pkg.component.get(name).get('service').get('args', {}).items() %} - {%- if value is not none %} - {% do args.append("--" ~ param ~ "=" ~ value ) %} - {%- else %} - {% do args.append("--" ~ param ) %} - {%- endif %} - {%- endfor %} - start: {{ p.pkg.component[name]['path'] }}/{{ name }} {{ args|join(' ') }} - {%- else %} - start: {{ p.pkg.component[name]['path'] }}/{{ name }} --config.file {{ p.pkg.component[name]['config_file'] }} # noqa 204 + {%- set all_args = p.pkg.component.get(name).get('service').get('args', {}) %} + {%- set commandline_only_args = ["storage.tsdb.retention.time"] %} + {%- if name in ('node_exporter', 'consul_exporter') or 'config_file' not in p.pkg.component[name] %} + {%- set args = all_args %} + {%- else %} + {%- set args = {'config.file': p.pkg.component[name]['config_file']} %} + {%- endif %} + {%- for arg in commandline_only_args %} + {%- set value = all_args.get(arg) %} + {%- if value is not none %} + {%- do args.update({arg: value}) %} {%- endif %} + {%- endfor %} + {%- set flags = [] %} + {%- for param, value in args.items() %} + {%- if value is not none %} + {% do flags.append("--" ~ param ~ "=" ~ value ) %} + {%- else %} + {% do flags.append("--" ~ param ) %} + {%- endif %} + {%- endfor %} + start: {{ p.pkg.component[name]['path'] }}/{{ name }} {{ flags|join(' ') }} - require: - file: prometheus-archive-install-{{ name }}-file-directory {%- if p.pkg.component.get(name).get('archive').get('tar', true) %} diff --git a/test/salt/pillar/default.sls b/test/salt/pillar/default.sls index 486b2d8..b8799e6 100644 --- a/test/salt/pillar/default.sls +++ b/test/salt/pillar/default.sls @@ -118,6 +118,7 @@ prometheus: service: args: web.listen-address: 0.0.0.0:9090 + storage.tsdb.retention.time: 150d environ: args: web.listen-address: 0.0.0.0:9090