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 <arend@adivare.nl>
This commit is contained in:
Arend Hummeling 2022-02-02 16:05:28 +01:00
parent 5d39408744
commit 9529d5fcfe
No known key found for this signature in database
GPG Key ID: B1C112C1A32E706A
2 changed files with 22 additions and 12 deletions

View File

@ -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: ''
{%- 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 = [] %}
{%- for param, value in p.pkg.component.get(name).get('service').get('args', {}).items() %}
{%- if value is not none %}
{% do args.append("--" ~ param ~ "=" ~ value ) %}
{%- set args = all_args %}
{%- else %}
{% do args.append("--" ~ param ) %}
{%- 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 %}
start: {{ p.pkg.component[name]['path'] }}/{{ name }} {{ args|join(' ') }}
{%- set flags = [] %}
{%- for param, value in args.items() %}
{%- if value is not none %}
{% do flags.append("--" ~ param ~ "=" ~ value ) %}
{%- else %}
start: {{ p.pkg.component[name]['path'] }}/{{ name }} --config.file {{ p.pkg.component[name]['config_file'] }} # noqa 204
{% 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) %}

View File

@ -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