Chef-client & exceptions


#1

Hello,

Does chef integrate with any exception notification services… like hoptoad?

As I’m writing new recipes I make mistakes that cause chef-client’s to barf
and I only find out about it by going and looking at the log. It’d be nice if the
exception could be forwarded to me the same way that my application level
code does it.

How are you folks dealing with this issue?

John


John Merrells
http://johnmerrells.com
+1.415.244.5808


#2

On Mon, Apr 12, 2010 at 9:25 AM, John Merrells john@merrells.com wrote

Does chef integrate with any exception notification services… like hoptoad?

As I’m writing new recipes I make mistakes that cause chef-client’s to barf
and I only find out about it by going and looking at the log. It’d be nice if the
exception could be forwarded to me the same way that my application level
code does it.

How are you folks dealing with this issue?

It doesn’t as of yet, although we have plans to support this. If you
want hoptoad support right now, this will do it:

$ gem install toadhopper

Then change /usr/bin/chef-client to this:

require ‘rubygems’

version = “>= 0”

if ARGV.first =~ /^(.*)$/ and Gem::Version.correct? $1 then
version = $1
ARGV.shift
end

begin
gem ‘chef’, version
load Gem.bin_path(‘chef’, ‘chef-client’, version)
rescue => e
require 'toadhopper’
Toadhopper(“YOURAPIKEY”).post!(e)
raise
end

And viola, Toad-hoppered Chef.

Adam


Opscode, Inc.
Adam Jacob, CTO
T: (206) 508-7449 E: adam@opscode.com


#3

On Apr 12, 2010, at 11:40 AM, Adam Jacob wrote:

And viola, Toad-hoppered Chef.

Groovy! Thanks!

John


John Merrells
http://johnmerrells.com
+1.415.244.5808


#4

On Apr 12, 2010, at 11:40 AM, Adam Jacob wrote:

On Mon, Apr 12, 2010 at 9:25 AM, John Merrells john@merrells.com wrote

Does chef integrate with any exception notification services… like hoptoad?

As I’m writing new recipes I make mistakes that cause chef-client’s to barf
and I only find out about it by going and looking at the log. It’d be nice if the
exception could be forwarded to me the same way that my application level
code does it.

How are you folks dealing with this issue?

It doesn’t as of yet, although we have plans to support this. If you
want hoptoad support right now, this will do it:

Ah… that catches exceptions when the chef-client dies, but actually I want to
catch the exceptions from the recipe. It looks like the chef-client catches those
and reports them. Is there an easy way to wrap all the recipes with toadhopper?

John


John Merrells
http://johnmerrells.com
+1.415.244.5808


#5

On Apr 15, 2010, at 9:37 AM, John Merrells wrote:

On Apr 12, 2010, at 11:40 AM, Adam Jacob wrote:

On Mon, Apr 12, 2010 at 9:25 AM, John Merrells john@merrells.com wrote

Does chef integrate with any exception notification services… like hoptoad?

As I’m writing new recipes I make mistakes that cause chef-client’s to barf
and I only find out about it by going and looking at the log. It’d be nice if the
exception could be forwarded to me the same way that my application level
code does it.

How are you folks dealing with this issue?

It doesn’t as of yet, although we have plans to support this. If you
want hoptoad support right now, this will do it:

Ah… that catches exceptions when the chef-client dies, but actually I want to
catch the exceptions from the recipe. It looks like the chef-client catches those
and reports them. Is there an easy way to wrap all the recipes with toadhopper?

Mmm… I take that back… I think I must have messed this up somehow… I’ll work
on it some more…

John


John Merrells
http://johnmerrells.com
+1.415.244.5808


#6

On Apr 15, 2010, at 9:43 AM, John Merrells wrote:

Ah… that catches exceptions when the chef-client dies, but actually I want to
catch the exceptions from the recipe. It looks like the chef-client catches those
and reports them. Is there an easy way to wrap all the recipes with toadhopper?

Mmm… I take that back… I think I must have messed this up somehow… I’ll work
on it some more…

I take back my take back…

chef-0.8.8/lib/chef/application.rb

def fatal!(msg, err = -1)
  STDERR.puts("FATAL: #{msg}")
  Chef::Log.fatal(msg)
  Process.exit err
end

so the exception is eaten and the process exits… so it won’t come out of run for toadhopper to send on.

Probably Applciation.fatal! and exit! shoudl be passed the exception, which they can pass to hoptoad, if it’s configured…

John


John Merrells
http://johnmerrells.com
+1.415.244.5808