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

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

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Normal
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: PUP 7.0.0
    • Component/s: None
    • Labels:
    • Template:
      PUP Bug Template
    • Team:
      Coremunity
    • Sprint:
      Platform Core KANBAN
    • Method Found:
      Needs Assessment
    • Release Notes:
      Not Needed
    • Release Notes Summary:
      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.
    • QA Risk Assessment:
      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

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

              Dates

              Created:
              Updated:
              Resolved:

                Zendesk Support