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

launchd service provider crashes if a zero-length file in the {System,}/Library/Launch{Daemon,Agent} directory exists

    XMLWordPrintable

Details

    • Bug
    • Status: Closed
    • Normal
    • Resolution: Fixed
    • PUP 4.4.1
    • PUP 4.6.0
    • None
    • None
    • 0
    • Client 2016-06-29
    • Bug Fix
    • Hide
      This fixes a bug in the OSX launchd service provider that caused puppet to crash if an invalid file existed in the Launch directory.
      Now, puppet will detect the invalid file, emit a warning, skip the file, and continue.
      Show
      This fixes a bug in the OSX launchd service provider that caused puppet to crash if an invalid file existed in the Launch directory. Now, puppet will detect the invalid file, emit a warning, skip the file, and continue.

    Description

      If a zero-length file exists in the standard locations for OS X LaunchAgent or LaunchDaemons exist, puppet will exit with an error:

      # touch /Library/LaunchDaemons/foo
      # puppet resource service
      Error: Could not run: undefined method `elements' for nil:NilClass
      

      Not only does this cause puppet resource to fail, but puppet apply as well, causing failures.

      I discovered this by adding some logging to provider/service/launchd.plist, and saw the failure was when trying to read /Library/LaunchDaemons/<internal agent>.plist.puppettmp_9913, so it appears an interrupted puppet run left the .puppettmp_9913 file, which then caused future runs to fail.

      Puppet 3 is not affected, so this is a regression of sorts. It appears there's an unhandled exception down in cfpropertylist:

      $ sudo /Library/GoogleCorpSupport/bin/puppet resource --trace service
      Error: Could not run: undefined method `elements' for nil:NilClass
      /Library/GoogleCorpSupport/Ruby/lib/ruby/site_ruby/cfpropertylist/rbREXMLParser.rb:22:in `load'
      /Library/GoogleCorpSupport/Ruby/lib/ruby/site_ruby/cfpropertylist/rbCFPropertyList.rb:312:in `load_str'
      /Library/GoogleCorpSupport/Ruby/lib/ruby/site_ruby/cfpropertylist/rbCFPropertyList.rb:248:in `initialize'
      /Library/GoogleCorpSupport/Ruby/lib/ruby/site_ruby/puppet/util/plist.rb:83:in `new'
      /Library/GoogleCorpSupport/Ruby/lib/ruby/site_ruby/puppet/util/plist.rb:83:in `new_cfpropertylist'
      /Library/GoogleCorpSupport/Ruby/lib/ruby/site_ruby/puppet/util/plist.rb:62:in `parse_plist'
      /Library/GoogleCorpSupport/Ruby/lib/ruby/site_ruby/puppet/util/plist.rb:39:in `read_plist_file'
      /Library/GoogleCorpSupport/Ruby/lib/ruby/site_ruby/puppet/provider/service/launchd.rb:196:in `read_plist'
      /Library/GoogleCorpSupport/Ruby/lib/ruby/site_ruby/puppet/provider/service/launchd.rb:138:in `block (2 levels) in make_label_to_path_map'
      /Library/GoogleCorpSupport/Ruby/lib/ruby/site_ruby/puppet/provider/service/launchd.rb:137:in `each'
      /Library/GoogleCorpSupport/Ruby/lib/ruby/site_ruby/puppet/provider/service/launchd.rb:137:in `block in make_label_to_path_map'
      /Library/GoogleCorpSupport/Ruby/lib/ruby/site_ruby/puppet/provider/service/launchd.rb:136:in `each'
      /Library/GoogleCorpSupport/Ruby/lib/ruby/site_ruby/puppet/provider/service/launchd.rb:136:in `make_label_to_path_map'
      /Library/GoogleCorpSupport/Ruby/lib/ruby/site_ruby/puppet/provider/service/launchd.rb:157:in `jobsearch'
      /Library/GoogleCorpSupport/Ruby/lib/ruby/site_ruby/puppet/provider/service/launchd.rb:106:in `instances'
      /Library/GoogleCorpSupport/Ruby/lib/ruby/site_ruby/puppet/type.rb:1162:in `block in instances'
      /Library/GoogleCorpSupport/Ruby/lib/ruby/site_ruby/puppet/type.rb:1155:in `collect'
      /Library/GoogleCorpSupport/Ruby/lib/ruby/site_ruby/puppet/type.rb:1155:in `instances'
      /Library/GoogleCorpSupport/Ruby/lib/ruby/site_ruby/puppet/indirector/resource/ral.rb:24:in `search'
      /Library/GoogleCorpSupport/Ruby/lib/ruby/site_ruby/puppet/indirector/indirection.rb:269:in `search'
      /Library/GoogleCorpSupport/Ruby/lib/ruby/site_ruby/puppet/application/resource.rb:225:in `find_or_save_resources'
      /Library/GoogleCorpSupport/Ruby/lib/ruby/site_ruby/puppet/application/resource.rb:140:in `main'
      /Library/GoogleCorpSupport/Ruby/lib/ruby/site_ruby/puppet/application.rb:352:in `run_command'
      /Library/GoogleCorpSupport/Ruby/lib/ruby/site_ruby/puppet/application.rb:344:in `block in run'
      /Library/GoogleCorpSupport/Ruby/lib/ruby/site_ruby/puppet/util.rb:540:in `exit_on_fail'
      /Library/GoogleCorpSupport/Ruby/lib/ruby/site_ruby/puppet/application.rb:344:in `run'
      /Library/GoogleCorpSupport/Ruby/lib/ruby/site_ruby/puppet/util/command_line.rb:128:in `run'
      /Library/GoogleCorpSupport/Ruby/lib/ruby/site_ruby/puppet/util/command_line.rb:72:in `execute'
      /Library/GoogleCorpSupport/bin/puppet:5:in `<main>'
      

      Attachments

        Issue Links

          Activity

            People

              john.duarte John Duarte
              ccaviness Clay Caviness
              Votes:
              1 Vote for this issue
              Watchers:
              5 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Zendesk Support