Bug #6628
Parsed file providers fail to replace missing entries on first run where they are missing
| Status: | Accepted | Start date: | 03/07/2011 | |
|---|---|---|---|---|
| Priority: | Normal | Due date: | ||
| Assignee: | - | % Done: | 0% |
|
| Category: | provider | |||
| Target version: | 2.7.x | |||
| Affected Puppet version: | 2.7.9 | Branch: | ||
| Keywords: | ||||
| Votes: | 0 |
Description
I discovered this bug while trying to write integration tests for the mount provider. Thanks to Nick Lewis for helping me narrow it down to a reproducible test case.
Steps to reproduce:
Start a master running this manifest:
host { "foo": ip => '1.2.3.4', target => "/tmp/hosts" }Start a client using the options
--verbose --no-daemonize --runinterval 60 --no-onetimeso that the client runs every 60 seconds.After the client runs for the first time, open
/tmp/hostsand delete the line1.2.3.4 fooAfter the client runs for the second time, reload the file
/tmp/hosts. Expected behavior: the missing line should be back. Observed behavior: it isn’t.After the client runs for the third time, reload the file
/tmp/hosts. The missing line is now back.
History
Updated by Paul Berry about 1 year ago
Here’s what’s happening:
When the client receives the catalog from the master, it reconstitutes it by creating “host” resources and their associated parsed provider objects. In the Puppet::Provider::ParsedFile#initialize() method, we attempt to create a @property_hash based on prefetched file contents (in this case, the contents of the “/tmp/hosts” file). However, at this point in execution, the file contents have not been prefetched yet, so the @property_hash is created based on old inaccurate information.
Later, when Puppet::Provider::ParsedFile.prefetch() is called, it attempts to fix the inaccurate information by rebuilding the existing ParsedFile objects. However, it only rebuilds the ParsedFile objects associated with records that were actually prefetched; any ParsedFile objects associated with records that were not present don’t get rebuilt.
So, in the repro steps described above, when the client runs for the second time, it builds the @property_hash for the “foo” resource based on the old state of /tmp/hosts. When it later actually gets around to reading /tmp/hosts, it doesn’t find a line for the “foo” resource so it doesn’t rebuild it. Thus, when applying the catalog, it incorrectly concludes that the “foo” resource is still in the old correct state, so it doesn’t update it.
IMHO, we should fix this bug by restructuring the ParsedFile base class so that it never stores incorrect data in memory in the first place.
Since this bug is produced by code in Puppet::Provider::ParsedFile, it probably exists in all providers based on ParsedFile.
Updated by James Turnbull about 1 year ago
I suspect this explains some type specific tickets for types that use ParsedFile.
Updated by Ben Hughes 4 months ago
- Description updated (diff)
- Status changed from Accepted to Unreviewed
Updated by Devon Peters 4 months ago
- Description updated (diff)
- Category set to provider
- Status changed from Unreviewed to Accepted
- Target version set to 2.7.x
- Affected Puppet version set to 2.7.9
Was able to reproduce this same behavior using 2.7.9.