Bug #2940

Package resource with ensure=>latest and invalid source gives "undefined method" error msg

Added by Alan Harder 9 months ago. Updated 4 months ago.

Status:Closed Start:12/16/2009
Priority:Normal Due date:
Assignee:Alan Harder % Done:

0%

Category:package
Target version:0.25.2
Affected version:0.25.2rc1 Branch:http://github.com/MarkusQ/puppet/tree/ticket/0.25.x/2940
Keywords:
Votes: 1

Description

package {
  source => '/bogus/path',
  ensure => 'latest',
  provider => 'sun'
}

with something like this the error message I see with current 0.25.x branch from git looks like this: @Failed to retrieve current state of resource: Could not get latest version: undefined method `[]‘ for nil:NilClass@

Getting an error is correct, as the source is an invalid path, but the “undefined method” in “nil:NilClass” looks odd.


Related issues

related to Puppet - Bug #2999: Absent package problem on Solaris Closed 01/01/2010

History

Updated by Markus Roberts 9 months ago

  • Status changed from Unreviewed to Accepted
  • Priority changed from Low to Normal
  • Target version set to 0.25.2

Updated by Markus Roberts 9 months ago

  • Status changed from Accepted to Needs more information
  • Assignee set to Alan Harder

I don’t have access to a sun setup and was unable to reproduce the analog of this with another provider. Also, I note that this is an incomplete example, in that there’s no name given for the package, which should prevent it from getting as far as it would need to to generate the indicated error.

Updated by Alan Harder 9 months ago

Oops, yes I did miss the resource name.. and that is an important factor. If it is a package name that does not exist on the system, the error is ok:

err: //Node[]/Package[test]/ensure: change from absent to latest failed: Could not update: Execution of '/usr/sbin/pkgadd -d /bogus/path -n test' returned 99: pkgadd: ERROR: attempt to process datastream failed
    - open of  failed, errno=2
pkgadd: ERROR: could not process datastream from 
 at /etc/opt/csw/puppet/manifests/nodes.pp:14

But if the package does exist on the system (so it needs to compare the version number), then it gets the nil:NilClass error. Any other information I can provide? I updated to today’s 0.25.x branch from git and still see this.

Updated by Alan Harder 9 months ago

I looked at info2hash in provider/package/sun.rb, and tried changing “return nil” to “return {}” in the rescue block for Puppet::ExecutionFailure. This avoided the nil:NilClass error, and instead I got:

debug: //Node[]/Package[]/ensure:  "" is installed, latest is nil

It then preceded to pkgrm the package.. so this behavior isn’t great either. Would be better to report the error in determining the version of the given package source, and abort before doing pkgrm of the existing package.

Updated by Markus Roberts 9 months ago

  • Status changed from Needs more information to Accepted
  • Assignee changed from Alan Harder to Jesse Wolfe

Thanks for the info that should be enough for us to track it down (and if not, we’ll ask for more).

Updated by Markus Roberts 9 months ago

  • Status changed from Accepted to Ready for Testing
  • Assignee changed from Jesse Wolfe to Alan Harder
  • Branch set to http://github.com/MarkusQ/puppet/tree/ticket/0.25.x/2940

Instead of returning anything it should now generate a more informative / specific message and abort that resource.

Updated by Alan Harder 9 months ago

Here’s the output I get now:

debug: Package[CSWfacter](provider=sun): Executing '/usr/bin/pkginfo -l -d /bogus/path CSWfacter'
err: //Node[]/Package[CSWfacter]: Failed to retrieve current state of resource: Could not get latest version: Unable to get information about installed version of package CSWfacter, if any because of: #

Behavior is good.. message mentions “installed version”, though it actually failed to get the new/package version, not the installed version. The IO:0xf98e20 thing isn’t too helpful, but that’s ok. Thanks!

Updated by Markus Roberts 9 months ago

Updated with a revised message.

Updated by Alan Harder 9 months ago

Looks great!

debug: Package[CSWfacter](provider=sun): Executing '/usr/bin/pkginfo -l -d /bogus/path CSWfacter'
err: //Node[]/Package[CSWfacter]: Failed to retrieve current state of resource: Could not get latest version: Unable to get information about package CSWfacter because of: pkginfo: ERROR: unable to complete package transfer
    - unable to obtain package volume

Updated by James Turnbull 9 months ago

  • Status changed from Ready for Testing to Closed

Pushed in commit:“0e5d2647bd5f515dbaacf45f9e7dda5c27eb465a” in branch 0.25.x

Also available in: Atom PDF