Closed dwt closed 2 years ago
I should have added that ordinary defined services (without apply) seem to evaluate the templates correctly.
This has the rather unfortunate side effect that I cannot configure the defaults for a service in the apply rule, which currently leads to many unnecessary warnings because I cannot set a longer timeout for remote check that is rather slow. :/ Is this a bug you guys can reproduce?
ping - @developers can you guys reproduce the issue? Am I missing something? Is this a well disguised feature?
ping @maintainers? Any info on this? Do you require additional input for me to reproduce?
Looks strange indeed and the current behavior makes no sense for me:
root@1eaa341b7fa9:/# cat -n /etc/icinga2/conf.d/test.conf
1 template Service "test" default {
2 retry_interval = 23s
3 }
4
5 object Host "test" {
6 check_command = "dummy"
7 }
8
9 apply Service "test" {
10 assign where true
11 check_command = "dummy"
12 retry_interval = 42s
13 }
root@1eaa341b7fa9:/# icinga2 daemon -C
[2022-03-08 15:45:27 +0000] information/cli: Icinga application loader (version: v2.13.0-235-gbf5b90570)
[2022-03-08 15:45:27 +0000] information/cli: Loading configuration file(s).
[2022-03-08 15:45:27 +0000] information/ConfigItem: Committing config item(s).
[2022-03-08 15:45:27 +0000] information/ConfigItem: Instantiated 1 NotificationComponent.
[2022-03-08 15:45:27 +0000] information/ConfigItem: Instantiated 1 CheckerComponent.
[2022-03-08 15:45:27 +0000] information/ConfigItem: Instantiated 1 Service.
[2022-03-08 15:45:27 +0000] information/ConfigItem: Instantiated 3 Zones.
[2022-03-08 15:45:27 +0000] information/ConfigItem: Instantiated 1 Host.
[2022-03-08 15:45:27 +0000] information/ConfigItem: Instantiated 1 IcingaApplication.
[2022-03-08 15:45:27 +0000] information/ConfigItem: Instantiated 1 Endpoint.
[2022-03-08 15:45:27 +0000] information/ConfigItem: Instantiated 244 CheckCommands.
[2022-03-08 15:45:27 +0000] information/ScriptGlobal: Dumping variables to file '/var/cache/icinga2/icinga2.vars'
[2022-03-08 15:45:27 +0000] information/cli: Finished validating the configuration file(s).
root@1eaa341b7fa9:/# icinga2 object list -t Service
Object 'test!test' of type 'Service':
% declared in '/etc/icinga2/conf.d/test.conf', lines 9:1-9:20
* __name = "test!test"
* action_url = ""
* check_command = "dummy"
% = modified in '/etc/icinga2/conf.d/test.conf', lines 11:3-11:25
* check_interval = 300
* check_period = ""
* check_timeout = null
* command_endpoint = ""
* display_name = "test"
* enable_active_checks = true
* enable_event_handler = true
* enable_flapping = false
* enable_notifications = true
* enable_passive_checks = true
* enable_perfdata = true
* event_command = ""
* flapping_ignore_states = null
* flapping_threshold = 0
* flapping_threshold_high = 30
* flapping_threshold_low = 25
* groups = [ ]
* host_name = "test"
% = modified in '/etc/icinga2/conf.d/test.conf', lines 9:1-9:20
* icon_image = ""
* icon_image_alt = ""
* max_check_attempts = 3
* name = "test"
% = modified in '/etc/icinga2/conf.d/test.conf', lines 9:1-9:20
* notes = ""
* notes_url = ""
* package = "_etc"
% = modified in '/etc/icinga2/conf.d/test.conf', lines 9:1-9:20
* retry_interval = 23
% = modified in '/etc/icinga2/conf.d/test.conf', lines 12:3-12:22
% = modified in '/etc/icinga2/conf.d/test.conf', lines 2:3-2:22
* source_location
* first_column = 1
* first_line = 9
* last_column = 20
* last_line = 9
* path = "/etc/icinga2/conf.d/test.conf"
* templates = [ "test", "test" ]
% = modified in '/etc/icinga2/conf.d/test.conf', lines 9:1-9:20
% = modified in '/etc/icinga2/conf.d/test.conf', lines 1:0-1:30
* type = "Service"
* vars = null
* volatile = false
* zone = ""
@julianbrost Do you guys plan to fix this behaviour? Can you suggest a workaround until this gets fixed?
I had the idea pull out the customization into it's own template to enforce it overriding the inherited template that way. Not pretty, but might work? Do you maybe see a better way?
Duplicate of #7914
Describe the bug
default templates for services and apply service interaction is buggy.
The documentation on default templates states that: 'Default templates are imported before any other user-specified statement in an object definition is evaluated.'.
However, when default templates and service apply rules are combined, default templates are applied after all the rules of the apply rule. The effect is that the default template overrides settings done in the apply rule.
To Reproduce
Example:
This resolves
retry_interval
to 34.Expected behavior
I expect to be able to override attributes in apply rules. In the given example, the attribute
retry_interval
should resolve to 33Screenshots
Your Environment
Enabled features (
icinga2 feature list
): ``` icinga@ops:/$ icinga2 feature list Disabled features: debuglog elasticsearch gelf graphite ido-mysql ido-pgsql influxdb mainlog opentsdb perfdata syslog Enabled features: api checker icingadb notificationIcinga Web 2 version and modules (System - About): ``` Icinga Web 2 Version 2.9.5 Git commit 52d51f0ee532c33f2a1ab3136d5cfd5fd20d5f4c PHP Version 7.4.25 Git commit date 2022-02-16
Config validation (
icinga2 daemon -C
): ```icinga@ops:/$ icinga2 daemon -C [2022-02-17 12:18:52 +0000] information/cli: Icinga application loader (version: v2.13.0-197-g8016b013a) [2022-02-17 12:18:52 +0000] information/cli: Loading configuration file(s). [2022-02-17 12:18:52 +0000] information/ConfigItem: Committing config item(s). [2022-02-17 12:18:52 +0000] information/ApiListener: My API identity: ops.zms.hosting [2022-02-17 12:18:53 +0000] warning/ApplyRule: Apply rule 'backup-downtime' (in /etc/icinga2/conf.d/downtimes.conf: 5:1-5:52) for type 'ScheduledDowntime' does not match anywhere! [2022-02-17 12:18:53 +0000] warning/ApplyRule: Apply rule '' (in /etc/icinga2/conf.d/services.conf: 34:1-34:53) for type 'Service' does not match anywhere! [2022-02-17 12:18:53 +0000] warning/ApplyRule: Apply rule 'icinga' (in /etc/icinga2/conf.d/services.conf: 41:1-41:22) for type 'Service' does not match anywhere! [2022-02-17 12:18:53 +0000] warning/ApplyRule: Apply rule 'load' (in /etc/icinga2/conf.d/services.conf: 46:1-46:20) for type 'Service' does not match anywhere! [2022-02-17 12:18:53 +0000] warning/ApplyRule: Apply rule 'procs' (in /etc/icinga2/conf.d/services.conf: 55:1-55:21) for type 'Service' does not match anywhere! [2022-02-17 12:18:53 +0000] warning/ApplyRule: Apply rule 'swap' (in /etc/icinga2/conf.d/services.conf: 61:1-61:20) for type 'Service' does not match anywhere! [2022-02-17 12:18:53 +0000] warning/ApplyRule: Apply rule 'users' (in /etc/icinga2/conf.d/services.conf: 67:1-67:21) for type 'Service' does not match anywhere! [2022-02-17 12:18:53 +0000] information/ConfigItem: Instantiated 1 IcingaDB. [2022-02-17 12:18:53 +0000] information/ConfigItem: Instantiated 1 NotificationComponent. [2022-02-17 12:18:53 +0000] information/ConfigItem: Instantiated 1 CheckerComponent. [2022-02-17 12:18:53 +0000] information/ConfigItem: Instantiated 1 UserGroup. [2022-02-17 12:18:53 +0000] information/ConfigItem: Instantiated 2 Users. [2022-02-17 12:18:53 +0000] information/ConfigItem: Instantiated 3 ServiceGroups. [2022-02-17 12:18:53 +0000] information/ConfigItem: Instantiated 4 TimePeriods. [2022-02-17 12:18:53 +0000] information/ConfigItem: Instantiated 25 Services. [2022-02-17 12:18:53 +0000] information/ConfigItem: Instantiated 3 Zones. [2022-02-17 12:18:53 +0000] information/ConfigItem: Instantiated 1 IcingaApplication. [2022-02-17 12:18:53 +0000] information/ConfigItem: Instantiated 2 Hosts. [2022-02-17 12:18:53 +0000] information/ConfigItem: Instantiated 4 NotificationCommands. [2022-02-17 12:18:53 +0000] information/ConfigItem: Instantiated 54 Notifications. [2022-02-17 12:18:53 +0000] information/ConfigItem: Instantiated 2 HostGroups. [2022-02-17 12:18:53 +0000] information/ConfigItem: Instantiated 1 Endpoint. [2022-02-17 12:18:53 +0000] information/ConfigItem: Instantiated 2 ApiUsers. [2022-02-17 12:18:53 +0000] information/ConfigItem: Instantiated 244 CheckCommands. [2022-02-17 12:18:53 +0000] information/ConfigItem: Instantiated 1 ApiListener. [2022-02-17 12:18:53 +0000] information/ScriptGlobal: Dumping variables to file '/var/cache/icinga2/icinga2.vars' [2022-02-17 12:18:53 +0000] information/cli: Finished validating the configuration file(s).