Director template inheritance loop – “Loop detected: check_vm_memory.sh → check_vm_memory.sh” + PHP timeout

Service template - modify
Loop detected: check_vm_memory.sh → check_vm_memory.sh

What I’ve tried:

  • Checked the template in Director UI → shows the loop.
  • Clicked Modify → UI freezes → timeout.
  • Restarted Director daemon and Icinga Web 2.
  • Rebooted the entire host → no change.
  • Haven’t yet touched the database directly (want to confirm safe method first).

Icinga Web 2 Version: 2.11.3
Icinga 2 Version: r2.14.3-1
PHP Version: 8.0.30
Server OS: AlmaLinux 8.10 (Cerulean Leopard)
Web browser: Chrome (latest)

businessprocess 2.4.0
director 1.11.5
doc 2.11.3
graphite 1.2.5
idoreports 0.10.0
incubator 0.22.0
migrate 2.11.3
monitoring 2.11.3
nagvis 1.2.1
pdfexport 0.10.2
reactbundle 0.7.0
reporting 1.0.3
translation 2.11.3
vspheredb 1.7.1
x509 1.1.2

Thx!:blush:

this can happen if you store a template and accidentally reference the template as an import

you can fix that manually using some database tool or plain sql.
like here Icinga2 director loop

so what is it mysql or postgre?

I would recommend to play around a bit with the icingacli director service command.
I am pretty sure there is some way to either remove one of those, or modify one of those to import something else.

what helped too in the past:

find the change that caused the problem in the activitylog.

there you can restore the object to the previous state

1 Like

Tried it out during my lunch break, its actually possible to fix this using icingacli director service set.

root@icinga:~# icingacli director service show tpl_cluster
ERROR: Icinga\Module\Director\Exception\NestingError in /usr/share/icingaweb2/modules/director/library/Director/Resolver/TemplateTree.php:226 with message: Loop detected: tpl_cluster -> tpl_cluster2 -> tpl_cluster

So first, we can see theres a pretty similar error to yours. A circular dependency loop.
Of course, we can try deleting it, but it wont work:

root@icinga:~# icingacli director service delete tpl_cluster2
ERROR: Zend_Db_Statement_Exception in /usr/share/icinga-php/vendor/vendor/shardj/zf1-future/library/Zend/Db/Statement/Pdo.php:235 with message: SQLSTATE[23000]: Integrity constraint violation: 1451 Cannot delete or update a parent row: a foreign key constraint fails ("director"."icinga_service_inheritance", CONSTRAINT "icinga_service_inheritance_parent_service" FOREIGN KEY ("parent_service_id") REFERENCES "icinga_service" ("id") ON UPDATE CASCADE), query was: DELETE FROM icinga_service WHERE (uuid = 0xff9405917c22487a80b7ba63b0aec9d7)

Alright. Lets try modifying one of these two services, so that it imports something else.

root@icinga:~# icingacli director service set tpl_cluster --imports tpl_lshw
Service 'tpl_cluster' has been modified

Great, no error message. Lets look at the modified service, just to be sure!

root@icinga:~# icingacli director service show tpl_cluster
/** zones.d/director-global/service_templates.conf **/

template Service "tpl_cluster" {
    import "tpl_lshw"

    check_command = "cluster"
}

Looks like its gone :wink:

cc @moreamazingnick I think its better to fix this using icingacli then the so called Frickellösung using SQL.

1 Like

I like that better too, now that I know that this works.
…and the activitylog approach :slight_smile:

1 Like

Problem was solved with restoring object in Icinga director :slight_smile:

1 Like