Bug #14764

Auditing logs error "undefined method `rjust' for :absent:Symbol"

Added by R.I. Pienaar about 1 year ago. Updated 2 months ago.

Status:ClosedStart date:05/31/2012
Priority:NormalDue date:
Assignee:-% Done:

0%

Category:auditing/compliance
Target version:3.2.0
Affected Puppet version:3.1.1 Branch:https://github.com/puppetlabs/puppet/pull/1557
Keywords: customer

Description

Given:

file{"/tmp/foo": audit => "all"}

If I first run it with the file missing I get:

$ puppet apply test.pp
notice: /Stage[main]//File[/tmp/foo]/ensure: audit change: newly-recorded value absent
notice: /Stage[main]//File[/tmp/foo]/content: audit change: newly-recorded value absent
notice: /Stage[main]//File[/tmp/foo]/target: audit change: newly-recorded value absent
notice: /Stage[main]//File[/tmp/foo]/owner: audit change: newly-recorded value absent
notice: /Stage[main]//File[/tmp/foo]/group: audit change: newly-recorded value absent
notice: /Stage[main]//File[/tmp/foo]/mode: audit change: newly-recorded value absent
notice: /Stage[main]//File[/tmp/foo]/type: audit change: newly-recorded value absent
notice: /Stage[main]//File[/tmp/foo]/seluser: audit change: newly-recorded value absent
notice: /Stage[main]//File[/tmp/foo]/selrole: audit change: newly-recorded value absent
notice: /Stage[main]//File[/tmp/foo]/seltype: audit change: newly-recorded value absent
notice: /Stage[main]//File[/tmp/foo]/selrange: audit change: newly-recorded value absent
notice: /Stage[main]//File[/tmp/foo]/ctime: audit change: newly-recorded value absent
notice: /Stage[main]//File[/tmp/foo]/mtime: audit change: newly-recorded value absent
notice: Finished catalog run in 0.03 seconds

If I then create the file and run again:

$ touch /tmp/foo
$ puppet apply test.pp
notice: /Stage[main]//File[/tmp/foo]/ensure: audit change: previously recorded value absent has been changed to file
notice: /Stage[main]//File[/tmp/foo]/content: audit change: previously recorded value absent has been changed to {md5}d41d8cd98f00b204e9800998ecf8427e
notice: /Stage[main]//File[/tmp/foo]/target: audit change: previously recorded value absent has been changed to notlink
notice: /Stage[main]//File[/tmp/foo]/owner: audit change: previously recorded value absent has been changed to rip
notice: /Stage[main]//File[/tmp/foo]/group: audit change: previously recorded value absent has been changed to rip
err: /Stage[main]//File[/tmp/foo]: Could not evaluate: undefined method `rjust' for :absent:Symbol
notice: Finished catalog run in 0.03 seconds

If I run this with —trace

