Please review pull request #720: Fix for #14199: Mount resource don't recognize already mounted resources if there is a symlink in mountpoint path opened by (kupson)
Description:
If there is a symlink in mountpoint puppet don't recognize this resource
as already mounted and keeps remounting.
- Opened: Thu Apr 26 16:13:44 UTC 2012
- Based on: puppetlabs:master (df8db7c6b298fc02637f936b8b0609ee8ca2bb0a)
- Requested merge: kupson:master (487d782b7426ebc66d9e6aa44608de12eada0a49)
Diff follows:
diff --git a/lib/puppet/provider/mount/parsed.rb b/lib/puppet/provider/mount/parsed.rb
index 8d48dad..7542b40 100755
--- a/lib/puppet/provider/mount/parsed.rb
+++ b/lib/puppet/provider/mount/parsed.rb
@@ -40,9 +40,11 @@
record_line self.name, :fields => @fields, :separator => /\s+/, :joiner => "\t", :optional => optional_fields
# Every entry in fstab is :unmounted until we can prove different
+ # Add :realpath to entries with absolute pathnames
def self.prefetch_hook(target_records)
target_records.collect do |record|
record[:ensure] = :unmounted if record[:record_type] == :parsed
+ record[:realpath] = Pathname.new(record[:name]).realpath.to_s if record[:name] =~ /^\//
record
end
end
@@ -53,7 +55,7 @@ def self.instances
# Update fstab entries that are mounted
providers.each do |prov|
- if mounts.delete({:name => prov.get(:name), :mounted => :yes}) then
+ if mounts.delete({:name => prov.get(:realpath), :mounted => :yes}) then
prov.set(:ensure => :mounted)
end
end
@@ -69,13 +71,18 @@ def self.prefetch(resources = nil)
# Get providers for all resources the user defined and that match
# a record in /etc/fstab.
super
+ # Prepare resources hash indexed by realpath
+ res_by_realpath = Hash.new;
+ resources.each do |name,resource|
+ res_by_realpath[resource.provider.get(:realpath)] = resource
+ end
# We need to do two things now:
# - Update ensure from :unmounted to :mounted if the resource is mounted
# - Check for mounted devices that are not in fstab and
# set ensure to :ghost (if the user wants to add an entry
# to fstab we need to know if the device was mounted before)
mountinstances.each do |hash|
- if mount = resources[hash[:name]]
+ if mount = res_by_realpath[hash[:name]]
case mount.provider.get(:ensure)
when :absent # Mount not in fstab
mount.provider.set(:ensure => :ghost)
-- You received this message because you are subscribed to the Google Groups "Puppet Developers" 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-dev?hl=en.
