Uploaded image for project: 'Puppet'
  1. Puppet
  2. PUP-6986

Service provider fails when hasstatus => false and the output of 'ps -ef' happens to contains non-ASCII chars

    XMLWordPrintable

Details

    • Improvement
    • Status: Closed
    • Major
    • Resolution: Fixed
    • None
    • PUP 4.10.9, PUP 5.3.3
    • None
      • New tests should reproduce this issue and demonstrate the fix
    • Platform Core
    • 3
    • AP 2017-01-11, AP 2017-03-08, Agent 2017-03-22, Platform Core KANBAN
    • Bug Fix
    • Hide
      The base service provider would previously fail with a stacktrace if the process line for any given service contained UTF-8 characters and puppet was not running in UTF-8, causing service checks to fail. puppet will now attempt to convert the PS output to UTF-8, and on failure force valid interpretation by replacing invalid UTF-8 characters with replacement characters. This allows puppet to correctly match the running UTF-8 service in PS output to the managed service name.
      Show
      The base service provider would previously fail with a stacktrace if the process line for any given service contained UTF-8 characters and puppet was not running in UTF-8, causing service checks to fail. puppet will now attempt to convert the PS output to UTF-8, and on failure force valid interpretation by replacing invalid UTF-8 characters with replacement characters. This allows puppet to correctly match the running UTF-8 service in PS output to the managed service name.
    • No Action
    • Provider failure isn't catastrophic; tested in unit, so no additional work required

    Description

      When a service resource uses the parameter `hasstatus => false`, puppet will search the output of `ps -ef` to determine the status of the service.

      If the output of `ps -ef` happens to contain non-ASCII characters, we see the following stack trace:

      Error: /Stage[main]/Automic/Service[automic]: Could not evaluate: invalid byte sequence in US-ASCII 
      /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/provider/service/base.rb:38:in `match' 
      /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/provider/service/base.rb:38:in `block (2 levels) in getpid' 
      /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/provider/service/base.rb:37:in `each_line' 
      /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/provider/service/base.rb:37:in `block in getpid' 
      /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/provider/service/base.rb:36:in `popen' 
      /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/provider/service/base.rb:36:in `getpid' 
      /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/provider/service/base.rb:66:in `status' 
      /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/type/service.rb:110:in `retrieve' 
      /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/type.rb:1068:in `retrieve' 
      /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/type.rb:1096:in `retrieve_resource' 
      /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/transaction/resource_harness.rb:221:in `from_resource' 
      /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/transaction/resource_harness.rb:19:in `evaluate' 
      /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/transaction.rb:212:in `apply' 
      /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/transaction.rb:228:in `eval_resource' 
      /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/transaction.rb:151:in `call' 
      /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/transaction.rb:151:in `block (2 levels) in evaluate' 
      /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/util.rb:386:in `block in thinmark' 
      /opt/puppetlabs/puppet/lib/ruby/2.1.0/benchmark.rb:294:in `realtime' 
      /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/util.rb:385:in `thinmark' 
      /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/transaction.rb:151:in `block in evaluate' 
      /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/graph/relationship_graph.rb:118:in `traverse' 
      /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/transaction.rb:142:in `evaluate' 
      /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/resource/catalog.rb:222:in `block in apply' 
      /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/util/log.rb:155:in `with_destination' 
      /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/transaction/report.rb:118:in `as_logging_destination' 
      /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/resource/catalog.rb:221:in `apply' 
      /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/configurer.rb:171:in `block in apply_catalog' 
      /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/util.rb:223:in `block in benchmark' 
      /opt/puppetlabs/puppet/lib/ruby/2.1.0/benchmark.rb:294:in `realtime' 
      /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/util.rb:222:in `benchmark' 
      /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/configurer.rb:170:in `apply_catalog' 
      /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/configurer.rb:315:in `run_internal' 
      /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/configurer.rb:186:in `block in run' 
      /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/context.rb:65:in `override' 
      /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet.rb:240:in `override' 
      /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/configurer.rb:185:in `run' 
      /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/agent.rb:45:in `block (4 levels) in run' 
      /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/agent/locker.rb:21:in `lock' 
      /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/agent.rb:45:in `block (3 levels) in run' 
      /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/agent.rb:98:in `with_client' 
      /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/agent.rb:42:in `block (2 levels) in run' 
      /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/agent.rb:65:in `run_in_fork' 
      /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/agent.rb:41:in `block in run' 
      /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/application.rb:179:in `call' 
      /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/application.rb:179:in `controlled_run' 
      /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/agent.rb:39:in `run' 
      /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/application/agent.rb:353:in `onetime' 
      /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/application/agent.rb:331:in `run_command' 
      /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/application.rb:344:in `block in run' 
      /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/util.rb:540:in `exit_on_fail' 
      /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/application.rb:344:in `run' 
      /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/util/command_line.rb:128:in `run' 
      /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/util/command_line.rb:72:in `execute' 
      /opt/puppetlabs/puppet/bin/puppet:5:in `<main>'
      

      Could puppet avoid this error by translating the output to ASCII-8BIT encoding in the Puppet provider before doing regex matches?

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              erik.hansen Erik Hansen
              Votes:
              0 Vote for this issue
              Watchers:
              7 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Zendesk Support