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

Bug #14652

Resource requiring self fails to apply but does not generate an error, even with --debug

Added by David Gwilliam almost 2 years ago. Updated 5 months ago.

Status:ClosedStart date:05/22/2012
Priority:NormalDue date:
Assignee:Andrew Parker% Done:

0%

Category:dependency graph
Target version:3.3.0
Affected Puppet version:2.7.12 Branch:https://github.com/puppetlabs/puppet/pull/1703
Keywords: customer

We've Moved!

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

This issue is currently not available for export. If you are experiencing the issue described below, please file a new ticket in JIRA. Once a new ticket has been created, please add a link to it that points back to this Redmine ticket.


Description

class test {
  file { '/tmp/file1.txt':
    ensure => present,
    require => File['/tmp/file1.txt'],
  }
  file { '/tmp/file2.txt':
    ensure => present,
    require => File['/tmp/file1.txt'],
  }
}

The above code generates an obvious cyclical dependency, but does not return an error on puppet agent -t --debug, though the following is seen:

debug: /Stage[main]/Test/File[/tmp/file1.txt]/require: requires File[/tmp/file1.txt]

Related issues

Duplicated by Puppet - Bug #20715: A resource requiring itself fails silently, no error or w... Duplicate
Duplicated by Puppet - Bug #20675: Bug/question: No error or warning for self-requiring reso... Duplicate
Duplicated by Puppet - Bug #20872: infinite dependency using spaceship operator silently suc... Duplicate
Duplicated by Puppet - Bug #21654: No cyclic error? Duplicate
Duplicated by Puppet - Bug #22224: Exec scheduled for refresh never runs Duplicate

History

#1 Updated by David Gwilliam almost 2 years ago

  • Description updated (diff)

#2 Updated by Nick Lewis almost 2 years ago

Looks like this was caused by the deterministic graph traversal work, which was what I suspected. Personally I’m of the mind that it probably ought to work, as it’s a vacuous dependency. There is a question of whether the semantics of “x requires y” are “run x only if y completes successfully” or “don’t run x if y doesn’t complete successfully”. The former means this is a failure, the latter allows it.

#3 Updated by Kelsey Hightower almost 2 years ago

  • Status changed from Unreviewed to Needs Decision

#4 Updated by Kelsey Hightower almost 2 years ago

Nick,

Can we kick off the discussion on how this should work?

#5 Updated by Charlie Sharpsteen about 1 year ago

  • Keywords set to customer

#7 Updated by Charlie Sharpsteen 11 months ago

  • Assignee set to Charlie Sharpsteen

#8 Updated by Charlie Sharpsteen 11 months ago

The current behavior is to silently ignore the resource. There are plenty of ways to unintentionally set this situation up, especially when using variables or other programmatic aspects of the Puppet language, we should at least throw a warning that these resources are being ignored.

#9 Updated by Charlie Sharpsteen 11 months ago

  • Assignee deleted (Charlie Sharpsteen)

#10 Updated by Andrew Parker 10 months ago

Here is a really simple example of this:

[13:56:42][Ruby(ruby-1.9.3-p194)][Git(master)] andy:puppet
> bundle exec puppet apply -e 'notify { "foo": require => Notify[foo] }'
Notice: Finished catalog run in 0.06 seconds
[13:56:47][Ruby(ruby-1.9.3-p194)][Git(master)] andy:puppet
> bundle exec puppet apply -e 'notify { "foo": require => Notify[bar] } notify { "bar": require => Notify[foo] }'
Error: Could not apply complete catalog: Found 1 dependency cycle:
(Notify[bar] => Notify[foo] => Notify[bar])
Try the '--graph' option and opening the resulting '.dot' file in OmniGraffle or GraphViz
Notice: Finished catalog run in 0.05 seconds

I would have expected that first puppet apply to either fail with a dependency cycle or to have executed the notify.

#11 Updated by eric sorenson 10 months ago

Based on the duplicate bugs, I’m inclined to think this should cause a cyclical dependency error. As Christian Flamm says in #20675, “Isn’t a resource that requires itself just the smallest possible dependency cycle?”

#12 Updated by eric sorenson 10 months ago

  • Status changed from Needs Decision to Accepted
  • Assignee set to Andrew Parker

#13 Updated by Josh Cooper 10 months ago

In 2.6.x, puppet would report this as an error:

err: Could not apply complete catalog: Found dependency cycles in the following relationships: File[/tmp/file1.txt] => File[/tmp/file1.txt]; try using the '--graph' option and open the '.dot' files in OmniGraffle or GraphViz

#14 Updated by Josh Cooper 10 months ago

  • Status changed from Accepted to Merged - Pending Release
  • Target version set to 3.3.0
  • Branch set to https://github.com/puppetlabs/puppet/pull/1703

Merged into master in d258e0605d

#15 Updated by lee hanel 10 months ago

  • Support Urls deleted (https://support.puppetlabs.com/tickets/1048)

Shouldn’t a dependency cycle failure cause an exit status other that zero?

this is running on master after the above branch was merged.

bundle exec puppet apply  --detailed-exitcodes -e 'notify { "foo": require => Notify[foo] }'
Warning: Could not retrieve fact fqdn
Error: Could not apply complete catalog: Found 1 dependency cycle:
(Notify[foo] => Notify[foo])
Try the '--graph' option and opening the resulting '.dot' file in OmniGraffle or GraphViz
Notice: Finished catalog run in 0.01 seconds
$ echo $?
0

#16 Updated by eric sorenson 10 months ago

  • Support Urls deleted (https://support.puppetlabs.com/tickets/1048)

Good catch Lee. This should probably not exit with zero, but that’s not specific to this bug. No dependency cycles exit with non-zero codes.

I’ll raise or find another issue about that.

#17 Updated by eric sorenson 10 months ago

Flagging for release notes — this is a fix for a regression in 2.7; we’re restoring 2.6-era behaviour, where self-referential dependencies are considered loops.

#18 Updated by Andrew Parker 5 months ago

  • Status changed from Merged - Pending Release to Closed

Released in 3.3.0

#19 Updated by Andrew Parker 5 months ago

Released in 3.3.0

Also available in: Atom PDF