Jira (PUP-10863) Invalid parser function breaks catalog compilation in all environments

12 views
Skip to first unread message

Matt Fields (Jira)

unread,
Jan 29, 2021, 5:10:02 PM1/29/21
to puppe...@googlegroups.com
Matt Fields created an issue
 
Puppet / Bug PUP-10863
Invalid parser function breaks catalog compilation in all environments
Issue Type: Bug Bug
Affects Versions: PUP 6.15.0
Assignee: Unassigned
Components: Compiler
Created: 2021/01/29 2:09 PM
Priority: Normal Normal
Reporter: Matt Fields

Puppet Version: 6.20.0
Puppet Server Version: 6.15.0
OS Name/Version: CentOS Linux 7.9

Crafting a parser function file in a particular way causes most future catalog compilations to fail across all environments after the function is executed once, until puppetserver is restarted. 

 

To reproduce, create a file in lib/puppet/parser/functions/bork.rb with the following contents:

module Puppet
  module Parser
    module Functions
      newfunction(
        :bork,
        type: :rvalue,
        doc: 'B0rks the puppetserver'
      ) do |args|
        return true
      end
    end
  end
end

Then have an agent manifest call the `bork()` function. 

 

Observe most future puppet runs fail, even for other nodes in other environments that previously worked before.  

 

The error frequently seen is:

Error 500 on SERVER: Server Error: Evaluation Error: Error while evaluating a Function Call, undefined method `[]' for Puppet::Pops::Loader::RubyLegacyFunctionInstantiator::Puppet:Module

Desired Behavior:

Catalog fails for the invalid parser function, and other catalogs work fine. 

Actual Behavior:

Most future catalog compilations fail, even for unrelated nodes in other environments that previously worked before the `bork()` function was called.

 

The following simple catalog is known to fail, where it previous works:

include stdlib

$test = pick($puppetmaster, $::fqdn)

Add Comment Add Comment
 
This message was sent by Atlassian Jira (v8.5.2#805002-sha1:a66f935)
Atlassian logo

Gheorghe Popescu (Jira)

unread,
Feb 2, 2021, 4:54:03 AM2/2/21
to puppe...@googlegroups.com
Gheorghe Popescu commented on Bug PUP-10863
 
Re: Invalid parser function breaks catalog compilation in all environments

Matt Fields Can you provide more information about which setup worked before?(puppet-agent and puppetserver versions)

Mihai Buzgau (Jira)

unread,
Feb 2, 2021, 10:46:04 AM2/2/21
to puppe...@googlegroups.com

Matt Fields (Jira)

unread,
Feb 2, 2021, 10:58:03 AM2/2/21
to puppe...@googlegroups.com
Matt Fields commented on Bug PUP-10863
 
Re: Invalid parser function breaks catalog compilation in all environments

We do not encounter the issue on our `5.3.16` puppetserver.

Agent version doesn't seem to matter, we have a mix of agents in our environment and only the server version appears to affect anything. 

Henrik Lindberg (Jira)

unread,
Feb 4, 2021, 5:15:04 AM2/4/21
to puppe...@googlegroups.com

It is probably going wrong in the logic that validates the old 3x functions when they are loaded. The borked function in question is overly verbose and uses constructs that the validation parsing was not designed to handle.

If the "borked" was written on the form shown below, it should load (did not try though).

 

module Puppet::Parser::Functions
newfunction(
:bork,
:type => :rvalue,
:doc => 'B0rks the puppetserver'


) do |args|
return true
end
end

{ruby}

I realize that the issue is really "loading completely borked function implementation should not have effect on subsequent compilations where the borked function is unused" - and not "I cannot load this function".

As a side note - In general the recommendation is to not use the legacy (3.x) style for function implementations. Also note that it is close to impossible to ward off all possible cases of "loading bad logic in Ruby" due to Ruby's super flexible nature. The 3.x function loading is susceptible to a wider range of mistakes than the 4.x API and that is why the Ruby source is parsed and analyzed before being passed on to actually loading it. The 3.x API was invented long before the Ruby syntax was invented that is used in the borked function, so here is also a question about how much energy should be spent on fixing modern style mistakes made in this antique context. - - - In other words - fix the borked function.

Matt Fields (Jira)

unread,
Feb 4, 2021, 11:56:03 AM2/4/21
to puppe...@googlegroups.com
Matt Fields commented on Bug PUP-10863

If it was an issue in the Puppet 5 server as well, I'd just write it off as a quirk of Puppet; however, this is something that affects Puppet 6 and not Puppet 5, so it seems like a bug that should be fixed to me. If it just affected the environment the bad code was executed in, then "fix your code" is acceptable, but since it affects everything on the server until it is restarted, I feel that this should be fixed in the server process. 

Reply all
Reply to author
Forward
0 new messages