Got invalid parent id 1382 for host "XXXXX.xxxxx.local" (TemplateTree.php:63)

Hi!

I made some mistakes while adding a new host. Now I’m stuck. I cannot revert the changes.

The screenshot has been altered for anonymity

The error is

Got invalid parent id 1382 for host “XXXXX.local” (TemplateTree.php:63)

As you can see I tried to delete the host again, but I cannot commit anything because of the error message.

This is how the section looks like:

46     public function listParentNamesFor(IcingaObject $object)
[...]
58         if (array_key_exists($id, $this->objectMaps)) {
59             foreach ($this->objectMaps[$id] as $pid) {
60                 if (array_key_exists($pid, $this->names)) {
61                     $parents[] = $this->names[$pid];
62                 } else {
63                     throw new RuntimeException(sprintf(
64                         'Got invalid parent id %d for %s "%s"',
65                         $pid,
66                         $this->type,
67                         $object->getObjectName()
[...]

I found other topics discussing similar errors with TemplateTree.php:63, but I found nothing helpful.

How can I clean up the activity log or delete the faulty host? Any advise will be appreciated.

Additional information

  • Icinga Web 2 version: 2.11.1
  • Web browser: Edge
  • PHP version: 8.1.8
  • Used modules and their versions:
Library Version
icinga/icinga-php-library 0.9.1
icinga/icinga-php-thirdparty 0.11.0
Module Version
setup 2.11.1
businessprocess 2.4.0
dependency_plugin 0.0.0
director 1.9.1
doc 2.11.1
graphite 1.2.1
idoreports 0.10.0
incubator 0.17.0
monitoring 2.11.1
pdfexport 0.10.2
reporting 0.10.0
translation 2.11.1
vspheredb 1.4.0
x509 1.1.2

can you explain the steps that caused the issue?

can you delete server9.local?

At first I filled out the form for SERVER23, then clicked on save. It was more of a guess which field to fill and what to put in them. Then I clicked on Clone and filled in some information for SERVER9 and clicked on save. I totally messed up. I cannot tell you exactly which fields I put data into, but I’m pretty sure the ‘parent’ field was wrong too :expressionless:

For your second question: In order to delete SERVER9.local I first have to click on the server. But then this appears instead:

#0 /usr/share/icingaweb2/modules/director/library/Director/Objects/IcingaObject.php(3009): Icinga\Module\Director\Resolver\TemplateTree->listParentNamesFor()
#1 /usr/share/icingaweb2/modules/director/library/Director/Objects/IcingaObject.php(2922): Icinga\Module\Director\Objects\IcingaObject->listImportNames()
#2 /usr/share/icingaweb2/modules/director/library/Director/Db/Branch/BranchedObject.php(270): Icinga\Module\Director\Objects\IcingaObject->toPlainObject()
#3 /usr/share/icingaweb2/modules/director/library/Director/Web/Controller/ObjectController.php(545): Icinga\Module\Director\Db\Branch\BranchedObject->getBranchedDbObject()
#4 /usr/share/icingaweb2/modules/director/library/Director/Web/Controller/ObjectController.php(538): Icinga\Module\Director\Web\Controller\ObjectController->loadSpecificObject()
#5 /usr/share/icingaweb2/modules/director/library/Director/Web/Controller/ObjectController.php(497): Icinga\Module\Director\Web\Controller\ObjectController->loadObject()
#6 /usr/share/icingaweb2/modules/director/library/Director/Web/Controller/ObjectController.php(90): Icinga\Module\Director\Web\Controller\ObjectController->loadOptionalObject()
#7 /usr/share/php/Icinga/Web/Controller/ActionController.php(170): Icinga\Module\Director\Web\Controller\ObjectController->init()
#8 /usr/share/php/Icinga/Web/Controller/Dispatcher.php(59): Icinga\Web\Controller\ActionController->__construct()
#9 /usr/share/icingaweb2/library/vendor/Zend/Controller/Front.php(937): Icinga\Web\Controller\Dispatcher->dispatch()
#10 /usr/share/php/Icinga/Application/Web.php(290): Zend_Controller_Front->dispatch()
#11 /usr/share/php/Icinga/Application/webrouter.php(105): Icinga\Application\Web->dispatch()
#12 /usr/share/icingaweb2/public/index.php(4): require_once(String)
#13 {main}

I didn’t mention it, because it’s listParentNamesFor again.

please make a screenshot of the form of host server9.local

I’m sorry I can’t do that. All I get is this error message. Just like in this post:

Can you revert the changes by clicking on restore former object?
Screenshot 2023-04-14 at 20.29.17

It just created another log entry on top of the stack. Then I click on Deploy changes but it always gets stuck at the third entry from the bottom. I can create as many changes as I want. As long as the log entry [kamikater] modify host "SERVER9.local" is still there, I won’t make any progress.

I have to fix this today. Maybe I can delete the entry via ssh?

Thanks for trying to help so far!

the problem is somewhere in the inheritance chain of an object, you can dump / backup the director database and remove the object that causes the issue.

can you execute that on the director database:

SELECT * FROM `icinga_host_inheritance` where `parent_host_id`=1382;

Yes, that shows me exactly one entry. But there are only two columns with both 1382 as value. I will not just simply delete the entry, there are probably some constraints. It would make things even worse.

post the output please:

and the output of this too:

SELECT * FROM `icinga_host` where `id` = 1382;

if the first query has the same value in both colums you have to delete this row, because it references the host to import the host itself which causes the issue.

after that you can delete the host in icinga director.

if you want to keep the host you have to add a new template under imports!

make a backup first!!

Finally I got the time to check your ideas.

SELECT * FROM `icinga_host_inheritance` where `parent_host_id`=1382;
+---------+----------------+--------+
| host_id | parent_host_id | weight |
+---------+----------------+--------+
|    1382 |           1382 |      1 |
+---------+----------------+--------+

If host_id and parent_host_id are the same, that has to be the issue, as you said.

The output of SELECT * FROM `icinga_host_inheritance` where `parent_host_id`=1382; is too big to post it directly here, so I will post the most interesting fields of the single result:

id: 1382
uuid: ��i��N'��&��/T 
object_name: SERVER9.local
object_type: object
disabled: n
display_name: SERVER9
address: NULL
has_agent: NULL

It’s tempting to delete both entries, but I’m afraid this would mess everthing up. What do you think? Is it safe to delete them?

the second query shows that it is infact a host that tries to import itself, but you copied the wrong query into the post

just delete the one row:

DELETE FROM icinga_host_inheritance where parent_host_id=1382 and host_id=1382;

after that you should be able to click on the host in icinga director again.
you can choose to delete the host in icinga director, or keep the host.

If you want to keep it, you have to reassign a template, because every host needs a template.

and as always make a backup first!

Thanks a lot for your help! That solved it :slight_smile:

1 Like