The Puppet Labs Issue Tracker has Moved: https://tickets.puppetlabs.com

Bug #1372

Class names that match the node name are not evaluated

Added by Digant Kasundra almost 6 years ago. Updated 3 months ago.

Status:InvestigatingStart date:06/16/2008
Priority:NormalDue date:
Assignee:Lee Lowder% Done:

0%

Category:language
Target version:-
Affected Puppet version:0.24.4 Branch:
Keywords:devtriage

We've Moved!

Ticket tracking is now hosted in JIRA: https://tickets.puppetlabs.com

This ticket is now tracked at: https://tickets.puppetlabs.com/browse/PUP-1357


Description

If I setup:

class subversion { warning(“I am class subversion”) }

and in my nodes.pp I have

node subversion { include subversion }

When i run puppet in verbose mode on subversion, I never see that warning.


Related issues

Related to Puppet - Bug #17687: Variables not accessible if classname is same as node name Investigating
Related to Puppet - Bug #2053: Relative namespacing of class/define names results in big... Accepted 03/06/2009
Duplicated by Puppet - Bug #18553: When name of module is same as nodes name configuration w... Duplicate

History

#1 Updated by AJ Christensen almost 6 years ago

  • Category set to language
  • Status changed from Unreviewed to Needs More Information
  • Assignee set to Luke Kanies

I can reproduce this with the current 0.24.x HEAD:

aj@junglist /tmp$ cat test.pp
#!/usr/bin/env puppet

class junglist {
  notify { "I am class junglist": }
}

node junglist {
  include junglist
}
aj@junglist /tmp$ ./test.pp --debug
debug: Creating default schedules
debug: Finishing transaction -609513118 with 0 changes

Luke, can you please clarify if this is desired behaviour? Should we at least be throwing a top-level duplicate class error?

#2 Updated by Luke Kanies almost 6 years ago

  • Status changed from Needs More Information to Accepted

There should actually be an exception there, I’m pretty sure. I know my intention was that this throw an exception, because I haven’t been all that careful to make sure naming collisions don’t cause problems, so I knew an exception was important.

Probably the right move, at this point, is to make the ASTSet in parser/parser_support.rb into a class, which can then do validation as nodes et al are added.

#3 Updated by Digant Kasundra almost 6 years ago

Some thoughts on this…

I think it shouldn’t be an exception. I know eventually, this is probably solved by an external node tool, but as it stands now, we often have classes that have the same name as nodes and I’d really hate to rename classes/modules to something else just to avoid that name collision. Isn’t there any other way to handle this such that a node is a node and can be the same name as a class? I know the direction that was discussed was to eventuall treat nodes as classes (or perhaps that’s what’s happening now), but this is somewhat limiting.

#4 Updated by Luke Kanies over 5 years ago

  • Target version set to 0.24.6

I think this is actually going to be straightforward, so I’m going to try to fit it into 0.24.6.

#5 Updated by Luke Kanies over 5 years ago

The problem here is that I’ve got a single @class_scope hash for the entire compile, and it stores both node and class scopes, with no typing (i.e., the node and class scopes aren’t separated in any way).

This looks pretty unnecessary, so it should be straightforward to just add a node_scope hash to go with the class_scope hash.

#6 Updated by Luke Kanies over 5 years ago

  • Target version changed from 0.24.6 to 4

This is harder than I thought, so I’m bumping it.

#7 Updated by Luke Kanies almost 4 years ago

  • Assignee changed from Luke Kanies to Markus Roberts
  • Target version changed from 4 to 2.7.x

#8 Updated by Joshua Lifton over 2 years ago

  • Assignee deleted (Markus Roberts)

This issue was assigned to a former Puppet Labs employee. Adding back to the pool of unreviewed issues.

#9 Updated by Joshua Lifton over 2 years ago

This issue was assigned to a former Puppet Labs employee. Adding back to the pool of unreviewed issues.

#10 Updated by Ben Hughes about 2 years ago

  • Description updated (diff)
  • Status changed from Accepted to Unreviewed

