Uploaded image for project: 'Puppet'
  1. Puppet
  2. PUP-11079

Setting age=0 on a tidy resource does not remove all files

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Normal
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: PUP 6.24.0, PUP 7.9.0
    • Component/s: None
    • Labels:
    • Template:
      PUP Bug Template
    • Team:
      Night's Watch
    • Story Points:
      1
    • Sprint:
      NW - 2021-06-30
    • Method Found:
      Needs Assessment
    • 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.
    • QA Risk Assessment:
      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
      

        Attachments

          Activity

            People

            Assignee:
            gabriel.nagy Gabriel Nagy
            Reporter:
            gabriel.nagy Gabriel Nagy
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved:

                Zendesk Support