Skip to content
This repository has been archived by the owner on Nov 6, 2024. It is now read-only.

[dev.icinga.com #12843] Adding zone attribute to basically all resources is failing #234

Open
icinga-migration opened this issue Oct 3, 2016 · 5 comments
Assignees
Labels

Comments

@icinga-migration
Copy link

This issue has been migrated from Redmine: https://dev.icinga.com/issues/12843

Created by rnekkanti on 2016-10-03 17:45:24 +00:00

Assignee: (none)
Status: New
Target Version: (none)
Last Update: 2016-10-03 17:45:24 +00:00 (in Redmine)


Below is the applyservice resource definition:

icinga2_applyservice 'cluster-check' do
import 'landing-page'
display_name 'cluster-check'
check_command 'cluster'
zone 'test'
assign_where ['match("opsmonitor", host.vars.tags)']
ignore_where ['match("ops-nw-monitor*", host.name)']
end

Error:

  • template[zone_template_applyservice_test_cluster-check] action create

Error executing action `create` on resource 'template[zone_template_applyservice_test_cluster-check]'

NoMethodError

  • undefined method `empty?' for 0:Fixnum*

Cookbook Trace:

/var/chef/cache/cookbooks/icinga2/libraries/provider_instance.rb:188:in `block (3 levels) in process_icinga2_resources'
/var/chef/cache/cookbooks/compat_resource/files/lib/chef_compat/monkeypatches/chef/runner.rb:78:in `run_action'
/var/chef/cache/cookbooks/compat_resource/files/lib/chef_compat/monkeypatches/chef/runner.rb:106:in `block (2 levels) in converge'
/var/chef/cache/cookbooks/compat_resource/files/lib/chef_compat/monkeypatches/chef/runner.rb:106:in `each'
/var/chef/cache/cookbooks/compat_resource/files/lib/chef_compat/monkeypatches/chef/runner.rb:106:in `block in converge'
/var/chef/cache/cookbooks/compat_resource/files/lib/chef_compat/monkeypatches/chef/runner.rb:105:in `converge'

Resource Declaration:

# In /var/chef/cache/cookbooks/icinga2/libraries/provider_instance.rb

179: zoned_te = template "zone_template*#{resource_name}*#{zone}_#{new_resource.name}" do
180: path ::File.join(node['icinga2']['zones_dir'], zone, "#{resource_name}_template.conf")
181: source "object.#{resource_name}.conf.erb"
182: cookbook 'icinga2'
183: owner node['icinga2']['user']
184: group node['icinga2']['group']
185: mode 0o640
186: variables :objects => zoned_templates
187: notifies :reload, 'service[icinga2]'
188: only_if { !zoned_templates.length.empty? }
189: end
190:

Compiled Resource:

# Declared in /var/chef/cache/cookbooks/icinga2/libraries/provider_instance.rb:179:in `block in process_icinga2_resources'

template("zone_template_applyservice_test_cluster-check") do
action [:create]
retries 0
retry_delay 2
default_guard_interpreter :default
path "/etc/icinga2/zones.d/test/applyservice_template.conf"
backup 5
atomic_update true
source "object.applyservice.conf.erb"
cookbook "icinga2"
variables {:objects=>{}}
declared_type :template
cookbook_name "gnops_icinga2"
mode 416
owner "nagios"
group "nagios"
only_if { #code block }
end

Running handlers:
Running handlers complete
Chef Client failed. 4 resources updated in 06 seconds
root@ops-monitor-test-1:/etc/icinga2/zones.d/test#

When I modify the icinga cookbook provider_instance.rb file and change the zoned_objects.length.empty? to zoned_objects.empty? and zoned_templates.length.empty? to zoned_templates.empty? in line 175 and 189 we are not seeing the error. Below is the modified code. We did a for the zoned_objects.length and is returning 1. Below is the put.

zoned_ot = template "zone_config*#{resource_name}#{zone}_#{new_resource.name}" do
path ::File.join(node['icinga2']['zones_dir'], zone, "#{resource_name}.conf")
source "object.#{resource_name}.conf.erb"
cookbook 'icinga2'
owner node['icinga2']['user']
group node['icinga2']['group']
mode 0640
variables :objects => zoned_objects
notifies :reload, 'service[icinga2]'
only_if { !zoned_objects.empty? }
end
puts 'zone length'
puts zoned_objects.length
zoned_te = template "zone_template
#{resource_name}*#{zone}_#{new_resource.name}" do
path ::File.join(node['icinga2']['zones_dir'], zone, "#{resource_name}_template.conf")
source "object.#{resource_name}.conf.erb"
cookbook 'icinga2'
owner node['icinga2']['user']
group node['icinga2']['group']
mode 0o640
variables :objects => zoned_templates
notifies :reload, 'service[icinga2]'
only_if { !zoned_templates.empty? }
end

zone length
1
(up to date)

@vkhatri vkhatri self-assigned this Jan 17, 2017
@rnekkanti
Copy link

@vkhatri any update on this. I am seeing the same issue on the newest version of the cookbook as well.

@tonnenpinguin
Copy link
Contributor

Same here!

@vkhatri
Copy link
Member

vkhatri commented Feb 21, 2017

checking, will update shortly.

@vkhatri
Copy link
Member

vkhatri commented Mar 5, 2017

@tonnenpinguin 👍 Thank you for the PR.

@tonnenpinguin
Copy link
Contributor

I think this can be closed, right?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

4 participants