The Puppet Labs Issue Tracker has Moved: https://tickets.puppetlabs.com

This issue tracker is now in read-only archive mode and automatic ticket export has been disabled. Redmine users will need to create a new JIRA account to file tickets using https://tickets.puppetlabs.com. See the following page for information on filing tickets with JIRA:

Bug #8814

fqdn_rand() causes can't convert String into Integer error

Added by Noah Diewald over 4 years ago. Updated over 3 years ago.

Status:ClosedStart date:08/08/2011
Priority:NormalDue date:
Assignee:-% Done:

0%

Category:functions
Target version:3.0.0
Affected Puppet version:2.7.1 Branch:
Keywords:Ruby 1.9.2

We've Moved!

Ticket tracking is now hosted in JIRA: https://tickets.puppetlabs.com


Description

This is occurring in version 2.7.1 and in the master branch. I’m running ruby 1.9.2p290 on Arch Linux.

The section of my manifest looks like this:

  $rand_hour = fqdn_rand(23,5445)
  $rand_minute = fqdn_rand(59,954)

From puppetd, I get:

err: Could not retrieve catalog from remote server: Error 400 on SERVER: can't convert String into Integer at /etc/puppet/manifests/mymanifest.pp:4 on node example.com

From puppetmasterd, I get:

err: can't convert String into Integer at /etc/puppet/manifests/mymanifest.pp:4 on node example.com

I tried a number of things, like using only one argument to fqdn_rand() but it turns out my version of Ruby’s rand function doesn’t like string arguments and that fqdn_rand’s arguments are strings when they reach rand.

I’ve included a patch that got things working for me.

fix_fqdn_rand.patch Magnifier - Patch to fqdn_rand.rb (882 Bytes) Noah Diewald, 08/08/2011 12:52 am

History

#1 Updated by Nan Liu over 4 years ago

  • Status changed from Unreviewed to Accepted
  • Target version set to 2.7.x
  • Keywords set to Ruby 1.9.2

Confirmed Ruby 1.9.2 does not handle rand with string, and the patch seems sensible:

ruby-1.9.2-p136 :002 >   rand(4)
=> 1 
ruby-1.9.2-p136 :003 > rand('4')
TypeError: can't convert String into Integer
from (irb):3:in `rand'
from (irb):3
from /Users/nan/.rvm/rubies/ruby-1.9.2-p136/bin/irb:16:in `<main>'
ruby-1.9.2-p136 :004 > rand('4'.to_i)
=> 1 
ruby-1.9.2-p136 :005 > 

#2 Updated by James Turnbull over 4 years ago

  • Category set to functions
  • Status changed from Accepted to Requires CLA to be signed

Hi Noah! Thanks for your patch. Could I please get you to sign a CLA (see the Contributor License Agreement link in the top menu) and have a quick look at our http://projects.puppetlabs.com/projects/puppet/wiki/Development_Development_Lifecycle link?

Thanks again!

#3 Updated by Nan Liu over 4 years ago

FYI, I sent a merge request, but since i didn’t write the original code, this require contributor CLA first.

#4 Updated by Noah Diewald over 4 years ago

I signed the CLA and looked at the Development_Development_Lifecycle page.

#5 Updated by Anonymous over 4 years ago

  • Status changed from Requires CLA to be signed to Merged - Pending Release
  • Target version changed from 2.7.x to 3.x

#6 Updated by Anonymous almost 4 years ago

  • Target version changed from 3.x to 3.0.0

#7 Updated by Matthaus Owens over 3 years ago

  • Status changed from Merged - Pending Release to Closed

Released in Puppet 3.0.0rc1

Also available in: Atom PDF