This testcase demonstrates how FileMapper provider instances will multiply. Noticebly when purging is in effect for a type.
- Use a CentOS VM because I haven't written a
target_files
implementation that works on other systems. - Use Sharpie/puppet-filemapper_cron@repro-purging and adrienthebo/puppet-filemapper@master.
- Install parslet:
gem install parslet
.
- Run
puppet apply cron-def.pp
to define two cron resources in the root crontab. - Run
puppet apply cron-purge.pp
which will manage one of the resources and purge the rest. Puppet will say it is purging the unmanaged resource, but the unmanaged resource remains and the managed resource duplicates.
For clues, drop a pry shell into def new
in filemapper.rb
and watch how many things get added to @all_providers
and what call stack leads to this.
diff --git a/lib/puppetx/filemapper.rb b/lib/puppetx/filemapper.rb
index f8d93c6..b1e7455 100644
--- a/lib/puppetx/filemapper.rb
+++ b/lib/puppetx/filemapper.rb
@@ -96,6 +96,7 @@ module PuppetX::FileMapper
# passed to self.flush_file
def new(*args)
obj = super
+ @all_providers.delete_if {|p| p.name == obj.name}
@all_providers << obj
obj
end