Details
-
Bug
-
Status: Resolved
-
Normal
-
Resolution: Fixed
-
None
-
Coremunity
-
Platform Core KANBAN
-
Needs Assessment
-
39142
-
1
-
Bug Fix
-
Improve how puppet detects the current pip version so that catalog application does not fail when managing pip package resources.
-
Needs Assessment
Description
Puppet Version: 4.8.2
OS Name/Version: Debian 8.10
When trying to install a package with the pip provider
puppet agent -t fails with
Info: Using configured environment 'xxx' |
Info: Retrieving pluginfacts
|
Info: Retrieving plugin
|
Info: Loading facts
|
Info: Caching catalog for myhost.com |
Info: Applying configuration version '123213' |
Error: Failed to apply catalog: undefined method `[]' for nil:NilClass |
|
with --trace it points to:
Error: Failed to apply catalog: undefined method `[]' for nil:NilClass |
/opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/provider/package/pip.rb:64:in `block (2 levels) in pip_version' |
/opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/provider/package/pip.rb:63:in `each' |
/opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/provider/package/pip.rb:63:in `collect' |
/opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/provider/package/pip.rb:63:in `block in pip_version' |
/opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/util/execution.rb:81:in `block (2 levels) in execpipe' |
/opt/puppetlabs/puppet/lib/ruby/2.1.0/open-uri.rb:36:in `open' |
/opt/puppetlabs/puppet/lib/ruby/2.1.0/open-uri.rb:36:in `open' |
/opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/util/execution.rb:80:in `block in execpipe' |
/opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/util.rb:128:in `withenv' |
/opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/util/execution.rb:79:in `execpipe' |
/opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/provider.rb:117:in `execpipe' |
/opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/provider/package/pip.rb:62:in `pip_version' |
/opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/provider/package/pip.rb:43:in `instances' |
/opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/provider/package.rb:4:in `prefetch' |
/opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/transaction.rb:323:in `prefetch' |
/opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/transaction.rb:223:in `prefetch_if_necessary' |
/opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/transaction.rb:107:in `block in evaluate' |
/opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/graph/relationship_graph.rb:116:in `call' |
/opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/graph/relationship_graph.rb:116:in `traverse' |
/opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/transaction.rb:154:in `evaluate' |
/opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/resource/catalog.rb:222:in `block in apply' |
/opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/util/log.rb:155:in `with_destination' |
/opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/transaction/report.rb:142:in `as_logging_destination' |
/opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/resource/catalog.rb:221:in `apply' |
/opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/configurer.rb:171:in `block in apply_catalog' |
/opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/util.rb:223:in `block in benchmark' |
|
The code is:
1 def self.pip_version |
2 pip_cmd = self.pip_cmd |
3 return nil unless pip_cmd |
4 execpipe [pip_cmd, '--version'] do |process| |
5 process.collect do |line| |
6 return line.strip.match(/^pip (\d+\.\d+\.?\d*).*$/)[1] |
7 end |
8 end |
9 end |
|
Line 6 fails when "pip --version" returns other information:
# pip --version
|
/usr/local/lib/python2.7/dist-packages/urllib3/contrib/socks.py:37: DependencyWarning: SOCKS support in urllib3 requires the installation of optional dependencies: specifically, PySocks. For more information, see https://urllib3.readthedocs.io/en/latest/contrib.html#socks-proxies |
DependencyWarning
|
pip 1.5.6 from /usr/lib/python2.7/dist-packages (python 2.7) |
Because then there is no match, it returns null and using [1] on null obviously fails.
Installing python-pysocks removes the warning and fixes the puppet run.
Desired Behavior:
The pip_version function should be able to handle additional output. Either by checking if there is a match or by filtering out stderr.