Issue #14518 has been updated by Josh Cooper.
Subject changed from Registry - Autorequire can create circular dependencies
when ensure => absent to Autorequire can create circular dependencies when
ensure => absent
Assignee deleted (Josh Cooper)
Affected Puppet version set to 2.7.14
Keywords changed from registry autorequire to autorequire circular dependencies
This turns out to not be a registry issue, it's a general issue with
autorequiring and the `->` syntax. It is likely a duplicate of another issue...
This manifest attempts to delete two child directories, then the parent
directory. It doesn't actually delete them, because `force` is not set, but it
illustrates that puppet does attempt to delete them in the right order:
<pre>
File { ensure => absent }
file { '/tmp/a': }
file { '/tmp/a/b1': }
-> File['/tmp/a']
file { '/tmp/a/b2': }
-> File['/tmp/a']
</pre>
Results in:
<pre>
debug: /Stage[main]//File[/tmp/a/b2]/before: requires File[/tmp/a]
debug: /Stage[main]//File[/tmp/a/b1]/before: requires File[/tmp/a]
debug: /Stage[main]//File[/tmp/a/b2]: Skipping automatic relationship with
File[/tmp/a]
debug: /Stage[main]//File[/tmp/a/b1]: Skipping automatic relationship with
File[/tmp/a]
notice: /Stage[main]//File[/tmp/a/b1]: Not removing directory; use 'force' to
override
notice: /Stage[main]//File[/tmp/a/b1]/ensure: removed
notice: /Stage[main]//File[/tmp/a/b2]: Not removing directory; use 'force' to
override
notice: /Stage[main]//File[/tmp/a/b2]/ensure: removed
notice: /Stage[main]//File[/tmp/a]: Not removing directory; use 'force' to
override
notice: /Stage[main]//File[/tmp/a]/ensure: removed
</pre>
However, if the dependencies are expressed as follows (delete b1, b2, then the
parent):
<pre>
File { ensure => absent }
file { '/tmp/a/b1': }
-> file { '/tmp/a/b2': }
-> file { '/tmp/a': }
</pre>
It creates a circular dependency:
<pre>
debug: /Stage[main]//File[/tmp/a/b1]/before: requires File[/tmp/a/b2]
debug: /Stage[main]//File[/tmp/a/b2]/before: requires File[/tmp/a]
debug: /Stage[main]//File[/tmp/a/b1]: Autorequiring File[/tmp/a]
debug: /Stage[main]//File[/tmp/a/b2]: Skipping automatic relationship with
File[/tmp/a]
err: Could not apply complete catalog: Found 1 dependency cycle:
(File[/tmp/a/b1] => File[/tmp/a/b2] => File[/tmp/a] => File[/tmp/a/b1])
</pre>
The circular dependency occurs because `/tmp/a/b1` should not have autorequired
`/tmp/a`
On a general note, autorequiring generates dependency edges in the `ensure =>
present` direction. I'm thinking puppet should always ignore autorequiring when
`ensure => absent`, or it should flip the dependency direction. For example,
for files, it would ensure the child file/dir is deleted before its parent.
I think flipping the direction is preferrable. The file type autorequire
already generates the correct dependency for both present and absent, it's just
the wrong direction for absent. Also, it's strange that manifest authors have
to define dependency edges in the `ensure => absent` case, but not `ensure =>
present`. For example, it would be nice to be able to do:
<pre>
File { ensure => absent }
file { '/tmp/a/b1': }
file { '/tmp/a/b2': }
file { '/tmp/a': }
</pre>
And have puppet do the right thing. But it doesn't, since the autorequired
dependencies are backwards:
<pre>
debug: /Stage[main]//File[/tmp/a/b2]: Autorequiring File[/tmp/a]
debug: /Stage[main]//File[/tmp/a/b1]: Autorequiring File[/tmp/a]
notice: /Stage[main]//File[/tmp/a]: Not removing directory; use 'force' to
override
notice: /Stage[main]//File[/tmp/a]/ensure: removed
notice: /Stage[main]//File[/tmp/a/b1]: Not removing directory; use 'force' to
override
notice: /Stage[main]//File[/tmp/a/b1]/ensure: removed
notice: /Stage[main]//File[/tmp/a/b2]: Not removing directory; use 'force' to
override
notice: /Stage[main]//File[/tmp/a/b2]/ensure: removed
</pre>
----------------------------------------
Bug #14518: Autorequire can create circular dependencies when ensure => absent
https://projects.puppetlabs.com/issues/14518#change-62979
Author: Josh Cooper
Status: Accepted
Priority: Normal
Assignee:
Category:
Target version:
Affected Puppet version: 2.7.14
Keywords: autorequire circular dependencies
Branch:
The `registry_key` auto-require functionality doesn't appear to work with `->`
style relationships when `ensure => absent`. This results in a circular
dependency:
<pre>
Registry_key { ensure => absent }
registry_key { '#{keypath}\\SubKey1': }
-> registry_key { '#{keypath}\\SubKeyToPurge': }
-> registry_key { '#{keypath}': }
</pre>
But this does not:
<pre>
registry_key { '#{keypath}\\SubKey1': }
registry_key { '#{keypath}\\SubKeyToPurge': }
registry_key { '#{keypath}':
require => Registry_key['#{keypath}\\SubKeyToPurge',
'#{keypath}\\SubKey1'],
}
</pre>
--
You have received this notification because you have either subscribed to it,
or are involved in it.
To change your notification preferences, please click here:
http://projects.puppetlabs.com/my/account
--
You received this message because you are subscribed to the Google Groups
"Puppet Bugs" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/puppet-bugs?hl=en.