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

Binary, Sensitive, etc deferred results can corrupt the transaction store

    XMLWordPrintable

Details

    • Bug
    • Status: Resolved
    • Normal
    • Resolution: Fixed
    • None
    • PUP 6.25.0, PUP 7.10.0
    • None
    • Needs Priority
    • Bug Fix
    • Fixes a bug that prevented Puppet from reporting on corrective changes when using rich data types such as Deferred, Binary, Sensitive, etc.
    • Needs Assessment

    Description

      If the result of a deferred function is the desired value for a resource's property, then the agent will save that in the transaction store, causing an error the next time the agent runs. As a result, our ability to report on corrective/intentional change is lost.

      Given site.pp containing:

      notify { "deferred":
        message => Deferred.new("binary_file", ["/tmp/binary"])
      }
      

      where /tmp/binary contains hi\n, the agent evaluates the deferred function correctly:

      [root@keen-lecture ~]# rm -f /opt/puppetlabs/puppet/cache/state/transactionstore.yaml
      [root@keen-lecture ~]# rm -f /opt/puppetlabs/puppet/cache/client_data/catalog/$(facter fqdn).json
      [root@keen-lecture ~]# puppet agent -t
      Info: Using configured environment 'production'
      Info: Retrieving pluginfacts
      Info: Retrieving plugin
      Info: Retrieving locales
      Info: Loading facts
      Info: Caching catalog for keen-lecture.delivery.puppetlabs.net
      Info: Applying configuration version '1607561363'
      Notice: aGkK
      Notice: /Stage[main]/Main/Notify[deferred]/message: defined 'message' as Binary("aGkK")
      Notice: Applied catalog in 0.01 seconds
      

      But the transactionstore contains the raw Puppet::Pops::Types::PBinaryType::Binary object, not the pcore representation:

      [root@keen-lecture ~]# cat /opt/puppetlabs/puppet/cache/state/transactionstore.yaml
      ---
      resources:
        Notify[deferred]:
          parameters:
            message:
              system_value:
              - !ruby/object:Puppet::Pops::Types::PBinaryType::Binary
                binary_buffer: 'hi
       
      '
      

      The next agent run will generate an error:

      [root@keen-lecture ~]# puppet agent -t
      Info: Using configured environment 'production'
      Info: Retrieving pluginfacts
      Info: Retrieving plugin
      Info: Retrieving locales
      Info: Loading facts
      Info: Caching catalog for keen-lecture.delivery.puppetlabs.net
      Error: Transaction store file /opt/puppetlabs/puppet/cache/state/transactionstore.yaml is corrupt ((/opt/puppetlabs/puppet/cache/state/transactionstore.yaml): Tried to load unspecified class: Puppet::Pops::Types::PBinaryType::Binary); replacing
      Wrapped exception:
      Tried to load unspecified class: Puppet::Pops::Types::PBinaryType::Binary
      Info: Applying configuration version '1607561397'
      Notice: aGkK
      Notice: /Stage[main]/Main/Notify[deferred]/message: defined 'message' as Binary("aGkK")
      Notice: Applied catalog in 0.01 seconds
      

      This issue doesn't happen if the deferred result is type that YAML natively supports (string, integer, etc).

      Puppet should probably be using Puppet::Pops::Serialization::ToDataConverter to persist the transactionstore instead of yaml.

      Attachments

        Issue Links

          Activity

            People

              dorin.pleava Dorin Pleava
              josh Josh Cooper
              Votes:
              1 Vote for this issue
              Watchers:
              7 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Zendesk Support