puppet-prometheus icon indicating copy to clipboard operation
puppet-prometheus copied to clipboard

Systemd dependencies cycle with rabbitmq and rabbitmq-exporter

Open gokuatkai opened this issue 5 years ago • 4 comments

Hello, I am not sure if this is a puppet-prometheus or a puppet-rabbitmq issue but I am having a dependency cycle using them both: puppet-server: 2.8.1 puppet: 4.10.12 puppet-rabbitmq: 8.5.0 puppet-prometheus: 6.4.0 system: centos7

My manifest is has followed (The prometheus exporter should be added after Rabbitmq, that is why I have a require in the 'prometheus::rabbitmq_exporter' class)

node /^rabbitmq-node-.*.org$/ {
    class { 'rabbitmq':
        [some_config]
    } ->
    rabbitmq_vhost {
        'some-vhost': [...];
    } ->
    rabbitmq_policy {
        'some-policy': [...];
    } ->
    rabbitmq_user {
        'some_user': [...];
    } ->
    rabbitmq_user_permissions {
        'some_user_perms': [...];
    }
    rabbitmq_plugin {
        some_plugin': [...];
    }

    class { 'prometheus::rabbitmq_exporter':
        [some_config]
        require => Class['rabbitmq']
    }
}

The error that I have is:

Error: Failed to apply catalog: Found 1 dependency cycle:
(Exec[systemctl-daemon-reload] => Class[Systemd::Systemctl::Daemon_reload] => Service[rabbitmq-server] => Class[Rabbitmq::Service] => Class[Rabbitmq] => Class[Prometheus::Rabbitmq_exporter] => Prometheus::Daemon[rabbitmq_exporter] => Systemd::Unit_file[rabbitmq_exporter.service] => File[/etc/systemd/system/rabbitmq_exporter.service] => Class[Systemd::Systemctl::Daemon_reload] => Exec[systemctl-daemon-reload])

Any ideas ?

gokuatkai avatar Feb 28 '20 08:02 gokuatkai

I've noticed the same error with other services that use the class Class[Systemd::Systemctl::Daemon_reload] so this is not limited to rabbitmq

jakubjakubik avatar Sep 10 '20 13:09 jakubjakubik

I did a quick workaround in https://github.com/egnyte/puppet-prometheus/tree/v10.0.0_workaround_434 but I am not sure if it doesn't have side effects yet, so it's definitely not ready to create a PR.

gdubicki avatar Sep 10 '20 14:09 gdubicki

You could be less strict with your relationships. You probably don't actually need every resource declared in the exporter (and specifically the unit_file) to come after every resource in rabbitmq.

Something like

class { 'prometheus::rabbitmq_exporter':
  ...
  require => Class['rabbitmq::service'],
}

will probably break the dependency cycle.

alexjfisher avatar Sep 24 '20 22:09 alexjfisher

I think that less ordering won't help, @alexjfisher .

Because in our code we do not have any ordering between the class that contains prometheus::rabbitmq_exporter and the rabbitmq resources and we still had this dependency cycle.

gdubicki avatar Feb 28 '21 08:02 gdubicki

I think this is obsolete and only affects outdated puppet versions. Pleas re-open the issue if I am wrong.

TheMeier avatar Jun 03 '24 11:06 TheMeier