Uploaded image for project: 'Hiera'
  1. Hiera
  2. HI-569

Hiera filecache class should not store nil when an exception is thrown

    Details

    • Type: Bug
    • Status: Open
    • Priority: Normal
    • Resolution: Unresolved
    • Affects Version/s: HI 3.2.2
    • Fix Version/s: None
    • Component/s: None
    • Labels:
      None
    • Template:
    • Team:
      Puppet Developer Experience
    • QA Risk Assessment:
      Needs Assessment

      Description

      The error is caused by:

      https://github.com/puppetlabs/hiera/blob/3.2.2/lib/hiera/backend/yaml_backend.rb#L22

      Steps to reproduce:

      1. Install PE 2016.4.3 with a simple hiera_include('classes') inside of node default in site.pp.
      2. Configure common.yaml with classes: []
      3. Change permissions on common.yaml from 644 to 640.
      4. Perform two puppet agent runs.
      5. Notice the cryptic error message on the second run.

      Expected behavior:

      The helpful error message returned in the first agent run should always be returned.

      Actual behavior:

      The helpful error message is only returned once and is buried by subsequent agent reports. The cryptic error message is returned on all subsequent agent runs and makes troubleshooting extremely time consuming and costly.

      Potential fix:

      The filecache class should not store nil when an exception is thrown. Doing so results in the cryptic error message on all subsequent runs.

      I suspect the root cause of the bug is here: https://github.com/puppetlabs/hiera/blob/3.2.2/lib/hiera/filecache.rb#L53

      There is no handler for when when the passed block throws an exception which results in

      @cache[path][:data] 
      

      being set to nil.

      Storing nil causes the cryptic error message on all subsequent runs.

      [root@abc123 ~]# puppet agent -t --no-noop 
      Info: Using configured environment 'test' 
      Info: Retrieving pluginfacts 
      Info: Retrieving plugin 
      Info: Loading facts 
      Error: Could not retrieve catalog from remote server: Error 500 on SERVER: Server Error: Evaluation Error: Error while evaluating a Function Call, Permission denied - /opt/puppet-data/hiera/common.yaml at /etc/puppetlabs/code/environments/test/manifests/site.pp on node abc123.domain.com 
      Warning: Not using cache on failed catalog 
      Error: Could not retrieve catalog; skipping run
       
      [root@abc123 ~]# puppet agent -t --no-noop 
      Info: Using configured environment 'test' 
      Info: Retrieving pluginfacts 
      Info: Retrieving plugin 
      Info: Loading facts 
      Error: Could not retrieve catalog from remote server: Error 500 on SERVER: Server Error: Evaluation Error: Error while evaluating a Function Call, undefined method `empty?' for nil:NilClass at /etc/puppetlabs/code/environments/SBX/manifests/site.pp on node abc123.domain.com 
      Warning: Not using cache on failed catalog 
      Error: Could not retrieve catalog; skipping run 
      

        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              tom.kishel Thomas Kishel
            • Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

              • Created:
                Updated:

                Zendesk Support