my badly broken fact

9 views
Skip to first unread message

Ben Hughes

unread,
Feb 4, 2009, 9:26:21 AM2/4/09
to puppet...@googlegroups.com
Hi all.

I've got this fact, trying to use it with the munin module from DavidS
to work out which drives to graph. Fairly run of the mill, but when ever
I add this in to my facter folder. Puppet barfs with a Timeout::Error

[root@foo-vm:~]# invoke-rc.d puppet start
Starting puppet configuration management tool
info: Loading fact whatraid
info: Loading fact localdisks
/usr/lib/ruby/1.8/timeout.rb:60: execution expired (Timeout::Error)
from /var/lib/puppet/lib/facter/localdisks.rb:20:in `open'
from /var/lib/puppet/lib/facter/localdisks.rb:20
from /usr/lib/ruby/1.8/facter/util/fact.rb:38:in `instance_eval'
from /usr/lib/ruby/1.8/facter/util/fact.rb:38:in `add'


The fact (yeah it's ugly...):

Facter.add("localdisks") do

disks = [ ]
File.open( "/proc/mounts" , "r" ) do |f|
f.each do |line|
foo = line.chomp!.split("\s")
matchey = foo[0].match(/^\/dev\/([a-z0-9\/]+)[0-9]/)
disks.push(matchey[1]) unless matchey.nil?
end
end

setcode do
disks.uniq.join(',')
end
end

However, from the command line with facter, it works:
[root@foo-vm:~]# FACTERLIB=/var/lib/puppet/lib/facter/ facter localdisks
sda


So I'm a little confused. What have I done painfully wrong? ):

--
Ben Hughes - MindCandy
--
Mind Candy Ltd, Registered in England: 05119483, Registered office: 41 Welbeck Street, London, W1G 8EA, UK

Luke Kanies

unread,
Feb 5, 2009, 12:07:49 AM2/5/09
to puppet...@googlegroups.com

Maybe something about a difference in environment making /proc/mounts
not work?

The code certainly looks right to me, although I'll note that your
fact value won't update in the same process -- I'd put all of that
code inside the setcode block.

--
Love is a snowmobile racing across the tundra and then suddenly it
flips over, pinning you underneath. At night, the ice weasels come.
--Matt Groening
---------------------------------------------------------------------
Luke Kanies | http://reductivelabs.com | http://madstop.com

Todd Zullinger

unread,
Feb 17, 2009, 12:17:01 PM2/17/09
to puppet...@googlegroups.com

Seeing /proc/mounts jumps out at me. I have a simple fact that I
added as a plugin and causes a similar timeout. In my case, the code
which reads /proc/mounts is in read_mounts in puppet/util/selinux.rb.
So whenever I have selinux enabled (on a system with libselinux-ruby),
I get this timeout and the plugin retrieval fails. It's quite
strange, as /proc/mounts is successfully read many times during the
course of a puppetd run, both before and after the plugin syncing.
Yet it always fails at this same point.

For anyone curious, this was already filed as:

http://projects.reductivelabs.com/issues/1963

--
Todd OpenPGP -> KeyID: 0xBEAF0CE3 | URL: www.pobox.com/~tmz/pgp
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
The greatest gift you can give another is the purity of your
attention.
-- Richard Moss, M.D.

Reply all
Reply to author
Forward
0 new messages