Gavin Williams
2013-Apr-05 07:57 UTC
[Puppet Users] Flush provider - Differentiating between new resource and modification?
Morning all I''m working on converting some of my NetApp providers to prefetch/flush style to try and optimize performance. I''ve hit an issue on my Netapp_user provider, around handling resource creation versus resource modification? What''s the easiest way to differentiate? Current code is here: https://github.com/fatmcgav/fatmcgav-netapp/commit/66092978f4182c5474a60011db99ee2e3e12e689 Any tips appreciated. Regards Gavin -- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to puppet-users+unsubscribe@googlegroups.com. To post to this group, send email to puppet-users@googlegroups.com. Visit this group at http://groups.google.com/group/puppet-users?hl=en. For more options, visit https://groups.google.com/groups/opt_out.
Stefan Schulte
2013-Apr-06 22:22 UTC
Re: [Puppet Users] Flush provider - Differentiating between new resource and modification?
On Fri, 5 Apr 2013 00:57:32 -0700 (PDT) Gavin Williams <fatmcgav@gmail.com> wrote:> Morning all > > I''m working on converting some of my NetApp providers to > prefetch/flush style to try and optimize performance. > > I''ve hit an issue on my Netapp_user provider, around handling > resource creation versus resource modification? > What''s the easiest way to differentiate? > > Current code is here: > https://github.com/fatmcgav/fatmcgav-netapp/commit/66092978f4182c5474a60011db99ee2e3e12e689 > > Any tips appreciated. > > Regards > Gavin >There is no way to check *why* the flush method was called, you just now that at least one property has been updated. You do not see if `ensure` updated or let''s say `passmaxage`. Does this actually cause problems? One thing I''ve spotted is that your create method does update the @property_hash[:ensure] value but no other value. This seems to be wrong because if the resource was absent before, @property_hash is initally an empty hash. Because when `ensure` changes no other properties are synced you don''t have the desired values of all the other properties available in the `flush` method. So your `create` method should propably look like def create resource.class.validproperties.each do |property| if value = resource.should(property) @property_hash[property] = value end end end -Stefan -- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to puppet-users+unsubscribe@googlegroups.com. To post to this group, send email to puppet-users@googlegroups.com. Visit this group at http://groups.google.com/group/puppet-users?hl=en. For more options, visit https://groups.google.com/groups/opt_out.
jcbollinger
2013-Apr-08 13:55 UTC
Re: [Puppet Users] Flush provider - Differentiating between new resource and modification?
On Saturday, April 6, 2013 5:22:03 PM UTC-5, Stefan Schulte wrote:> > On Fri, 5 Apr 2013 00:57:32 -0700 (PDT) > Gavin Williams <fatm...@gmail.com <javascript:>> wrote: > > > Morning all > > > > I''m working on converting some of my NetApp providers to > > prefetch/flush style to try and optimize performance. > > > > I''ve hit an issue on my Netapp_user provider, around handling > > resource creation versus resource modification? > > What''s the easiest way to differentiate? > > > > Current code is here: > > > https://github.com/fatmcgav/fatmcgav-netapp/commit/66092978f4182c5474a60011db99ee2e3e12e689 > > > > Any tips appreciated. > > > > Regards > > Gavin > > > > There is no way to check *why* the flush method was called, you just now > that at least one property has been updated. You do not see if `ensure` > updated or let''s say `passmaxage`. Does this actually cause problems? >Your prefetch() method determines which target resources already exist as part of its normal job. It could flag those resources via some internal variable of the resource, or perhaps even in the @property_hash. You could even formalize that by creating a read-only property for it, if that makes you more comfortable. At flush() time you can assume that resources that are flagged already exist, and those that are not, don''t. There is a small window for collision if physical resources of the target type can be created / destroyed by a different process while Puppet is running, but that issue exists in any case. If you were not doing prefetching then the provider could check the existence of the physical resource as the first step of flushing. Indeed, it would need to do so, one way or another, to correctly apply the resource''s ''ensure'' parameter. Your provider can work this way despite prefetching if you don''t want to mark prefetched resources. John -- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to puppet-users+unsubscribe@googlegroups.com. To post to this group, send email to puppet-users@googlegroups.com. Visit this group at http://groups.google.com/group/puppet-users?hl=en. For more options, visit https://groups.google.com/groups/opt_out.