[Pkg-puppet-devel] [SCM] Puppet packaging for Debian branch, master, updated. debian/0.24.7-1-98-gf19c0e5
James Turnbull
james at lovedthanlost.net
Wed Apr 8 21:48:07 UTC 2009
The following commit has been merged in the master branch:
commit 6b0c1b9170c69829bdf5956d1dec0949dcc08b35
Author: Luke Kanies <luke at madstop.com>
Date: Tue Feb 10 17:21:00 2009 -0600
Fixing #1543 - Nagios parse errors no longer kill Puppet
The problem wasn't actually transactions, it was how
exceptions were raised in Naginator. Well, parse errors
actually resulted in an 'exit', rather than an exception,
and the exceptions that Naginator was raising were not
caught by a normal begin block (SyntaxError, rather than
RuntimeError).
This commit raises a RuntimeError-derived error rather
than exiting.
It also adds some context to the error when Puppet catches it.
Signed-off-by: Luke Kanies <luke at madstop.com>
diff --git a/CHANGELOG b/CHANGELOG
index 8f84116..6b84df0 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -1,4 +1,6 @@
0.24.8
+ Fixing #1543 - Nagios parse errors no longer kill Puppet
+
Fixed #1420 - nagios_serviceescalation not allowing host_name more than one type
Fixed #1884 - Exported resources are marked as unexported when collected on the exporting host
diff --git a/lib/puppet/external/nagios/grammar.ry b/lib/puppet/external/nagios/grammar.ry
index f50818f..87c9092 100644
--- a/lib/puppet/external/nagios/grammar.ry
+++ b/lib/puppet/external/nagios/grammar.ry
@@ -55,6 +55,8 @@ end
----inner
+class ::Nagios::Parser::SyntaxError < RuntimeError; end
+
def parse(src)
@src = src
@@ -66,12 +68,7 @@ def parse(src)
@line = 0
@yydebug = true
- begin
- do_parse
- rescue SyntaxError
- $stderr.print "#{$!}\n"
- exit
- end
+ do_parse
end
# The lexer. Very simple.
@@ -183,6 +180,6 @@ def on_error(token, value, vstack )
if token == '$end'.intern
puts "okay, this is silly"
else
- raise SyntaxError, msg
+ raise ::Nagios::Parser::SyntaxError, msg
end
end
diff --git a/lib/puppet/external/nagios/parser.rb b/lib/puppet/external/nagios/parser.rb
index b7e2c21..d8a8bce 100644
--- a/lib/puppet/external/nagios/parser.rb
+++ b/lib/puppet/external/nagios/parser.rb
@@ -1,22 +1,20 @@
#
# DO NOT MODIFY!!!!
-# This file is automatically generated by racc 1.4.4
+# This file is automatically generated by racc 1.4.5
# from racc grammer file "grammar.ry".
#
#
# parser.rb: generated by racc (runtime embedded)
#
-
-###### racc/parser.rb
-
+###### racc/parser.rb begin
unless $".index 'racc/parser.rb'
$".push 'racc/parser.rb'
-self.class.module_eval <<'..end /usr/lib/ruby/1.8/racc/parser.rb modeval..id1306b79176', '/usr/lib/ruby/1.8/racc/parser.rb', 1
+self.class.module_eval <<'..end racc/parser.rb modeval..id5256434e8a', 'racc/parser.rb', 1
#
-# parser.rb
+# $Id: parser.rb,v 1.7 2005/11/20 17:31:32 aamine Exp $
#
-# Copyright (c) 1999-2003 Minero Aoki <aamine at loveruby.net>
+# Copyright (c) 1999-2005 Minero Aoki
#
# This program is free software.
# You can distribute/modify this program under the same terms of ruby.
@@ -25,8 +23,6 @@ self.class.module_eval <<'..end /usr/lib/ruby/1.8/racc/parser.rb modeval..id1306
# into a Racc output file, you may use that output file
# without restriction.
#
-# $raccId: parser.rb,v 1.4 2003/11/03 13:41:47 aamine Exp $
-#
unless defined?(NotImplementedError)
NotImplementedError = NotImplementError
@@ -39,7 +35,6 @@ unless defined?(::ParseError)
ParseError = Racc::ParseError
end
-
module Racc
unless defined?(Racc_No_Extentions)
@@ -48,14 +43,14 @@ module Racc
class Parser
- Racc_Runtime_Version = '1.4.4'
- Racc_Runtime_Revision = '$raccRevision: 1.4 $'.split[1]
+ Racc_Runtime_Version = '1.4.5'
+ Racc_Runtime_Revision = '$Revision: 1.7 $'.split[1]
- Racc_Runtime_Core_Version_R = '1.4.4'
- Racc_Runtime_Core_Revision_R = '$raccRevision: 1.4 $'.split[1]
+ Racc_Runtime_Core_Version_R = '1.4.5'
+ Racc_Runtime_Core_Revision_R = '$Revision: 1.7 $'.split[1]
begin
require 'racc/cparse'
- # Racc_Runtime_Core_Version_C = (defined in extension)
+ # Racc_Runtime_Core_Version_C = (defined in extention)
Racc_Runtime_Core_Revision_C = Racc_Runtime_Core_Id_C.split[2]
unless new.respond_to?(:_racc_do_parse_c, true)
raise LoadError, 'old cparse.so'
@@ -121,7 +116,7 @@ module Racc
raise NotImplementedError, "#{self.class}\#next_token is not defined"
end
- def _racc_do_parse_rb( arg, in_debug )
+ def _racc_do_parse_rb(arg, in_debug)
action_table, action_check, action_default, action_pointer,
goto_table, goto_check, goto_default, goto_pointer,
nt_base, reduce_table, token_table, shift_n,
@@ -166,11 +161,11 @@ module Racc
### yyparse
###
- def yyparse( recv, mid )
+ def yyparse(recv, mid)
__send__(Racc_YY_Parse_Method, recv, mid, _racc_setup(), true)
end
- def _racc_yyparse_rb( recv, mid, arg, c_debug )
+ def _racc_yyparse_rb(recv, mid, arg, c_debug)
action_table, action_check, action_default, action_pointer,
goto_table, goto_check, goto_default, goto_pointer,
nt_base, reduce_table, token_table, shift_n,
@@ -189,7 +184,6 @@ module Racc
end
end
recv.__send__(mid) do |tok, val|
-# $stderr.puts "rd: tok=#{tok}, val=#{val}"
unless tok
@racc_t = 0
else
@@ -203,12 +197,7 @@ module Racc
act = action_table[i] and
action_check[i] == @racc_state[-1]
act = action_default[@racc_state[-1]]
-# $stderr.puts "02: act=#{act}"
-# $stderr.puts "curstate=#{@racc_state[-1]}"
- else
-# $stderr.puts "01: act=#{act}"
end
-
while act = _racc_evalact(act, arg)
;
end
@@ -221,9 +210,6 @@ module Racc
act = action_table[i] and
action_check[i] == @racc_state[-1]
act = action_default[@racc_state[-1]]
-# $stderr.puts "04: act=#{act}"
- else
-# $stderr.puts "03: act=#{act}"
end
while act = _racc_evalact(act, arg)
;
@@ -237,13 +223,12 @@ module Racc
### common
###
- def _racc_evalact( act, arg )
-# $stderr.puts "ea: act=#{act}"
+ def _racc_evalact(act, arg)
action_table, action_check, action_default, action_pointer,
goto_table, goto_check, goto_default, goto_pointer,
nt_base, reduce_table, token_table, shift_n,
reduce_n, use_result, * = arg
-nerr = 0 # tmp
+ nerr = 0 # tmp
if act > 0 and act < shift_n
#
@@ -276,7 +261,7 @@ nerr = 0 # tmp
when 2 # yyaccept
return shift_n
else
- raise RuntimeError, '[Racc Bug] unknown jump code'
+ raise '[Racc Bug] unknown jump code'
end
end
@@ -314,7 +299,6 @@ nerr = 0 # tmp
break
end
end
-
throw :racc_end_parse, nil if @racc_state.size <= 1
@racc_state.pop
@racc_vstack.pop
@@ -326,7 +310,7 @@ nerr = 0 # tmp
return act
else
- raise RuntimeError, "[Racc Bug] unknown action #{act.inspect}"
+ raise "[Racc Bug] unknown action #{act.inspect}"
end
racc_next_state(@racc_state[-1], @racc_state) if @yydebug
@@ -334,7 +318,7 @@ nerr = 0 # tmp
nil
end
- def _racc_do_reduce( arg, act )
+ def _racc_do_reduce(arg, act)
action_table, action_check, action_default, action_pointer,
goto_table, goto_check, goto_default, goto_pointer,
nt_base, reduce_table, token_table, shift_n,
@@ -375,7 +359,7 @@ nerr = 0 # tmp
goto_default[k1]
end
- def on_error( t, val, vstack )
+ def on_error(t, val, vstack)
raise ParseError, sprintf("\nparse error on value %s (%s)",
val.inspect, token_to_str(t) || '?')
end
@@ -396,20 +380,20 @@ nerr = 0 # tmp
# for debugging output
#
- def racc_read_token( t, tok, val )
+ def racc_read_token(t, tok, val)
@racc_debug_out.print 'read '
@racc_debug_out.print tok.inspect, '(', racc_token2str(t), ') '
@racc_debug_out.puts val.inspect
@racc_debug_out.puts
end
- def racc_shift( tok, tstack, vstack )
+ def racc_shift(tok, tstack, vstack)
@racc_debug_out.puts "shift #{racc_token2str tok}"
racc_print_stacks tstack, vstack
@racc_debug_out.puts
end
- def racc_reduce( toks, sim, tstack, vstack )
+ def racc_reduce(toks, sim, tstack, vstack)
out = @racc_debug_out
out.print 'reduce '
if toks.empty?
@@ -428,20 +412,20 @@ nerr = 0 # tmp
@racc_debug_out.puts
end
- def racc_e_pop( state, tstack, vstack )
+ def racc_e_pop(state, tstack, vstack)
@racc_debug_out.puts 'error recovering mode: pop token'
racc_print_states state
racc_print_stacks tstack, vstack
@racc_debug_out.puts
end
- def racc_next_state( curstate, state )
+ def racc_next_state(curstate, state)
@racc_debug_out.puts "goto #{curstate}"
racc_print_states state
@racc_debug_out.puts
end
- def racc_print_stacks( t, v )
+ def racc_print_stacks(t, v)
out = @racc_debug_out
out.print ' ['
t.each_index do |i|
@@ -450,34 +434,37 @@ nerr = 0 # tmp
out.puts ' ]'
end
- def racc_print_states( s )
+ def racc_print_states(s)
out = @racc_debug_out
out.print ' ['
s.each {|st| out.print ' ', st }
out.puts ' ]'
end
- def racc_token2str( tok )
+ def racc_token2str(tok)
self.class::Racc_token_to_s_table[tok] or
- raise RuntimeError, "[Racc Bug] can't convert token #{tok} to string"
+ raise "[Racc Bug] can't convert token #{tok} to string"
end
- def token_to_str( t )
+ def token_to_str(t)
self.class::Racc_token_to_s_table[t]
end
end
end
-..end /usr/lib/ruby/1.8/racc/parser.rb modeval..id1306b79176
-end # end of racc/parser.rb
+..end racc/parser.rb modeval..id5256434e8a
+end
+###### racc/parser.rb end
module Nagios
class Parser < Racc::Parser
-module_eval <<'..end grammar.ry modeval..id458299781d', 'grammar.ry', 57
+module_eval <<'..end grammar.ry modeval..idcb2ea30b34', 'grammar.ry', 57
+
+class ::Nagios::Parser::SyntaxError < RuntimeError; end
def parse(src)
@src = src
@@ -490,12 +477,7 @@ def parse(src)
@line = 0
@yydebug = true
- begin
- do_parse
- rescue SyntaxError
- $stderr.print "#{$!}\n"
- exit
- end
+ do_parse
end
# The lexer. Very simple.
@@ -607,12 +589,12 @@ def on_error(token, value, vstack )
if token == '$end'.intern
puts "okay, this is silly"
else
- raise SyntaxError, msg
+ raise ::Nagios::Parser::SyntaxError, msg
end
end
-..end grammar.ry modeval..id458299781d
+..end grammar.ry modeval..idcb2ea30b34
-##### racc 1.4.4 generates ###
+##### racc 1.4.5 generates ###
racc_reduce_table = [
0, 0, :racc_error,
diff --git a/lib/puppet/provider/naginator.rb b/lib/puppet/provider/naginator.rb
index 8e8a3d6..233d82e 100644
--- a/lib/puppet/provider/naginator.rb
+++ b/lib/puppet/provider/naginator.rb
@@ -23,7 +23,11 @@ class Puppet::Provider::Naginator < Puppet::Provider::ParsedFile
end
def self.parse(text)
- Nagios::Parser.new.parse(text)
+ begin
+ Nagios::Parser.new.parse(text)
+ rescue => detail
+ raise Puppet::Error, "Could not parse configuration for %s: %s" % [resource_type.name, detail]
+ end
end
def self.to_file(records)
--
Puppet packaging for Debian
More information about the Pkg-puppet-devel
mailing list