After deleting a host or a service via API with parameter "cascade=1" I am not able to restart Icinga2 service because of an inconsistency in config files.
$ service icinga2 restart
[....] checking Icinga2 configuration
[FAIL] checking Icinga2 configuration. Check '/var/log/icinga2/startup.log' for details. ... failed!
Looking at /var/log/icinga2/startup.log
[2019-07-17 09:14:41 +0000] critical/config: Error: Validation failed for object 'test_host!check_uptime!check_uptime-notification' of type 'Notification'; Attribute 'host_name': Object 'test_host' of type 'Host' does not exist.
Location: in /var/lib/icinga2/api/packages/_api/f926d87d-b636-436f-a1d2-00ccb405a299/conf.d/notifications/test_host!check_uptime!check_uptime-notification!check_uptime-notification.conf: 4:2-4:33
/var/lib/icinga2/api/packages/_api/f926d87d-b636-436f-a1d2-00ccb405a299/conf.d/notifications/test_host!check_uptime!check_uptime-notification!check_uptime-notification.conf(2): import "mail-service-notification-norenotify"
/var/lib/icinga2/api/packages/_api/f926d87d-b636-436f-a1d2-00ccb405a299/conf.d/notifications/test_host!check_uptime!check_uptime-notification!check_uptime-notification.conf(3):
/var/lib/icinga2/api/packages/_api/f926d87d-b636-436f-a1d2-00ccb405a299/conf.d/notifications/test_host!check_uptime!check_uptime-notification!check_uptime-notification.conf(4): host_name = "test_host"
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
/var/lib/icinga2/api/packages/_api/f926d87d-b636-436f-a1d2-00ccb405a299/conf.d/notifications/test_host!check_uptime!check_uptime-notification!check_uptime-notification.conf(5): service_name = "check_uptime"
/var/lib/icinga2/api/packages/_api/f926d87d-b636-436f-a1d2-00ccb405a299/conf.d/notifications/test_host!check_uptime!check_uptime-notification!check_uptime-notification.conf(6): user_groups = [ ]
[2019-07-17 09:14:41 +0000] critical/config: 8 errors
After deleting host (or whatever object with "cascade=1") I should be able to restart Icinga2 service without an inconsistency in config files.
If applicable, add screenshots to help explain your problem.
icinga2 - The Icinga 2 network monitoring daemon (version: r2.10.5-1)
Copyright (c) 2012-2019 Icinga GmbH (https://icinga.com/)
License GPLv2+: GNU GPL version 2 or later http://gnu.org/licenses/gpl2.html
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
System information:
Platform: Debian GNU/Linux
Platform version: 9 (stretch)
Kernel: Linux
Kernel version: 4.9.0-8-amd64
Architecture: x86_64
Build information:
Compiler: GNU 6.3.0
Build host: cb654124b660
Application information:
General paths:
Config directory: /etc/icinga2
Data directory: /var/lib/icinga2
Log directory: /var/log/icinga2
Cache directory: /var/cache/icinga2
Spool directory: /var/spool/icinga2
Run directory: /run/icinga2
Old paths (deprecated):
Installation root: /usr
Sysconf directory: /etc
Run directory (base): /run
Local state directory: /var
Internal paths:
Package data directory: /usr/share/icinga2
State path: /var/lib/icinga2/icinga2.state
Modified attributes path: /var/lib/icinga2/modified-attributes.conf
Objects path: /var/cache/icinga2/icinga2.debug
Vars path: /var/cache/icinga2/icinga2.vars
PID path: /run/icinga2/icinga2.pid
Add any other context about the problem here.
Can someone confirm/deny this? Was considering upgrade to 2.10.5 but this is a regression.
Sounds like a bug. Sorry for not answering earlier, I was busy with the 2.11 RC.
For anyone looking into this - the object define a dependency tree which is respected with the DELETE statement and cascade=1. There might be a missing reference to notifications in there.
Thanks for your response. Can you tell me when this bug will be fixed?
@Al2Klimov
@marek130 Sorry, but unfortunately I could not reproduce the error. I can restart Icinga2 without any problems after I deleted the host via API. I did exactly the same as you described above to reproduce the error.
First I created a host via API and the command looks like this. curl -k -v -u root:icinga -H 'Accept: application/json' -X PUT 'https://localhost:5665/v1/objects/hosts/exampleHost' -d '{ "attrs": { "address": "192.168.1.1", "check_command": "hostalive" } }'
Then I created a service for the just created host via api. curl -k -v -u root:icinga -H 'Accept: application/json' -X PUT 'https://localhost:5665/v1/objects/services/exampleHost!uptime' -d '{ "attrs": { "host_name": "exampleHost", "display_name": "exampleHost Uptime", "check_command": "snmp" } }'
And finally I have created a notification for the service also via API curl -k -v -u root:icinga -H 'Accept: application/json' -X PUT 'https://localhost:5665/v1/objects/notifications/exampleHost!uptime!exampleNotification' -d '{ "attrs": { "command": "mail-service-notification", "users": [ "icingaadmin" ], "states": [ "Critical", "Warning", "OK"], "types": [ "Problem", "Recovery"] } }'
After I restarted Icinga2, I deleted the host curl -k -v -u root:icinga -H 'Accept: application/json' -X DELETE 'https://localhost:5665/v1/objects/hosts/exampleHost?cascade=1'
and I can restart Icinga2 as often as I want but the error will not occur as it does with you.
Hello @marek130 and thank you for reporting!
I can't reproduce this as well. Please provide more detailed instructions (as these).
Best,
AK
Most helpful comment
Thanks for your response. Can you tell me when this bug will be fixed?