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 204 forks source link

Director 1.10 Error when editing services in a serviceset #2586

Open terra-nova opened 2 years ago

terra-nova commented 2 years ago

Expected Behavior

It should be possible to manipulate services in a serviceset using the Director GUI (or the underlying REST API calls).

Current Behavior

When trying to modify services in a service set, we get the following error messages for some (but not all) services:

Uncaught Error: Call to a member function toString() on null in /usr/share/icingaweb2/modules/director/application/controllers/ServiceController.php:254
Stack trace:
#0 /usr/share/icingaweb2/modules/director/library/Director/Web/Controller/ObjectController.php(497): Icinga\Module\Director\Controllers\ServiceController->loadObject()
#1 /usr/share/icingaweb2/modules/director/library/Director/Web/Controller/ObjectController.php(90): Icinga\Module\Director\Web\Controller\ObjectController->loadOptionalObject()
#2 /usr/share/icingaweb2/modules/director/application/controllers/ServiceController.php(46): Icinga\Module\Director\Web\Controller\ObjectController->init()
#3 /usr/share/php/Icinga/Web/Controller/ActionController.php(170): Icinga\Module\Director\Controllers\ServiceController->init()
#4 /usr/share/php/Icinga/Web/Controller/Dispatcher.php(59): Icinga\Web\Controller\ActionController->__construct(Object(Icinga\Web\Request), Object(Icinga\Web\Response), Array)
#5 /usr/share/icingaweb2/library/vendor/Zend/Controll

#0 [internal function]: Icinga\Application\Web->Icinga\Application\{closure}()
#1 {main}

Possible Solution

We are aware of the workarounds offered in #2554, #2487 etc., but none of those worked for us. Checking out director master branch did not help either.

The one difference I can think of is that our Director database lives in PostgreSQL, not MySQL. We were not able to reproduce the issue on another installation using MySQL, however that environment has only a fraction of the service sets we have on the main (PostgreSQL-backed) instance.

Steps to Reproduce (for bugs)

Your Environment

terra-nova commented 2 years ago

