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

Old report processors don't work with the new puppetserver http client

    XMLWordPrintable

Details

    • Bug
    • Status: Resolved
    • Normal
    • Resolution: Fixed
    • None
    • PUP 7.0.0
    • None
    • Coremunity
    • Platform Core KANBAN
    • Needs Assessment
    • Not Needed
    • This issue only existed during development builds during platform 7 development or oddball configurations using puppet-agent 6.18.0 with puppetserver 7, which is not supported.
    • Needs Assessment

    Description

      Add the following report processor to lib/puppet/reports/legacy.rb, which is a simplified version of the http processor from puppet 5/6:

      require 'puppet'
      require 'puppet/network/http_pool'
      require 'uri'
       
      Puppet::Reports.register_report(:legacy) do
        def process
          url = URI.parse(Puppet[:reporturl])
          conn = Puppet::Network::HttpPool.http_instance(url.host, url.port, false)
          response = conn.post(url.path, self.to_yaml, { "Content-Type" => "application/x-yaml" })
          unless response.kind_of?(Net::HTTPSuccess)
            Puppet.err ("Unable to submit report to #{Puppet[:reporturl]} [#{response.code}] #{response.msg}")
          end
        end
      end
      

      Make sure puppetserver includes commit https://github.com/puppetlabs/puppetserver/commit/d6c07c9fae476cfd07502436fd397fa8ef60ac67 and the report processor is the jruby load-path.

      Configure puppet.conf with:

      [server]
      reports = legacy
      reporturl = http://localhost:8000/reports
      

      Start a simple http server on port 8000, like python -m SimpleHTTPServer

      Start puppetserver and run the agent, and the report processor will fail with:

      020-10-28 11:26:04,868 ERROR [qtp470539277-446] [puppetserver] Puppet Report processor failed: undefined method `code' for nil:NilClass
      /Users/josh/work/puppet/lib/puppet/reports/legacy.rb:35:in `process'
      /Users/josh/work/puppet/lib/puppet/indirector/report/processor.rb:37:in `block in process'
      /Users/josh/work/puppet/lib/puppet/indirector/report/processor.rb:54:in `block in processors'
      org/jruby/RubyArray.java:1809:in `each'
      /Users/josh/work/puppet/lib/puppet/indirector/report/processor.rb:51:in `processors'
      /Users/josh/work/puppet/lib/puppet/indirector/report/processor.rb:30:in `process'
      /Users/josh/work/puppet/lib/puppet/indirector/report/processor.rb:14:in `save'
      

      This is because Puppet::HTTP::Response#nethttp returns nil

      Attachments

        Activity

          People

            josh Josh Cooper
            josh Josh Cooper
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Zendesk Support