#11 Updated by Michael Stahnke about 2 years ago

  • Description updated (diff)
  • Status changed from Unreviewed to Accepted
  • Keywords set to devtriage
[root@centos tests]# cat test.pp 
class centos {
notice ("Class centos")
}
node centos {
include centos
notice ("Node centos")
}
[root@centos tests]# !pup
puppet apply --verbose test.pp 
dnsdomainname: Unknown host
notice: Scope(Node[centos]): Node centos
info: Applying configuration version '1327167310'
notice: Finished catalog run in 0.02 seconds
[root@centos tests]# 

Still an issue in 2.7.9.

#12 Updated by Lee Lowder over 1 year ago

$ cat bugtest.pp class puppet-tn { notice (“Class puppet-tn”) }

node puppet-tn { include puppet-tn notice (“Node puppet-tn”) }

@puppet-tn:~$ puppet apply —verbose bugtest.pp notice: Scope(Node[puppet-tn]): Node puppet-tn info: Applying configuration version ‘1353014165’ notice: Finished catalog run in 0.03 seconds

This was done on 2.7.19

#13 Updated by Lee Lowder over 1 year ago

Another update. It seems if you use parameter syntax it works as expected (includes the class).

$ cat bugtest.pp
class puppet-tn {
  notice ("Class puppet-tn")
}
node /puppet-tn/ {
  class { 'puppet-tn': }
  notice ("Node puppet-tn")
}

user@puppet-tn:~$ puppet apply --verbose bugtest.pp
notice: Scope(Node[puppet-tn]): Node puppet-tn
notice: Scope(Class[Puppet-tn]): Class puppet-tn
info: Applying configuration version '1353015627'
notice: Finished catalog run in 0.04 seconds

#14 Updated by Lee Lowder over 1 year ago

In addition to using param style syntax as a workaround, a properly constructed regex will work.

llowder@ubuntu:~$ cat bugtest.pp
class ubuntu {
  $foo = "bar"
  notice ("Class ubuntu")
}
node /ubunt./ {
  #class { 'ubuntu': }
  include ::ubuntu
  notice ("Node ubuntu")
  notice ("class::ubuntu::foo is ${ubuntu::foo}")
}
#class { 'ubuntu': }

llowder@ubuntu:~$ puppet apply --verbose bugtest.pp
notice: Scope(Class[Ubuntu]): Class ubuntu
notice: Scope(Node[ubunt.]): Node ubuntu
notice: Scope(Node[ubunt.]): class::ubuntu::foo is bar
info: Applying configuration version '1353019533'
notice: Finished catalog run in 0.02 seconds

One thing to notice, that using a regex of /ubuntu/ results in the class not loading:

llowder@ubuntu:~$ cat bugtest.pp
class ubuntu {
  $foo = "bar"
  notice ("Class ubuntu")
}
node /ubuntu/ {
  #class { 'ubuntu': }
  include ::ubuntu
  notice ("Node ubuntu")
  notice ("class::ubuntu::foo is ${ubuntu::foo}")
}
#class { 'ubuntu': }

llowder@ubuntu:~$ puppet apply --verbose bugtest.pp
notice: Scope(Node[ubuntu]): Node ubuntu
notice: Scope(Node[ubuntu]): class::ubuntu::foo is
info: Applying configuration version '1353019657'
notice: Finished catalog run in 0.01 seconds

#15 Updated by Lee Lowder over 1 year ago

I have created a series of tests that demonstrate the current behavior, and will help explore the edges of this bug.

They can be found at: https://github.com/llowder/puppet/blob/1372_data_gathering/spec/integration/parser/node_class_same_spec.rb

It is a work in progress and still being worked on.

#16 Updated by Jeff Weiss over 1 year ago

  • Status changed from Accepted to Investigating
  • Assignee set to Lee Lowder

#17 Updated by Andrew Parker over 1 year ago

  • Target version deleted (2.7.x)

#18 Updated by Anonymous 3 months ago

Redmine Issue #1372 has been migrated to JIRA:

https://tickets.puppetlabs.com/browse/PUP-1357

Also available in: Atom PDF