Just to expand a bit on the issue, because neither the proposed workarounds (see issues #2554, #2487) nor the recent commits to master (e.g. https://github.com/Icinga/icingaweb2-module-director/commit/9a0279b111803a362c00f342bacfde775eb865f6) seem to help with this.

We have defined a new Service Set with a single service using the Director Web UI.

Clicking on a service in the "Services" tab of the service set definition, we get the aforementioned error meesage:

grafik

Uncaught Error: Call to a smember function toString() on null in /usr/share/icingaweb2/modules/director/application/controllers/ServiceController.php:255
Stack trace:
#0 /usr/share/icingaweb2/modules/director/library/Director/Web/Controller/ObjectController.php(497): Icinga\Module\Director\Controllers\ServiceController->loadObject()
#1 /usr/share/icingaweb2/modules/director/library/Director/Web/Controller/ObjectController.php(90): Icinga\Module\Director\Web\Controller\ObjectController->loadOptionalObject()
#2 /usr/share/icingaweb2/modules/director/application/controllers/ServiceController.php(46): Icinga\Module\Director\Web\Controller\ObjectController->init()
#3 /usr/share/php/Icinga/Web/Controller/ActionController.php(170): Icinga\Module\Director\Controllers\ServiceController->init()
#4 /usr/share/php/Icinga/Web/Controller/Dispatcher.php(59): Icinga\Web\Controller\ActionController->__construct(Object(Icinga\Web\Request), Object(Icinga\Web\Response), Array)
#5 /usr/share/icingaweb2/library/vendor/Zend/Controll

#0 [internal function]: Icinga\Application\Web->Icinga\Application\{closure}()
#1 {main}

The code in /usr/share/icingaweb2/modules/director/application/controllers/ServiceController.php:255 runs the following query against our PostgreSQL database:

SELECT icinga_service.uuid FROM icinga_service WHERE (object_name = 'Filesystem /var/lib') AND (service_set_id = '1875')

This query returns no results. There is a row in icinga_service with object_name = 'Filesystem /var/lib', but the service_set_id colums is 1871, not 1875:

# select * from icinga_service where (object_name = 'Filesystem /var/lib');
-[ RECORD 1 ]-----------+-----------------------------------
id                      | 8517
object_name             | Filesystem /var/lib
object_type             | object
disabled                | n
...
service_set_id          | 1871
template_choice_id      |
check_timeout           |
flapping_threshold_high |
flapping_threshold_low  |
uuid                    | \xec589041f7874bff90f603176d965f35

service_set_id 1871 refers to the service set record with object_type "template", while service_set_id 1875 refers to the service set record with object_type "object" (because the service set has been manually assigned to a host):

# select * from icinga_service_set where id in (1871, 1875);
  id  | host_id |             object_name             | object_type | description | assign_filter |                uuid
------+---------+-------------------------------------+-------------+-------------+---------------+------------------------------------
 1871 |         | OS/Linux/SSH/Kubernetes Master Base | template    |             |               | \xb631467cd86b411dae5a88f2e80690b2
 1875 |    5774 | OS/Linux/SSH/Kubernetes Master Base | object      |             |               | \xe90a07059b8d4a1ca519a317e555ec7c
(2 rows)

It seems to me that, since we are trying to manipulate a service in the service set template itself, we are really looking for the service set with id 1871, not 1875. In effect, the database records seem valid, but the lookup code does not?

Thomas-Gelf commented 2 years ago

Hi @terra-nova,

thank you for trying to track this down! DB content looks correct, DB Query doesn't - should use id = 1871. Are you using v1.9.1 with just some cherry-picked fixes, or are you running the current master? I haven't been able to reproduce your issue with the current master

terra-nova commented 2 years ago

Hi @Thomas-Gelf.

We were running v1.9.1 and tried cherry-picking each of the proposed fixes in #2487 and #2554. Since that didn't work out for us, we tried with the recent commits from master, but no luck also.

I just now resynced with master and still get a different error message now:

#0 /usr/share/icingaweb2/modules/director/library/Director/Web/Controller/ObjectController.php(506): Icinga\Module\Director\Controllers\ServiceController->loadObject()
#1 /usr/share/icingaweb2/modules/director/library/Director/Web/Controller/ObjectController.php(100): Icinga\Module\Director\Web\Controller\ObjectController->loadOptionalObject()
#2 /usr/share/icingaweb2/modules/director/library/Director/Web/Controller/ObjectController.php(69): Icinga\Module\Director\Web\Controller\ObjectController->initializeWebRequest()
#3 /usr/share/icingaweb2/modules/director/application/controllers/ServiceController.php(47): Icinga\Module\Director\Web\Controller\ObjectController->init()
#4 /usr/share/php/Icinga/Web/Controller/ActionController.php(170): Icinga\Module\Director\Controllers\ServiceController->init()
#5 /usr/share/php/Icinga/Web/Controller/Dispatcher.php(59): Icinga\Web\Controller\ActionController->__construct(Object(Icinga\Web\Request), Object(Icinga\Web\Response), Array)
#6 /usr/share/icingaweb2/library/vendor/Zend/Controller/Front.php(937): Icinga\Web\Controller\Dispatcher->dispatch(Object(Icinga\Web\Request), Object(Icinga\Web\Response))
#7 /usr/share/php/Icinga/Application/Web.php(290): Zend_Controller_Front->dispatch(Object(Icinga\Web\Request), Object(Icinga\Web\Response))
#8 /usr/share/php/Icinga/Application/webrouter.php(105): Icinga\Application\Web->dispatch()
#9 /usr/share/icingaweb2/public/index.php(4): require_once(String)
#10 {main}

It will take me some time to dig into that, but maybe you'll get some ideas in the meantime just from looking at method names?

Kind regards Florian

Thomas-Gelf commented 2 years ago

Thanks @terra-nova,

do you also have the error message related to that stack trace? And, just to be sure: you didn't checkout the "full" current master, but are using v1.9.1 with 4c502bb and 9a0279b - is that correct?

Cheers, Thomas

Thomas-Gelf commented 2 years ago

@terra-nova: could you also please share the (anonymized) URL from your browser's location bar, leading to this error?

terra-nova commented 2 years ago

do you also have the error message related to that stack trace?

Sorry, that was a copy & paste error. The error message is "Not found" (exception type NotFoundError).

And, just to be sure: you didn't checkout the "full" current master, but are using v1.9.1 with 4c502bb and 9a0279b - is that correct?

This is true for the initial issue and the first comment (https://github.com/Icinga/icingaweb2-module-director/issues/2586#issuecomment-1246454777). After your reply, I checked out master branch and pulled, which resulted in the "new" error message (https://github.com/Icinga/icingaweb2-module-director/issues/2586#issuecomment-1246476500).

could you also please share the (anonymized) URL from your browser's location bar, leading to this error?

https://icinga.mycompany.com/icingaweb2/director/services/sets?q=Master%20Base#!/icingaweb2/director/service?name=Filesystem%20%2Fvar%2Flib&set=OS%2FLinux%2FSSH%2FKubernetes%20Master%20Base
Thomas-Gelf commented 2 years ago

do you also have the error message related to that stack trace?

Sorry, that was a copy & paste error. The error message is "Not found" (exception type NotFoundError).

Given your query, that's at least the correct error - but it loads based on the wrong object

https://icinga.mycompany.com/icingaweb2/director/services/sets?q=Master%20Base#!/icingaweb2/director/service?name=Filesystem%20%2Fvar%2Flib&set=OS%2FLinux%2FSSH%2FKubernetes%20Master%20Base

Thank you, please also share the URL before clicking on the Service itself (the one leading to the list of services in this set)

terra-nova commented 2 years ago

Thank you, please also share the URL before clicking on the Service itself (the one leading to the list of services in this set)

https://icinga.mycompany.com/icingaweb2/director/services/sets?q=Master%20Base#!/icingaweb2/director/serviceset/services?uuid=b631467c-d86b-411d-ae5a-88f2e80690b2
Wintermute2k6 commented 1 year ago

ref/NC/779144

Thomas-Gelf commented 1 year ago

@terra-nova, @Wintermute2k6: there have been multiple variants of this issue, all of them SHOULD have been fixed with the current master, most of them already with v1.10.2. As I'm preparing the next release, it would be great if you could give it a try, In case it still fails for you, please provide me with the related URL and Stack Trace.

SylvainMartin-LMSYS commented 1 year ago

We have the same problem. Have you a workaround until the next version ? Here the versions use on my server

Capture d’écran 2023-08-22 à 16 20 05