Another dependency cycle error after upgrading to 2.14.0

Hi!

This morning I updated our Icinga2 environment and now I’m running into a dependency cycle error. I’ve read the documentation several times, but I can’t seem to figure out how to fix this. Hopefully someone of you can help me out.

This is the error I got:

[2023-07-17 10:33:21 +0200] critical/config: Error: Dependency cycle:
Service 'hostname.example.com!VHOST_extra_uri_to_check.tld'
-> Dependency 'hostname.example.com!VHOST_extra_uri_to_check.tld!HTTPS_CERTIFICATE'
-> Service 'hostname.example.com!HTTPS'
-> Dependency 'hostname.example.com!HTTPS!HTTPS_CERTIFICATE'
-> Service 'hostname.example.com!HTTPS'
[2023-07-17 10:33:21 +0200] critical/cli: Config validation failed. Re-run with 'icinga2 daemon -C' after fixing the config.
 * checking Icinga2 configuration. Check '/var/log/icinga2/startup.log' for details.

Some of our hosts have an extra separate HTTPS service to check an other domain. Only it seems to go wrong here with the dependency that is set for the HTTPS_CERTIFICATE service.

This is the host configuration:

object Host "hostname.example.com" {

    import                                              "generic-host"

    vars.check_address                                  = "xx.xx.xx.xx"
    vars.check_address_type                             = "IPv4"

    vars.check_http_enabled                             = true
    vars.check_http_vhost                               = "uri.example.com"
    vars.check_https_enabled                            = true
    vars.check_https_vhost                              = "uri.example.com"
}

object Service "VHOST_extra_uri_to_check.tld" {
    import                                              "generic-service"

    host_name                                           = "hostname.example.com"

    check_command                                       = "check_http"
    vars.check_http_vhost                               = "extra_hostname_to_check.tld"
}

And these are the services:

apply Service "HTTPS" {
  import                                                      "generic-service"

  check_command                                               = "check_http"

  assign where host.vars.check_https_enabled                  == true
  ignore where host.vars.check_https_enabled                  == false

  vars.check_http_port                                        = "443"
  vars.check_http_ssl_enabled                                 = true
  vars.check_http_ssl_version                                 = "$check_https_version$"
  vars.check_http_string_expected                             = "$check_https_string_expected$"
  vars.check_http_content_expected                            = "$check_https_content_expected$"

  if (host.vars.check_https_vhost) {
    vars.check_http_vhost                                     = "$host.vars.check_https_vhost$"
  } else {
    vars.check_http_vhost                                     = "$host.name$"
  }

  if (host.vars.check_https_uri) {
    vars.check_http_uri                                       = "$host.vars.check_https_uri$"
  } else{
    vars.check_http_uri                                       = "/"
  }

}

apply Service "HTTPS_CERTIFICATE" {
    import                                                      "slowalarm-service"

    check_command                                               = "check_ssl_cert"

    assign where host.vars.check_https_enabled                  == true
    ignore where host.vars.check_https_enabled                  == false
    ignore where host.vars.check_https_cert_check               == false

    vars.check_https_ssl_warn                                   = "7"
    vars.check_https_ssl_crit                                   = "2"

    if (host.vars.check_https_vhost) {
      vars.check_https_vhost                                    = "$host.vars.check_https_vhost$"
    } else {
      vars.check_https_vhost                                    = "$host.name$"
    }
}

apply Dependency "HTTPS_CERTIFICATE" to Service {
  parent_service_name                                         = "HTTPS"

  disable_checks                                              = true
  disable_notifications                                       = true

  assign where host.vars.check_https_enabled                  == true
  assign where service.vars.check_https_enabled               == true
}

I’ve already tried several things with the redundancy_group option, but unfortunately I haven’t found the solution yet.

Anyone have an idea how I can solve this?

Thanks in advance!

Hi @Serpico, while you are defining the Dependency#parent_service_name manually to HTTPS, the assign where condition of this dependency is matching that same service as well, that is defined statically to be the parent one. Change the condition of the dependency to something like this:

assign where service.name != "HTTPS" && (host.vars.check_https_enabled || service.vars.check_https_enabled)
1 Like

Hi @yhabteab,

This is the solution, thanks!