Icinga / icingaweb2-module-director

The Director aims to be your new favourite Icinga config deployment tool. Director is designed for those who want to automate their configuration deployment and those who want to grant their “point & click” users easy access to the configuration.
https://icinga.com/docs/director/latest
GNU General Public License v2.0
413 stars 203 forks source link

Memory Leak when Loop in Service Template gets Created #2818

Open MisterMountain opened 1 year ago

MisterMountain commented 1 year ago

Expected Behavior

No Memory Leak

Current Behavior

Modify Service Template leads throws the following Error:

Fatal error
: Allowed memory size of 134217728 bytes exhausted (tried to allocate 262144 bytes) in
/usr/share/icinga-php/vendor/vendor/shardj/zf1-future/library/Zend/Db/Select.php
on line
979

Fatal error
: Allowed memory size of 134217728 bytes exhausted (tried to allocate 262144 bytes) in
Unknown
on line
0

Steps to Reproduce (for bugs)

  1. Create a Service Template with a name, lets call the Name "Mountain"
  2. Save it by clicking on Add
  3. Now Modify the created Service Template and add an Import, which Imports something with the same name as our Service Template
  4. Now the Director throws an Error Message: "Loop detected: Mountain -> Mountain (TemplateTree.php:225)"
  5. However, Save the Service Template by clicking on Store
  6. Try to Modify the Service Template again
  7. Icinga Director will take a long time to load, until it fails with the above Error Message

Your Environment

Director version (System - About): 1.10.2
Icinga Web 2 version and modules (System - About): 2.12.0
Icinga 2 version (icinga2 --version): 2.14.0
Operating System and version: Debian 11
Webserver, PHP versions: Apache2 2.4.56, PHP 7.4.33
Virtual Machine with 2GB RAM (i know its not much)
MisterMountain commented 1 year ago

I have created another Icinga Instance on a Virtual Machine with 32GB RAM and disabled any PHP Timeouts and Memory Limits, now i see the Memory Percentage of the php-fpm Process increasing by 0.1 to 0.2 percent every second. So it seems to be actually a memory leak for me.

moreamazingnick commented 1 year ago

if you let the director import the same template inside a template you create a loop. You get an error that this is a problem. I don't know why it is possible to save the malformed object, but you should not create such a scenario anyway. I think of it in a different way like, if you buy a knife. In a logical sense it is used to cut something, but in europe there is not warning about cutting yourself. However if you want to fix your malformed template you can use the Activity Log restore action.

MisterMountain commented 1 year ago

Its also possible to remove the loopcreating property by selecting multiple templates and then remove them: image

However, i know its a bad practive and you should not do it. But if someone does it, the loop should definitely not happen.