HomePhorge

(PUP-2710) For audit only, compare Time objects as strings
ec910598c2c6Unpublished

Unpublished Commit ยท Learn More

Repository Importing: This repository is still importing.

Description

(PUP-2710) For audit only, compare Time objects as strings

Previously, auditing the mtime or ctime properties of a file
on ext4 (or any nanosecond resolution filesystem) when running
under ruby 1.9+ would spuriously report a change on every catalog
run.

This was because the yaml library (or libraries, more on that
shortly) correctly serialize the nanosecond resolution of the Time
object to yaml, *but* on deserialization they produce a Time object
truncated to microseconds. This led to a false inequality operation
leading to the spurious audit messages.

This patch is an unfortunate hack consisting of special-casing
the comparison of Time objects in the audit equality operation.

For context, I also considered alternatives:

  • Monkey-patching the Time object == method to ignore nanoseconds. But this would affect all Time objects and could have undesired consequences.
  • Monkey-patching the yaml library to correctly deserialize. But this got messy because there are several different yaml libraries that may be involved.
  • Intercepting the serialization in Puppet::Util::Yaml, but this would mean discarding nanoseconds for all serialization of Time objects to yaml.

In the end, this spot fix seemed like the least evil solution.

Details

Provenance
Kylo Ginsberg <kylo@puppetlabs.com>Authored on
Ethan J. Brown <Iristyle@GitHub.com>Committed on Jun 4 2014, 3:19 PM
vanmeeuwenPushed on Jun 2 2015, 2:22 PM
Parents
rPU923e002024b6: (PUP-2583) Fix bad test case in file type mode acceptance test.
Branches
Unknown
Tags
Unknown

Event Timeline

Ethan J. Brown <Iristyle@GitHub.com> committed rPUec910598c2c6: (PUP-2710) For audit only, compare Time objects as strings (authored by Kylo Ginsberg <kylo@puppetlabs.com>).Jun 4 2014, 3:19 PM