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

puppet 4.8.0 breaks code that uses strftime()

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Critical
    • Resolution: Cannot Reproduce
    • Affects Version/s: PUP 4.8.0
    • Fix Version/s: None
    • Component/s: None
    • Labels:
      None
    • Template:
    • Team:
      Puppet Developer Experience

      Description

      After upgrading to puppet-agent-1.8.0, my catalogs fail to compile with the following error:

      Error: Could not retrieve catalog from remote server: Error 500 on SERVER: Server Error: Evaluation Error: Error while evaluating a Resource Statement, Evaluation Error: Error while evaluating a Function Call, uninitialized constant Puppet::Pops::Time at /etc/puppetlabs/code/modules/bind/manifests/master_zone.pp:27:12 at /etc/puppetlabs/code/modules/bind/manifests/init.pp:286 on node shieldbreaker.l33tskillz.local
      

      This is the code in question:

      $now = strftime ('%s')
      

      If I isolate that code and run it with puppet apply, I receive the deprecation warning as per PUP-6724:

      $ puppet apply example.pp --test
      Info: Loading facts
      Info: Loading facts
      Warning: The argument signature (String format, [String timezone]) is deprecated for #strfime. See #strftime documentation and Timespan type for more info
         (file & line not available)
      Notice: Scope(Class[main]): now = 1478138495
      Notice: Compiled catalog for shieldbreaker.l33tskillz.local in environment production in 0.14 seconds
      Info: Applying configuration version '1478138494'
      Notice: Applied catalog in 0.03 seconds
      

      So, I try to be clever about it:

      if versioncmp($::clientversion, '4.8') >= 0 {
        $now = Timestamp.new.strftime('%s')
        notice ('using Timestamp.new.strftime')
      } else {
        $now = strftime ('%s')
        notice ('using stdlib strftime')
      }
      notice ("now = ${now}")
      

      This works via puppet apply:

      $ puppet apply example.pp --test
      Info: Loading facts
      Info: Loading facts
      Notice: Scope(Class[main]): using Timestamp.new.strftime
      Notice: Scope(Class[main]): now = 1478138766
      Notice: Compiled catalog for shieldbreaker.l33tskillz.local in environment production in 0.11 seconds
      Info: Applying configuration version '1478138766'
      Notice: Applied catalog in 0.03 seconds
      

      …but still chokes the Puppet master during compilation:

      Error: Could not retrieve catalog from remote server: Error 500 on SERVER: Server Error: Evaluation Error: Error while evaluating a Resource Statement, Evaluation Error: Resource type not found: Timestamp at /etc/puppetlabs/code/modules/bind/manifests/master_zone.pp:25:12 at /etc/puppetlabs/code/modules/bind/manifests/init.pp:286 on node shieldbreaker.l33tskillz.local
      

      I am running puppetserver 2.6.0, the latest that seems to be available.

      My guess is that Puppet 4.8.0 requires a new version of Puppet Server to support these new language constructs when used in master/agent mode. But the Puppet 4.8.0 release notes make no mention of this:

      https://docs.puppet.com/puppet/4.8/reference/release_notes.html

      In essence, it seems Puppet 4.8.0 is currently unusable when run as an agent, with any version of Puppet Server, if it uses any of the new time-related language constructs, or any stdlib function that does.

        Attachments

          Issue Links

            Activity

              jsd-sla-details-panel

                People

                • Assignee:
                  thomas.hallgren Thomas Hallgren
                  Reporter:
                  ralston James Ralston
                • Votes:
                  0 Vote for this issue
                  Watchers:
                  11 Start watching this issue

                  Dates

                  • Created:
                    Updated:
                    Resolved:

                    Zendesk Support