Jira (PUP-7582) Make attempt to export or virtualize a class an error

23 views
Skip to first unread message

Henrik Lindberg (JIRA)

unread,
May 22, 2017, 9:01:05 AM5/22/17
to puppe...@googlegroups.com
Henrik Lindberg created an issue
 
Puppet / Bug PUP-7582
Make attempt to export or virtualize a class an error
Issue Type: Bug Bug
Assignee: Unassigned
Created: 2017/05/22 6:00 AM
Priority: Normal Normal
Reporter: Henrik Lindberg

Currently (under to control of --strict), it is a warning or an error to attempt to use @class or @@class in a resource expression or a create_resources call.

Now in Puppet 6.0.0 this should always be an error.

Note the configuration for this is done twice, once for the static validation, and once for the runtime. The checker4_0 has the static validation logic, and the runtime check is in the `create_resources`. See PUP-1606 where the warnings were added.

Add Comment Add Comment
 
This message was sent by Atlassian JIRA (v6.4.14#64029-sha1:ae256fe)
Atlassian logo

Henrik Lindberg (JIRA)

unread,
May 22, 2017, 9:01:08 AM5/22/17
to puppe...@googlegroups.com

Geoff Nichols (JIRA)

unread,
May 25, 2017, 1:07:03 PM5/25/17
to puppe...@googlegroups.com

Craig Gomes (JIRA)

unread,
Mar 19, 2018, 5:35:03 PM3/19/18
to puppe...@googlegroups.com
Craig Gomes updated an issue
Change By: Craig Gomes
Sub-team: Coremunity
This message was sent by Atlassian JIRA (v7.7.1#77002-sha1:e75ca93)
Atlassian logo

Craig Gomes (JIRA)

unread,
Mar 19, 2018, 5:35:03 PM3/19/18
to puppe...@googlegroups.com
Craig Gomes updated an issue
Change By: Craig Gomes
Sub-team: Language Coremunity

Josh Cooper (JIRA)

unread,
Mar 19, 2018, 5:35:07 PM3/19/18
to puppe...@googlegroups.com

Eric Sorenson (JIRA)

unread,
Mar 19, 2018, 5:36:03 PM3/19/18
to puppe...@googlegroups.com
Eric Sorenson commented on Bug PUP-7582
 
Re: Make attempt to export or virtualize a class an error

What is the downside of continuing the behavior as it is?

Do people do this in the world right now, and if so, what problem are they trying to solve?

Josh Cooper (JIRA)

unread,
Mar 19, 2018, 6:10:04 PM3/19/18
to puppe...@googlegroups.com

Henrik Lindberg (JIRA)

unread,
Mar 20, 2018, 7:32:04 AM3/20/18
to puppe...@googlegroups.com
Henrik Lindberg commented on Bug PUP-7582
 
Re: Make attempt to export or virtualize a class an error

Eric Sorenson See PUP-1606 for why people try to use this. The current behaviour is that the @ or @@ is ignored when combined with class declaration via resource expression - it has been ignored since puppet 2.7.0. In PUP-1606 we made it a warning/error under the control of --strict to make it clear that it simply does not work.

The impact if this is now always an error is that users that have @ or @@ in combination with class would need to remove the at-chars as they would always get an error for such a construct.

There is not a big downside to keeping this under control of --strict, if someone publishes code that contains this and someone else runs with --strict=error they would see the issue and could prompt to get it fixed. At the same time, I don't think this is really used in the wild simply because it has had no effect since puppet 2.6.

Josh Cooper (JIRA)

unread,
Jul 19, 2018, 6:09:02 PM7/19/18
to puppe...@googlegroups.com

Josh Cooper (JIRA)

unread,
Aug 3, 2018, 1:58:03 PM8/3/18
to puppe...@googlegroups.com

Henrik Lindberg (JIRA)

unread,
Aug 15, 2018, 5:29:03 PM8/15/18
to puppe...@googlegroups.com

Josh Cooper There was no decision. I think we should make it a hard non configurable error.

Eric Sorenson (JIRA)

unread,
Aug 29, 2018, 3:20:03 PM8/29/18
to puppe...@googlegroups.com
Eric Sorenson commented on Bug PUP-7582

I think we're out of time on this one and it seems very low risk to leave it. I'm just gonna close/wontfix.

Henrik Lindberg (JIRA)

unread,
Aug 29, 2018, 8:12:03 PM8/29/18
to puppe...@googlegroups.com

Eric Sorenson If you wanted this, but thought it would be complicated... it is a very simple change. (A "won't fix" is fine too, just wanted to let you know it is not hard to change since it is already configurable).

Henrik Lindberg (JIRA)

unread,
Sep 9, 2018, 11:39:04 AM9/9/18
to puppe...@googlegroups.com
Henrik Lindberg updated an issue
 
Change By: Henrik Lindberg
Fix Version/s: PUP 6.0.0
Fix Version/s: PUP 7.0.0

Henrik Lindberg (JIRA)

unread,
Sep 9, 2018, 11:40:01 AM9/9/18
to puppe...@googlegroups.com
 
Re: Make attempt to export or virtualize a class an error

Moved this to 7.0.0 removals (it is still wrong and should be fixed).

Jorie Tappa (JIRA)

unread,
Jan 27, 2020, 5:47:04 PM1/27/20
to puppe...@googlegroups.com
Jorie Tappa updated an issue
 
Change By: Jorie Tappa
Currently (under to control of --strict), it is a warning or an error to attempt to use {{@class}} or {{@@class}} in a resource expression or a {{create_resources}} call.

Now in In Puppet 6 7 .0.0 this should always be an error.


Note the configuration for this is done twice, once for the static validation, and once for the runtime. The checker4_0 has the static validation logic, and the runtime check is in the `create_resources`. See PUP-1606 where the warnings were added.

Melissa Stone (Jira)

unread,
Apr 29, 2020, 4:39:03 PM4/29/20
to puppe...@googlegroups.com
Melissa Stone commented on Bug PUP-7582
 
Re: Make attempt to export or virtualize a class an error

Hey Ben Ford! Question for you on this one. It looks like we do support virtualized classes in a sense in puppet. Josh Cooper and I are trying to figure out the best path forward on this.

Currently, following the example in the description of PUP-1606, I can get the virtual class to notify successfully. It only errors out when I include `--strict=error`.

```
➜ puppet git:(master) ✗ cat iclass.pp
class vclass {
notify

{"vclass": message => "I've been realized" }

}

class iclass {
@class

{"vclass": }

}

class

{"iclass":}

➜ puppet git:(master) ✗ be ./bin/puppet apply --debug iclass.pp
Debug: Runtime environment: puppet_version=6.16.0, ruby_version=2.3.8, run_mode=user, default_encoding=UTF-8
Debug: Loading external facts from /Users/melissa/.puppetlabs/opt/puppet/cache/facts.d
Debug: Facter: Found no suitable resolves of 1 for ec2_metadata
.
.
.
Debug: Facter: value for filesystems is still nil
Debug: Facter: value for ipaddress6 is still nil
Debug: Reset text domain to :production
Warning: Classes are not virtualizable (file: /Users/melissa/workdir/puppet/iclass.pp, line: 8, column: 3)
Notice: Compiled catalog for pyewacket.vpn.puppet.net in environment production in 0.04 seconds
Debug: Creating default schedules
Debug: Loaded state in 0.00 seconds
Debug: Loaded state in 0.00 seconds
Info: Applying configuration version '1588192102'
Notice: I've been realized
Notice: /Notify[vclass]/message: defined 'message' as 'I\'ve been realized'
Debug: Finishing transaction 70323370342720
Debug: Storing state
Debug: Pruned old state cache entries in 0.00 seconds
Debug: Stored state in 0.00 seconds
Notice: Applied catalog in 0.01 seconds
Debug: Applying settings catalog for sections reporting, metrics
Debug: Finishing transaction 70323644029760
Debug: Received report to process from pyewacket.vpn.puppet.net
Debug: Processing report from pyewacket.vpn.puppet.net with processor Puppet::Reports::Store

➜ puppet git:(master) ✗ be ./bin/puppet apply --debug iclass.pp --strict error
Debug: Runtime environment: puppet_version=6.16.0, ruby_version=2.3.8, run_mode=user, default_encoding=UTF-8
Debug: Loading external facts from /Users/melissa/.puppetlabs/opt/puppet/cache/facts.d
.
.
.
Debug: Facter: value for ipaddress6 is still nil
Debug: Reset text domain to :production
Error: Could not parse for environment production: Classes are not virtualizable (file: /Users/melissa/workdir/puppet/iclass.pp, line: 8, column: 3) on node pyewacket.vpn.puppet.net
```

Circling back to Eric's question, what's the benefit of removing this? How many people might this break? The warning was introduced in 4.10.2, so that's good if we do decide to make puppet fail if the user is trying to use a virtualized class.

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

Melissa Stone (Jira)

unread,
Apr 29, 2020, 4:44:02 PM4/29/20
to puppe...@googlegroups.com

Melissa Stone (Jira)

unread,
Apr 29, 2020, 4:44:02 PM4/29/20
to puppe...@googlegroups.com

Josh Cooper (Jira)

unread,
Jul 21, 2020, 12:49:02 PM7/21/20
to puppe...@googlegroups.com
Josh Cooper updated an issue
Change By: Josh Cooper
Epic Link: PUP- 9120 10591

Charlie Sharpsteen (Jira)

unread,
Sep 22, 2020, 11:15:04 AM9/22/20
to puppe...@googlegroups.com
Charlie Sharpsteen commented on Bug PUP-7582
 
Re: Make attempt to export or virtualize a class an error

I've never seen this done in the wild, but also haven't been specifically looking for things like it. Sounds like there has been a deprecation warning since 4.10, so I'd say go ahead and change the behavior in 7 if this is something we want to clean up.

 

We could always flip it back in 7.0.1 if it turns out to break $really_important_use_case that noone has mentioned in 3 years.

Reid Vandewiele (Jira)

unread,
Sep 23, 2020, 1:58:04 PM9/23/20
to puppe...@googlegroups.com

I think we should make it a hard error. The point of the ticket is that when you put a "@" in front of class today, it silently doesn't do what you probably thought it was doing, and that's confusing.

If we make it a hard error there could be some code, somewhere, that a user would then need to remove an "@" sign from. I've never seen a user try to do this intentionally. Removing the "@" sign would have no functional change on what their code does anyway, and at first blush I believe it's safe to fix non-clever code with something close to as simple as find . -name '*.pp' | xargs sed -i 's/@class {/class {/'.

An error is better than not actually doing what the syntax lets you think you're doing.

Ben Ford (Jira)

unread,
Sep 24, 2020, 12:22:04 PM9/24/20
to puppe...@googlegroups.com
Ben Ford commented on Bug PUP-7582

I said this in slack some time ago, but I should record it on the ticket. Kill it dead. The more hidden "actually, it's not doing what you think you're doing" gotchas we can eliminate, the better.

Josh Cooper (Jira)

unread,
Sep 28, 2020, 2:37:03 PM9/28/20
to puppe...@googlegroups.com
Josh Cooper commented on Bug PUP-7582

Check to see if puppet parser validate can warn on all cases where this occurs, not just the first one.

Josh Cooper (Jira)

unread,
Sep 28, 2020, 2:50:04 PM9/28/20
to puppe...@googlegroups.com
Josh Cooper commented on Bug PUP-7582

Puppet currently warns on all instances of virtual classes with file and line numbers, so I think it's fairly easy to correct this problem in manifests prior to upgrading:

$ bx puppet apply iclass.pp
Warning: Classes are not virtualizable (file: /Users/josh/work/puppet/iclass.pp, line: 14, column: 3)
Warning: Classes are not virtualizable (file: /Users/josh/work/puppet/iclass.pp, line: 15, column: 3)
Notice: Compiled catalog for localhost in environment production in 0.09 seconds
Notice: I've been realized
Notice: /Notify[vclass]/message: defined 'message' as 'I\'ve been realized'
Notice: I've been realized
Notice: /Notify[vclass2]/message: defined 'message' as 'I\'ve been realized'
Notice: Applied catalog in 0.01 seconds
$ bx puppet parser validate iclass.pp
Warning: Classes are not virtualizable (file: /Users/josh/work/puppet/iclass.pp, line: 14, column: 3)
Warning: Classes are not virtualizable (file: /Users/josh/work/puppet/iclass.pp, line: 15, column: 3)

Josh Cooper (Jira)

unread,
Sep 29, 2020, 2:48:05 PM9/29/20
to puppe...@googlegroups.com

Josh Cooper (Jira)

unread,
Sep 29, 2020, 2:48:05 PM9/29/20
to puppe...@googlegroups.com
Josh Cooper updated an issue
Change By: Josh Cooper
Sprint: Platform Core KANBAN

Gabriel Nagy (Jira)

unread,
Oct 6, 2020, 9:36:03 AM10/6/20
to puppe...@googlegroups.com

Josh Cooper (Jira)

unread,
Oct 6, 2020, 11:35:04 AM10/6/20
to puppe...@googlegroups.com
Josh Cooper updated an issue
Change By: Josh Cooper
Release Notes: Bug Fix
Release Notes Summary: Previously puppet would warn or error if it encountered a virtual
class (indicated by @class) or an exported class (indicated by @@class)
based on the Puppet[:strict] setting. By default, puppet would warn, yet
include resources from the virtual class in the catalog. This commit makes puppet always error on virtual and exported classes.

Josh Cooper (Jira)

unread,
Oct 8, 2020, 6:07:03 PM10/8/20
to puppe...@googlegroups.com

Claire Cadman (Jira)

unread,
Nov 10, 2020, 5:42:03 AM11/10/20
to puppe...@googlegroups.com
Claire Cadman updated an issue
 
Change By: Claire Cadman
Labels: doc_reviewed platform_7
Reply all
Reply to author
Forward
0 new messages