Issue #2930 has been updated by konrad rzentarzewski.
yes, i'm not ruby black belt :) however 2nd form (just without function_template call) works just right. can you replicate this problem? ---------------------------------------- Bug #2930: endless loop when calling function from within custom function http://projects.reductivelabs.com/issues/2930 Author: konrad rzentarzewski Status: Investigating Priority: Normal Assigned to: Markus Roberts Category: functions Target version: Affected version: 0.25.1 Keywords: puppetmaster hangs in endless loop Branch: based on [http://reductivelabs.com/trac/puppet/wiki/WritingYourOwnFunctions] it should be possible to call custom functions (including template and include functions) from within own function. however in 0.25.1 this leads to endless loops, consuming all system memory on puppetmaster. below are the 2 functions. 1st one causes loop and exhausts all resources, while 2nd one runs without problems. <pre> Puppet::Parser::Functions::newfunction(:template_search, :type => :rvalue, :doc => "Find first existing file and run puppet template function on it. If you want to concatenate multiple templates try var = template_search(file1,file2) + template_search(file3,file4) and then use var in your resources.") do |vals| ret = nil errors = Array.new vals.each do |file| debug "in :template_search find %s" % file ret = nil begin ret = function_template(file) rescue Exception=>e if /could.not.find.template/i =~ e debug "in :template_search not found %s" % file else raise Puppet::ParseError, "in :template_search exception in %s: %s" % [file,e] errors.push(e) end end if ret debug "in :template_search found %s" % file break end end if ret ret else if errors.length > 0 raise Puppet::ParseError, "Errors from :template function: %s" % errors.join(", ") else raise Puppet::ParseError, "Could not find any files from %s" % vals.join(", ") end end end </pre> <pre> Puppet::Parser::Functions::newfunction(:template_search, :type => :rvalue, :doc => "Find first existing file and run puppet template function on it. If you want to concatenate multiple templates try var = template_search(file1,file2) + template_search(file3,file4) and then use var in your resources.") do |vals| require 'erb' ret = nil errors = Array.new vals.each do |file| debug "in :template_search find %s" % file ret = nil begin wrapper = Puppet::Parser::TemplateWrapper.new(self) wrapper.file = file ret = wrapper.result rescue Exception=>e if /could.not.find.template/i =~ e debug "in :template_search not found %s" % file else raise Puppet::ParseError, "in :template_search exception in %s: %s" % [file,e] errors.push(e) end end if ret debug "in :template_search found %s" % file break end end if ret ret else if errors.length > 0 raise Puppet::ParseError, "Errors from :template function: %s" % errors.join(", ") else raise Puppet::ParseError, "Could not find any files from %s" % vals.join(", ") end end end </pre> -- You have received this notification because you have either subscribed to it, or are involved in it. To change your notification preferences, please click here: http://reductivelabs.com/redmine/my/account -- You received this message because you are subscribed to the Google Groups "Puppet Bugs" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/puppet-bugs?hl=en.
