Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bad formed prometheus.service #306

Closed
dubcl opened this issue Mar 20, 2019 · 3 comments · Fixed by #318
Closed

Bad formed prometheus.service #306

dubcl opened this issue Mar 20, 2019 · 3 comments · Fixed by #318
Assignees

Comments

@dubcl
Copy link

dubcl commented Mar 20, 2019

Affected Puppet, Ruby, OS and module versions/distributions

  • Puppet: 6.2.1
  • Ruby: 2.5.3
  • Distribution: Debian Stretch
  • Module version: 6.4.0

How to reproduce (e.g Puppet code you use)

class profile::prometheus::server (
  Array $scrape_configs,
  Array $alertmanagers_config,
  Variant[Array,Hash] $alerts,
  Hash $route,
  Array $receivers,
) {

  class { '::prometheus':
    version                   => '2.6.1',
    manage_prometheus_server  => true,
    scrape_configs            => $scrape_configs,
    alertmanagers_config      => $alertmanagers_config,
    alerts                    => $alerts,
  }
  -> class { '::prometheus::node_exporter': version => '0.17.0' }
  class { '::prometheus::alertmanager':
    route                     => $route,
    receivers                 => $receivers,
  }
}

What are you seeing

When you deploy on Debian Stretch with Systemd, Prometheus won't start, because the file generated for systemd on the last row of "ExecStart" option add a backslash (""), this cause "ExecStart" option include the option "ExecReload=/bin/kill -HUP $MAINPID" as parameter of "ExecStart".

What behaviour did you expect instead

Create the correct prometheus.service file like:

[Unit]
Description=Prometheus Monitoring framework
Wants=basic.target
After=basic.target network.target

[Service]
User=prometheus
Group=prometheus
ExecStart=/usr/local/bin/prometheus \
  --config.file=/etc/prometheus/prometheus.yaml \ 
  --storage.tsdb.path=/var/lib/prometheus \ 
  --storage.tsdb.retention=360h \ 
  --web.console.templates=/usr/local/share/prometheus/consoles \ 
  --web.console.libraries=/usr/local/share/prometheus/console_libraries
  
ExecReload=/bin/kill -HUP $MAINPID
KillMode=process
Restart=always

[Install]
WantedBy=multi-user.target

Output log

Mar 20 10:00:07 hostname-foo systemd[1]: Started Prometheus Monitoring framework.
Mar 20 10:00:07 hostname-foo prometheus[2257]: Error parsing commandline arguments: unexpected ExecReload=/bin/kill
Mar 20 10:00:07 hostname-foo prometheus[2257]: prometheus: error: unexpected ExecReload=/bin/kill
Mar 20 10:00:07 hostname-foo systemd[1]: prometheus.service: Main process exited, code=exited, status=1/FAILURE
Mar 20 10:00:07 hostname-foo systemd[1]: prometheus.service: Failed with result 'exit-code'.
Mar 20 10:00:07 hostname-foo systemd[1]: prometheus.service: Service RestartSec=100ms expired, scheduling restart.
Mar 20 10:00:07 hostname-foo systemd[1]: prometheus.service: Scheduled restart job, restart counter is at 5.
Mar 20 10:00:07 hostname-foo systemd[1]: Stopped Prometheus Monitoring framework.
Mar 20 10:00:07 hostname-foo systemd[1]: prometheus.service: Start request repeated too quickly.
Mar 20 10:00:07 hostname-foo systemd[1]: prometheus.service: Failed with result 'exit-code'.
Mar 20 10:00:07 hostname-foo systemd[1]: Failed to start Prometheus Monitoring framework.

Any additional information you'd like to impart

To fix I do this:

.../manifests/config.pp

18d17
<         '-log.format logger:stdout',
29,32c28,31
<         "--config.file=${prometheus::server::config_dir}/${prometheus::server::configname}",
<         "--storage.tsdb.path=${prometheus::server::localstorage}",
<         "--storage.tsdb.retention=${prometheus::server::storage_retention}",
<         "--web.console.templates=${prometheus::server::shared_dir}/consoles",
---
>         "--config.file=${prometheus::server::config_dir}/${prometheus::server::configname} \\",
>         "--storage.tsdb.path=${prometheus::server::localstorage} \\",
>         "--storage.tsdb.retention=${prometheus::server::storage_retention} \\",
>         "--web.console.templates=${prometheus::server::shared_dir}/consoles \\",
75c74
<       'sysv', 'redhat' : {
---
>       'sysv' : {

.../templates/prometheus.systemd.erb

10c10
<   <%= @daemon_flags.join(" \\\n  ") %> \
---
>   <%= @daemon_flags.join("\n  ") %>

I have looked for a similar problem but I did not see any like, Cheers.

@bastelfreak
Copy link
Member

Hi @dubcl, thanks for the PR. Strange that none of our tests catched this. are you able to provide a PR for this?

@dubcl
Copy link
Author

dubcl commented Mar 25, 2019

Hi @bastelfreak , PR done, I hope that help.

@bastelfreak
Copy link
Member

thanks!

@alexjfisher alexjfisher self-assigned this Mar 28, 2019
bastelfreak pushed a commit that referenced this issue May 20, 2019
Our init scripts sometimes contain a trailing `\` after the last
argument. Some might lead to wrong parsing.

Fixes #306
Replaces #307
bastelfreak added a commit that referenced this issue May 20, 2019
issue #306: Fix broken startup scripts
cegeka-jenkins pushed a commit to cegeka/puppet-prometheus that referenced this issue Aug 28, 2019
Our init scripts sometimes contain a trailing `\` after the last
argument. Some might lead to wrong parsing.

Fixes voxpupuli#306
Replaces voxpupuli#307
cegeka-jenkins pushed a commit to cegeka/puppet-prometheus that referenced this issue Aug 28, 2019
Rovanion pushed a commit to Rovanion/puppet-prometheus that referenced this issue May 5, 2021
Our init scripts sometimes contain a trailing `\` after the last
argument. Some might lead to wrong parsing.

Fixes voxpupuli#306
Replaces voxpupuli#307
Rovanion pushed a commit to Rovanion/puppet-prometheus that referenced this issue May 5, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants