Uploaded image for project: 'Modules'
  1. Modules
  2. MODULES-1738

Calls to fqdn_rotate() cause future random data to be deterministic

    XMLWordPrintable

Details

    • Bug
    • Status: Resolved
    • Normal
    • Resolution: Fixed
    • None
    • None
    • stdlib

    Description

      This is an extension of an old Redmine issue that affected Puppet proper (#15791, to be specific), which affected fqdn_rand(). Specifically, the issue is that fqdn_rotate() changes the global seed and then doesn't reset it. This can be fixed by changing fqdn_rand() to either reset the global seed or use fqdn_rand()/Puppet::Util.deterministic_rand() for generating its random numbers. Puppet::Util.deterministic_rand() was added in Puppet 3.2.0 and either doesn't modify the global seed or (if that isn't possible) resets it after use, and fqdn_rand() was modified to use it for its random numbers.

      To demonstrate this issue, you can add the following line to the end of fqdn_rotate.rb before it returns:

      Puppet.warning("rand: #{rand}")
      

      and execute fqdn_rotate() twice in a single run:

      [root@puppet-eli ~]# puppet apply -e 'notice fqdn_rotate("abcdef") notice fqdn_rotate("abcdef")'
      Warning: rand: 0.017745413299069535
      Notice: Scope(Class[main]): efabcd
      Warning: rand: 0.017745413299069535
      Notice: Scope(Class[main]): efabcd
      Notice: Compiled catalog for puppet-eli.localdomain in environment production in 0.03 seconds
      Notice: Finished catalog run in 0.10 seconds
      

      Ideally, the two warnings would have different values in them.

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              eyoung@certifydatasystems.com Eli Young
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Zendesk Support