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

assignment of a service to a serviceset over icingacli interface causes failure #1760

Open dskachan opened 5 years ago

dskachan commented 5 years ago

Expected Behavior

Service is added to a service set

Current Behavior

icingacli returns Service 'apt_t' has been modified, and afterwards in icinga2 director WUI, a service with name apt_t isn't displayed correctly. I see instead:

Fatal error: Uncaught ErrorException: Uncaught ErrorException: Creating default object from empty value in /usr/share/php/Icinga/Web/Controller/ActionController.php:127 Stack trace: #0 /usr/share/php/Icinga/Web/Controller/ActionController.php(127): Icinga\Application\ApplicationBootstrap->Icinga\Application\{closure}(2, 'Creating defaul...', '/usr/share/php/...', 127, Array) #1 /usr/share/php/Icinga/Web/Controller/Dispatcher.php(59): Icinga\Web\Controller\ActionController->__construct(Object(Icinga\Web\Request), Object(Icinga\Web\Response), Array) #2 /usr/share/icingaweb2/library/vendor/Zend/Controller/Front.php(937): Icinga\Web\Controller\Dispatcher->dispatch(Object(Icinga\Web\Request), Object(Icinga\Web\Response)) #3 /usr/share/php/Icinga/Application/Web.php(300): Zend_Controller_Front->dispatch(Object(Icinga\Web\Request), Object(Icinga\Web\Response)) #4 /usr/share/php/Icinga/Application/webrouter.php(104): Icinga\Application\Web->dispatch() #5 /usr/share/icingaweb2/public/index.php(4): require_once('/usr/share/php/...' in /usr/share/icingaweb2/library/vendor/Zend/Controller/Plugin/Broker.php on line 259

Possible Solution

I do not know whether it is designed to make it possible to assign a service to a service set over CLI, but if no, I would not expect that cli will change anything in the database and write an error message. If it could be done in some way, I'm kindly asking to provide a way how to do so.

Steps to Reproduce (for bugs)

first create a serviceset:

icingacli director serviceset create --json '{"object_type":"template","object_name":"test1"}'

create a serviece template:

icingacli director service create --json '{"object_type":"template","object_name":"apt_t"}'

assign the service to the serviceset

# icingacli director service set apt_t --service_set test1
Service 'apt_t' has been modified

That is the place where the bug comes. I understand that this is most likely abuse of the function. But as it gives me the correct result and makes the service unusable - something went wrong. I haven't found a list of keys might be used, so, I just took this one form director database.

Your Environment

Tqnsls commented 4 years ago

@dskachan Hey, has this been solved yet?

lazyfrosch commented 4 years ago

I think the basic handling is missing here for serviceset on CLI.

afeefghannam89 commented 3 years ago

I confirm this problem in the actual master with the commit 4f959572f2ad210493602552fce961a8db806be3

I did not find any way to add/delete a service to a service set using serviceset option after icingacli director command, for example icingacli director serviceset test-set set service load

I used service as an option, like @dskachan did, and I confirm his observation. The director will add the service to a serviceset, but he will delete the service template and convert it to apply rule. If this is not the wanted way to add service/s to a serviceset the director should stop this manipulation and another way should be available.

Here is what happen:

icingacli director service set load --service_set test-set

Screenshot 2021-11-10 at 09 29 28

Screenshot 2021-11-10 at 09 30 21

afeefghannam89 commented 3 years ago

ref/NC/735167