Uploaded image for project: 'Puppet'
  1. Puppet
  2. PUP-4698

Make fqdn_rand() Return A Numeric Instead of a String

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Normal
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: PUP 4.2.0
    • Component/s: None
    • Labels:
    • Template:
    • Story Points:
      1
    • Sprint:
      Language 2015-06-10, Language 2015-06-24
    • CS Priority:
      Minor
    • Release Notes:
      Bug Fix

      Description

      While testing the following snippet of code with the puppet 4 parser it would fail unexpectedly on only a few nodes.

      $cron_minute = fqdn_rand( 60 ) 
      if ($cron_minute >= '60') { 
        fail ("Variable cron_minute in module connection_watcher is >= 60. Values must be < 60. The cron_minute value is $cron_minute.") 
      }
      

      Upon further research, I figured the issue was because of the comparison of two strings not working the same was as two integers would.

      So, changing over to numeric for the comparison resolves the issue.

      $cron_minute = 0 + fqdn_rand( 60 ) #change a string to a numeric type
        if ($cron_minute >= 60) {
          fail ("Variable cron_minute in module connection_watcher is >= 60. Values must be < 60. The cron_minute value is $cron_minute.")
        }
      

      It turns out the issue with the original code only shows up with the values '7', '8', and '9' because the comparison compares lexiographically and makes a decision on the first two values since '7', '8' and '9' are > '6' (the first character in '60').

      At the end of the day it seems that fqdn_rand should just return a numeric as it will always be a number and is only a string for historical reasons.

        Attachments

          Issue Links

            Activity

              jsd-sla-details-panel

                People

                • Assignee:
                  Unassigned
                  Reporter:
                  nick.walker Nick Walker
                • Votes:
                  0 Vote for this issue
                  Watchers:
                  6 Start watching this issue

                  Dates

                  • Created:
                    Updated:
                    Resolved: