Please review pull request #179: Feature #12790: Raise an exception if fact recursion is detected opened by (stschulte)

Description:

Facter can already detect if fact dependencies will end up in a loop.
Recursions can lead to strange errors because facter will return nil (or
an already cached value) for the fact value.

The change now changes the behaviour upon recursion detection: Dont
print a debug message but throw an error. This way a recursion is a
lot easier to detect so we can actually fix it.

examples for recursions:
http://projects.puppetlabs.com/issues/11511
http://projects.puppetlabs.com/issues/12831

  • Opened: Sat Feb 25 15:33:01 UTC 2012
  • Based on: puppetlabs:1.6.x (a51ddb718a28524a690225654f00dc698bd78cdb)
  • Requested merge: stschulte:feature/1.6.x/12790 (3bf844caedd8b7fd63bf81167f0b5e7a1fdd3d7f)

Diff follows:

diff --git a/lib/facter/util/fact.rb b/lib/facter/util/fact.rb
index 3f18d7f..6b0c841 100644
--- a/lib/facter/util/fact.rb
+++ b/lib/facter/util/fact.rb
@@ -103,16 +103,7 @@ def searching?
 
   # Lock our searching process, so we never ge stuck in recursion.
   def searching
-    if searching?
-      Facter.debug "Caught recursion on %s" % @name
-
-      # return a cached value if we've got it
-      if @value
-        return @value
-      else
-        return nil
-      end
-    end
+    raise RuntimeError, "Caught recursion on #{@name}" if searching?
 
     # If we've gotten this far, we're not already searching, so go ahead and do so.
     @searching = true

    

--
You received this message because you are subscribed to the Google Groups "Puppet Developers" 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-dev?hl=en.

Reply via email to