/usr/lib/ruby/site_ruby/1.8/puppet/type/file/mode.rb:145:in `is_to_s'
/usr/lib/ruby/site_ruby/1.8/puppet/transaction/resource_harness.rb:94:in `create_change_event'
/usr/lib/ruby/site_ruby/1.8/puppet/transaction/resource_harness.rb:72:in `perform_changes'
/usr/lib/ruby/site_ruby/1.8/puppet/transaction/resource_harness.rb:69:in `each'
/usr/lib/ruby/site_ruby/1.8/puppet/transaction/resource_harness.rb:69:in `perform_changes'
/usr/lib/ruby/site_ruby/1.8/puppet/transaction/resource_harness.rb:133:in `evaluate'
/usr/lib/ruby/site_ruby/1.8/puppet/transaction.rb:49:in `apply'
/usr/lib/ruby/site_ruby/1.8/puppet/transaction.rb:84:in `eval_resource'
/usr/lib/ruby/site_ruby/1.8/puppet/transaction.rb:104:in `evaluate'
/usr/lib/ruby/site_ruby/1.8/puppet/util.rb:484:in `thinmark'
/usr/lib/ruby/1.8/benchmark.rb:308:in `realtime'
/usr/lib/ruby/site_ruby/1.8/puppet/util.rb:483:in `thinmark'
/usr/lib/ruby/site_ruby/1.8/puppet/transaction.rb:104:in `evaluate'
/usr/lib/ruby/site_ruby/1.8/puppet/transaction.rb:386:in `traverse'
/usr/lib/ruby/site_ruby/1.8/puppet/transaction.rb:99:in `evaluate'
/usr/lib/ruby/site_ruby/1.8/puppet/resource/catalog.rb:141:in `apply'
/usr/lib/ruby/site_ruby/1.8/puppet/configurer.rb:122:in `retrieve_and_apply_catalog'
/usr/lib/ruby/site_ruby/1.8/puppet/util.rb:159:in `benchmark'
/usr/lib/ruby/1.8/benchmark.rb:308:in `realtime'
/usr/lib/ruby/site_ruby/1.8/puppet/util.rb:158:in `benchmark'
/usr/lib/ruby/site_ruby/1.8/puppet/configurer.rb:121:in `retrieve_and_apply_catalog'
/usr/lib/ruby/site_ruby/1.8/puppet/configurer.rb:152:in `run'
/usr/lib/ruby/site_ruby/1.8/puppet/application/apply.rb:239:in `main'
/usr/lib/ruby/site_ruby/1.8/puppet/application/apply.rb:153:in `run_command'
/usr/lib/ruby/site_ruby/1.8/puppet/application.rb:309:in `run'
/usr/lib/ruby/site_ruby/1.8/puppet/application.rb:416:in `hook'
/usr/lib/ruby/site_ruby/1.8/puppet/application.rb:309:in `run'
/usr/lib/ruby/site_ruby/1.8/puppet/application.rb:407:in `exit_on_fail'
/usr/lib/ruby/site_ruby/1.8/puppet/application.rb:309:in `run'
/usr/lib/ruby/site_ruby/1.8/puppet/util/command_line.rb:69:in `execute'
/usr/bin/puppet:4
err: /Stage[main]//File[/tmp/foo]: Could not evaluate: undefined method `rjust' for :absent:Symbol

This is with apply – not tested against a master.

History

#1 Updated by Kelsey Hightower about 1 year ago

  • Status changed from Unreviewed to Accepted

#2 Updated by Robert Bell 5 months ago

Is there any solution for this? I’m seeing it when I audit Files

#3 Updated by Charlie Sharpsteen 3 months ago

  • Assignee set to Charlie Sharpsteen

#4 Updated by Charlie Sharpsteen 3 months ago

  • Status changed from Accepted to Investigating
  • Affected Puppet version changed from 2.7.14 to 3.1.1

Confirmed that this is still present in 3.1.1.

The issue appears to be triggered by a change in state from present to absent or vice versa. In this case, we have the following situation entering the create_change_event method in resource_harness.rb:

historical_value = :absent
current_value = "644"

The is_to_s method for file modes does the following:

def is_to_s(currentvalue)
      currentvalue.rjust(4, "0")
end

That works great for actual file modes like “644” as it transforms them to “0644”. But when current_value or historical_value is a symbol like :absent, then the method falls over.

#5 Updated by Charlie Sharpsteen 3 months ago

  • Status changed from Investigating to In Topic Branch Pending Review
  • Branch set to https://github.com/puppetlabs/puppet/pull/1557

#6 Updated by Adrien Thebo 3 months ago

  • Category set to auditing/compliance
  • Status changed from In Topic Branch Pending Review to Merged - Pending Release
  • Assignee deleted (Charlie Sharpsteen)
  • Target version set to 3.2.0

Merged into master as 3eea0e4.

This should be released in 3.2.0.

Thanks again for the contribution!

-Adrien

#7 Updated by Charlie Sharpsteen 2 months ago

  • Keywords set to customer

#9 Updated by Matthaus Owens 2 months ago

  • Status changed from Merged - Pending Release to Closed

Released in Puppet 3.2.0-rc1

#10 Updated by Matthaus Owens 2 months ago

Released in Puppet 3.2.0-rc1

Also available in: Atom PDF