puppetlabs/puppet — pull request #2321 by kylog (2014-02-01 01:27:18+00:00)
Title: (pup-1524) Correct resource_present? to account for purged

The fix for http://projects.puppetlabs.com/issues/23081 included
e376b9d8, which refactored some of the resource_harness code and
introduced ResourceApplicationContext.resource_present?

At the time that method only checked current_values[:ensure] against
:absent, which meant that if current_values[:ensure] was :purged,
then resource_present? was true and the code thus attempted to
sync additional properties. This resulted in the double events
noted in this ticket (the first one in manage_via_ensure_if_possible,
the second (unnecessary) one in sync_if_needed).

This change adds a present? method to Puppet::Type, the default
implementation of which just checks for :ensure != :absent, but
which must be overridden by other types that have additional values
for :ensure that also imply that the resource is not present. It also
overrides that method in the package, file, and interface types,
each of which offer such additional values for :ensure.

In addition, there was another code path for duplicate events
because the previous code didn't distinguish between not using
ensure and the ensure check failing (e.g. due to a provider failure).
To address this, the code was refactored slightly to introduce
the NO_ACTION return from sync_if_needed.