Details
-
Bug
-
Status: Resolved
-
Normal
-
Resolution: Fixed
-
None
-
None
-
Night's Watch
-
1
-
NW - 2021-06-30
-
Needs Assessment
-
Bug Fix
-
Previously, the `age` parameter of the `tidy` resource did not work according to the documentation and only removed files older than the specified time. Now it removes files whose age is equal to or greater than the specified time.
-
Needs Assessment
Description
Puppet Version: any
Puppet Server Version: n/a
OS Name/Version: n/a
The documentation for the age parameter for the tidy type states:
Tidy files whose age is equal to or greater than the specified time. You can choose seconds, minutes, hours, days, or weeks by specifying the first letter of any of those words (for example, ‘1w’ represents one week).
Docs: https://puppet.com/docs/puppet/7.7/types/tidy.html#tidy-attribute-age
Specifying 0 will remove all files.
Desired Behavior:
Setting age=0 removes all files
Actual Behavior:
Setting age=0 requires the target file to be at least 1 second old.
This was discovered when writing integration tests for the puppet resource subcommand (PUP-11074).
Relevant code: https://github.com/puppetlabs/puppet/blob/b91e53a38cb4671d4de9078837c05931c69121f9/lib/puppet/type/tidy.rb#L147
def tidy?(path, stat)
|
# If the file's older than we allow, we should get rid of it.
|
(Time.now.to_i - stat.send(resource[:type]).to_i) > value
|
end
|
Note that the greater than or equal comparison is respected for the size parameter:
def tidy?(path, stat)
|
stat.size >= value
|
end
|