Jira (PUP-11079) Setting age=0 on a tidy resource does not remove all files

1 view
Skip to first unread message

Gabriel Nagy (Jira)

unread,
Jun 3, 2021, 9:22:02 AM6/3/21
to puppe...@googlegroups.com
Gabriel Nagy created an issue
 
Puppet / Bug PUP-11079
Setting age=0 on a tidy resource does not remove all files
Issue Type: Bug Bug
Assignee: Unassigned
Created: 2021/06/03 6:21 AM
Priority: Normal Normal
Reporter: Gabriel Nagy

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

Add Comment Add Comment
 
This message was sent by Atlassian Jira (v8.13.2#813002-sha1:c495a97)
Atlassian logo

Ciprian Badescu (Jira)

unread,
Jun 8, 2021, 3:54:02 AM6/8/21
to puppe...@googlegroups.com
Ciprian Badescu updated an issue
Change By: Ciprian Badescu
Sprint: ready for triage NW-2021-06-30

Ciprian Badescu (Jira)

unread,
Jun 16, 2021, 5:52:02 AM6/16/21
to puppe...@googlegroups.com

Gabriel Nagy (Jira)

unread,
Jun 16, 2021, 10:43:01 AM6/16/21
to puppe...@googlegroups.com

Josh Cooper (Jira)

unread,
Jun 16, 2021, 5:40:03 PM6/16/21
to puppe...@googlegroups.com

Gabriel Nagy (Jira)

unread,
Jun 17, 2021, 9:06:01 AM6/17/21
to puppe...@googlegroups.com
Gabriel Nagy updated an issue
 
Change By: Gabriel Nagy
Release Notes: Bug Fix
Release Notes Summary: 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.

Victor Bobosila (Jira)

unread,
Jul 5, 2021, 8:01:01 AM7/5/21
to puppe...@googlegroups.com

Victor Bobosila (Jira)

unread,
Jul 8, 2021, 7:01:01 AM7/8/21
to puppe...@googlegroups.com

Claire Cadman (Jira)

unread,
Jul 13, 2021, 8:07:02 AM7/13/21
to puppe...@googlegroups.com
Reply all
Reply to author
Forward
0 new messages