Hi
> Hrm, in reading more closely, I now see that your code will only ever
> initialize the @updates hash, it will never replace it. Once @updates
> is created, the content becomes static, which is obviously a problem.
ok, yeah I now see this as a problem as well. I didn't think/see that
the provider never gets invalidated. Or is there a function for this?
> I think the right solution here is to make the yum prefetching more
> like other packaging systems -- prefetch should create a new provider
> instance and set it as the provider for each prefetched package.
>
> E.g., something like this:
>
> def self.prefetch(packages)
> super # collect all rpm information
> # return if we don't need 'latest' info
> return unless packages.detect { |p| p[:ensure] == :latest }
>
> # collect our 'latest' info
>
> updates = {}
> if Process.euid != 0
> raise Puppet::Error, "The yum provider can only be used
> as root"
> end
> python(YUMHELPER).each_line do |l|
> l.chomp!
> next if l.empty?
> if l[0,4] == "_pkg"
> hash = nevra_to_hash(l[5..-1])
> [hash[:name], "#{hash[:name]}.#{hash[:arch]}"].each
> do |n|
> updates[n] ||= []
> updates[n] << hash
> end
> end
> end
>
> # Add our 'latest' info to the providers.
> packages.each do |package|
> if info = updates[package[:name]]
> package.provider.latest = info[0]
> end
> end
> end
>
> This won't exactly work, because I doubt there's a 'latest=' method on
> the providers, but it's a good start.
>
> The big benefit of this over existing methods is that it involves no
> persistent state.
a more general question to understand how providers are instantiated:
puppet will run prefetch once as a global initalizer, but every package
will get it's own instance of the package provider?
actually I have some problem to understand of what kind will be
package.provider in your example? an instance of the yum provider, or
any other selected provider? maybe someone could point me to some
documentation about that or explain it a bit in detail? thanks!
> The downside of it is that you'll then have to change the 'latest'
> method so that, if no value is already present (e.g., in the
> @property_hash), it will need to know how to retrieve the value
> itself.
>
> I don't know if the yumhelper.rb can be run for individual
> packages. (Note that this state would only ever happen outside of a
> normal transaction, such as when you're running 'ralsh package <foo>'.)
looking at the fact that running yum itself is very expensive, I don't
think it is a good idea to run the yumhelper for every package.
however I have another idea:
currently I check if @updates is undef, how about setting @updates in
every prefetch to nil and then checking if @updates is nil? the problem
is that you seem not to able to undef variables (only constants) in
ruby. or have this changed?
ok anyway this won't change the fact that we still have the hackish
thing with the yumhelper. But I currently don't see a more performant
solution, regarding yum's overbloated behaviour. In my opinion calling
yumhelper or even yum for every package is simply too slow and just will
use a lot of resources.
greets pete
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---