components/ruby/puppet/patches/puppet-14-log-smf.patch
changeset 7565 48aa82a0931f
child 7651 70c0daa6928d
equal deleted inserted replaced
7564:f958607559a6 7565:48aa82a0931f
       
     1 24680838 puppet agent failures should be visible to administrator via SMF interfaces
       
     2 
       
     3 Patch could be submitted but is unlikely to be accepted by upstream.
       
     4 The default behavior is as expected by Puppet.
       
     5 
       
     6 --- puppet-4.7.0/lib/puppet/util/log.rb.orig	2016-12-07 11:50:30.148628055 +0000
       
     7 +++ puppet-4.7.0/lib/puppet/util/log.rb	2016-12-07 11:53:27.475565260 +0000
       
     8 @@ -16,6 +16,7 @@
       
     9  
       
    10    @levels = [:debug,:info,:notice,:warning,:err,:alert,:emerg,:crit]
       
    11    @loglevel = 2
       
    12 +  @degraded = false
       
    13  
       
    14    @desttypes = {}
       
    15  
       
    16 @@ -52,6 +53,16 @@
       
    17    # Reset log to basics.  Basically just flushes and closes files and
       
    18    # undefs other objects.
       
    19    def Log.close(destination)
       
    20 +    if Puppet[:degrade_smf_on_error]
       
    21 +      if !@degraded
       
    22 +        if Puppet.run_mode.agent?
       
    23 +          system 'svcadm clear puppet:agent'
       
    24 +        elsif Puppet.run_mode.master?
       
    25 +          system 'svcadm clear puppet:master'
       
    26 +        end
       
    27 +      end
       
    28 +    end
       
    29 +
       
    30      if @destinations.include?(destination)
       
    31        @destinations[destination].flush if @destinations[destination].respond_to?(:flush)
       
    32        @destinations[destination].close if @destinations[destination].respond_to?(:close)
       
    33 @@ -168,6 +179,17 @@
       
    34    # a potential for a loop here, if the machine somehow gets the destination set as
       
    35    # itself.
       
    36    def Log.newmessage(msg)
       
    37 +    if Puppet[:degrade_smf_on_error]
       
    38 +      if [:err,:alert,:emerg,:crit].include? msg.level and !@degraded
       
    39 +        @degraded = true
       
    40 +        if Puppet.run_mode.agent?
       
    41 +          system 'svcadm mark -s degraded puppet:agent'
       
    42 +        elsif Puppet.run_mode.master?
       
    43 +          system 'svcadm mark -s degraded puppet:master'
       
    44 +        end
       
    45 +      end
       
    46 +    end
       
    47 +
       
    48      return if @levels.index(msg.level) < @loglevel
       
    49  
       
    50      queuemessage(msg) if @destinations.length == 0