summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorluke <luke@980ebf18-57e1-0310-9a29-db15c13687c0>2007-01-30 19:07:18 +0000
committerluke <luke@980ebf18-57e1-0310-9a29-db15c13687c0>2007-01-30 19:07:18 +0000
commit8821300528e0e0ba4c4f0055911d263ae0b0133b (patch)
tree4aa2762281be772e5bce3ef39cbdabaadf39c778
parent0a62369718e3299990ef36ad657e22f7032446c9 (diff)
downloadpuppet-8821300528e0e0ba4c4f0055911d263ae0b0133b.tar.gz
puppet-8821300528e0e0ba4c4f0055911d263ae0b0133b.tar.xz
puppet-8821300528e0e0ba4c4f0055911d263ae0b0133b.zip
Providing a partial fix for #428. Resources can now be deleted as long as all of their dependencies are also being deleted. This, combined with the fix to #433, means that you can now explicitly specify the order of deletion, and everything will work as long as all required objects are being removed, too.
git-svn-id: https://reductivelabs.com/svn/puppet/trunk@2129 980ebf18-57e1-0310-9a29-db15c13687c0
-rw-r--r--lib/puppet/transaction.rb5
-rwxr-xr-xtest/other/transactions.rb12
2 files changed, 13 insertions, 4 deletions
diff --git a/lib/puppet/transaction.rb b/lib/puppet/transaction.rb
index 42935a377..347d94432 100644
--- a/lib/puppet/transaction.rb
+++ b/lib/puppet/transaction.rb
@@ -56,9 +56,10 @@ class Transaction
changes = [changes] unless changes.is_a?(Array)
# If a resource is going to be deleted but it still has dependencies, then
- # don't delete it unless it's implicit.
+ # don't delete it unless it's implicit or the dependency is itself being
+ # deleted.
if ! resource.implicit? and resource.deleting?
- if deps = @relgraph.dependents(resource) and ! deps.empty?
+ if deps = @relgraph.dependents(resource) and ! deps.empty? and deps.detect { |d| ! d.deleting? }
resource.warning "%s still depend%s on me -- not deleting" %
[deps.collect { |r| r.ref }.join(","), if deps.length > 1; ""; else "s"; end]
return []
diff --git a/test/other/transactions.rb b/test/other/transactions.rb
index 866c5551d..6901abe73 100755
--- a/test/other/transactions.rb
+++ b/test/other/transactions.rb
@@ -742,8 +742,8 @@ class TestTransactions < Test::Unit::TestCase
assert(trans.tagged?(res), "tags should have matched")
end
- # We don't want to purge resources that have relationships with other resources,
- # so we want our transactions to check for that.
+ # We don't want to purge resources that have relationships with other
+ # resources, so we want our transactions to check for that.
def test_required_resources_not_deleted
@file = Puppet::Type.type(:file)
path1 = tempfile()
@@ -760,6 +760,14 @@ class TestTransactions < Test::Unit::TestCase
assert_apply(file1, file2)
assert(FileTest.exists?(path1), "required file was deleted")
+
+ # However, we *do* want to allow deletion of resources of their dependency
+ # is also being deleted
+ file2[:ensure] = :absent
+
+ assert_apply(file1, file2)
+
+ assert(! FileTest.exists?(path1), "dependency blocked deletion even when it was itself being deleted")
end
# Make sure changes generated by eval_generated resources have proxies