Jira (PUP-10688) tidy resource does not honor schedule metaparameter

45 views
Skip to first unread message

Michael Luck (Jira)

unread,
Oct 6, 2020, 3:01:03 PM10/6/20
to puppe...@googlegroups.com
Michael Luck created an issue
 
Puppet / Bug PUP-10688
tidy resource does not honor schedule metaparameter
Issue Type: Bug Bug
Affects Versions: PUP 6.18.0
Assignee: Unassigned
Created: 2020/10/06 12:00 PM
Priority: Normal Normal
Reporter: Michael Luck

When using schedule and recurse with the tidy resource, it will apply on every Puppet run rather than adhering to the given schedule. For example, I run this tidy resource to clean up log files on some Windows agents. I expected it to only run on Sundays as indicated by the schedule but it will execute on every Puppet run instead.

 

{{ schedule { 'cleanup_window':}}
{{ weekday => 'Sunday'}}
{{ }}}

tidy { 'C:\ProgramData\os_patching':
    age => '1w',
    matches => '*.log',
    recurse => true,
    schedule => 'cleanup_window'
{{ }}}

Add Comment Add Comment
 
This message was sent by Atlassian Jira (v8.5.2#805002-sha1:a66f935)
Atlassian logo

Michael Luck (Jira)

unread,
Oct 6, 2020, 3:02:05 PM10/6/20
to puppe...@googlegroups.com
Michael Luck updated an issue
Change By: Michael Luck
When using schedule and recurse with the tidy resource, it will apply on every Puppet run rather than adhering to the given schedule. For example, I run this tidy resource to clean up log files on some Windows agents. I expected it to only run on Sundays as indicated by the schedule but it will execute on every Puppet run instead.

 

{{ schedule { 'cleanup_window': }}
{{ weekday => 'Sunday' }}
{{ } }}

{{
tidy { 'C:\ProgramData\os_patching': }}
{{    age => '1w', }}
{{    matches => '*.log', }}
{{    recurse => true, }}
{{    schedule => 'cleanup_window' }}
{{ } }}
Add Comment Add Comment
 

Michael Luck (Jira)

unread,
Oct 6, 2020, 3:04:04 PM10/6/20
to puppe...@googlegroups.com
Michael Luck updated an issue
When using schedule and recurse with the tidy resource, it will apply on every Puppet run rather than adhering to the given schedule. For example, I run this tidy resource to clean up log files on some Windows agents. I expected it to only run on Sundays as indicated by the schedule but it will execute on every Puppet run instead.

 
{code:java}

schedule { 'cleanup_window':
weekday => 'Sunday'
}


tidy { 'C:\ProgramData\os_patching':
age => '1w',
matches => '*.log',
recurse => true,
schedule => 'cleanup_window'
}

{code}
 

Josh Cooper (Jira)

unread,
Oct 14, 2020, 1:49:03 PM10/14/20
to puppe...@googlegroups.com
Josh Cooper commented on Bug PUP-10688
 
Re: tidy resource does not honor schedule metaparameter

I can't reproduce this:

 

C:\Users\josh\projects\puppet>type tidy.pp
schedule { 'cleanup_window':
  weekday     => 'Sunday'
}
 
tidy { 'C:\tmp\tidy':
  age         => '1w',
  matches     => '*.log',
  recurse     => true,
  schedule    => 'cleanup_window'
}
C:\Users\josh\projects\puppet>bundle exec puppet apply --debug tidy.pp
...
Debug: Creating default schedules
Debug: Loaded state in 0.01 seconds
Debug: Loaded state in 0.00 seconds
Info: Applying configuration version '1602697593'
Debug: /Stage[main]/Main/Tidy[C:\tmp\tidy]: Not scheduled
Debug: /Stage[main]/Main/Tidy[C:\tmp\tidy]: Resource is being skipped, unscheduling all events
...
C:\Users\josh\projects\puppet>dir c:\tmp\tidy\app.log
 Volume in drive C has no label.
 Volume Serial Number is 0CEE-A705
 
 Directory of c:\tmp\tidy
 
10/14/2020  10:43 AM             2,821 app.log

Michael Luck (Jira)

unread,
Oct 14, 2020, 2:12:03 PM10/14/20
to puppe...@googlegroups.com
Michael Luck commented on Bug PUP-10688

Josh Cooper  That is interesting...here is my output from Puppet DB. It should only be running on Sundays but it is not for some reason.

 

Oct 14 2020 - 14:03:41 /Stage[main]/Windows_patch_mgmt/Tidy[C:\ProgramData\os_patching] notice, tidy, class, windows_patch_mgmt, node, default Tidying 1 files /etc/puppetlabs/code/environments/production/manifests/patch_mgmt.pp:84
Oct 14 2020 - 14:04:40 /Stage[main]/Windows_patch_mgmt/File[C:/ProgramData/os_patching/os_patching_fact_generation-2020_10_07-13_46_02.log]/ensure notice, file, tidy, class, windows_patch_mgmt, node, default removed  
Oct 14 2020 - 14:06:59 Puppet notice Applied catalog in 198.57 seconds

Michael Luck (Jira)

unread,
Oct 14, 2020, 2:41:03 PM10/14/20
to puppe...@googlegroups.com
Michael Luck commented on Bug PUP-10688

Josh Cooper Ran some debug runs on two computers...looks like it works properly on one  but not another.

 

Computer A:

...
←[0;36mDebug: Loaded state in 0.02 seconds←[0m
←[0;36mDebug: /Stage[main]/Windows_patch_mgmt2/Tidy[C:\ProgramData\os_patching]: Tidying File[C:/ProgramData/os_patching/os_patching_fact_generation-2020_10_08-01_48_45.log]←[0m
←[0;36mDebug: /Stage[main]/Windows_patch_mgmt2/Tidy[C:\ProgramData\os_patching]: Tidying File[C:/ProgramData/os_patching/os_patching_fact_generation-2020_10_08-13_46_10.log]←[0m
←[mNotice: /Stage[main]/Windows_patch_mgmt2/Tidy[C:\ProgramData\os_patching]: Tidying 2 files←[0m
←[0;36mDebug: Loaded transaction store file in 0.04 seconds←[0m
←[0;32mInfo: Applying configuration version '1602700361'←[0m
...

 

Computer B:

...
Debug: /Stage[main]/Windows_patch_mgmt2/Tidy[C:\ProgramData\InstalledUpdates]: Not scheduled
Debug: /Stage[main]/Windows_patch_mgmt2/Tidy[C:\ProgramData\InstalledUpdates]: Resource is being skipped, unscheduling all events
Debug: /Stage[main]/Windows_patch_mgmt2/Tidy[C:\ProgramData\os_patching]: Not scheduled
Debug: /Stage[main]/Windows_patch_mgmt2/Tidy[C:\ProgramData\os_patching]: Resource is being skipped, unscheduling all events
...

Add Comment Add Comment
 

Lukas Erlacher (Jira)

unread,
Aug 23, 2022, 1:40:02 AM8/23/22
to puppe...@googlegroups.com

Hi,

I am using puppet 6 open source and just ran into this issue.

 

My usecase is cleaning up old puppet report files. We have a large number of clients so cleaning up the report files creates a lot of log spam that I want to contain.

 

This is my puppet code:

 

 

  schedule { 'daily tidy':
    period => daily,
    range  => '2-3',
  }
  tidy { '/opt/puppetlabs/server/data/puppetserver/reports':
    recurse  => true,
    age      => '90d',
    type     => mtime,
    schedule => 'daily tidy',
  }

 

This is the output:

 

Debug: /Stage[main]/XXX::Profile::Puppetserver/File[/opt/puppetlabs/server/data/puppetserver/reports/infra-mgmt1.XXX.aws.XXX.net/202205250422.yaml]: Removing existing file for replacement with absent
Notice: /Stage[main]/XXX::Profile::Puppetserver/File[/opt/puppetlabs/server/data/puppetserver/reports/infra-mgmt1.XXX.aws.XXX.net/202205250422.yaml]/ensure: removed
Debug: /Stage[main]/XXX::Profile::Puppetserver/File[/opt/puppetlabs/server/data/puppetserver/reports/infra-mgmt1.XXX.aws.XXX.net/202205250422.yaml]: The container Class[XXX::Profile::Puppetserver] will propagate my refresh event
Debug: /Stage[main]/XXX::Profile::Puppetserver/Tidy[/opt/puppetlabs/server/data/puppetserver/reports]: Not scheduled
Debug: /Stage[main]/XXX::Profile::Puppetserver/Tidy[/opt/puppetlabs/server/data/puppetserver/reports]: Resource is being skipped, unscheduling all events  

 

I've managed to reproduce this on puppet 6.18 and 6.28.

This message was sent by Atlassian Jira (v8.20.11#820011-sha1:0629dd8)
Atlassian logo

Morgan Rhodes (Jira)

unread,
Aug 30, 2022, 4:29:03 PM8/30/22
to puppe...@googlegroups.com

Lukas Erlacher (Jira)

unread,
Sep 5, 2022, 10:53:02 PM9/5/22
to puppe...@googlegroups.com
 
Re: tidy resource does not honor schedule metaparameter

Are there any hacky workarounds for this, something like switching it to {{noop }}based on current time?

Lukas Erlacher (Jira)

unread,
Oct 16, 2022, 9:09:03 PM10/16/22
to puppe...@googlegroups.com

Poking this again since this is still an issue. Is anyone reading this?

 

I tracked down the code: https://github.com/puppetlabs/puppet/blob/eb498be4bf7b4dbb326dbd479d01101f0b226abb/lib/puppet/type/tidy.rb#L243

 

And the root cause seems to be that the only metaparameter that is inherited into the file-to-delete resources is `noop`: https://github.com/puppetlabs/puppet/blob/eb498be4bf7b4dbb326dbd479d01101f0b226abb/lib/puppet/type/tidy.rb#L250

 

So, the `schedule` metaparameter should be added there, and more broadly, it should be checked whether other metaparameters should be added too.

Josh Cooper (Jira)

unread,
Oct 18, 2022, 12:26:03 PM10/18/22
to puppe...@googlegroups.com
Josh Cooper commented on Bug PUP-10688

Lukas Erlacher yes in general metaparameters should be copied from the parent to the child resource, except for the "alias" metaparameter. See my comment in https://tickets.puppetlabs.com/browse/PUP-11631?focusedCommentId=876236&page=com.atlassian.jira.plugin.system.issuetabpanels%3Acomment-tabpanel#comment-876236 and related ticket PUP-10688.

Morgan Rhodes (Jira)

unread,
Oct 19, 2022, 5:47:03 PM10/19/22
to puppe...@googlegroups.com

Josh Cooper (Jira)

unread,
Oct 26, 2022, 1:51:03 PM10/26/22
to puppe...@googlegroups.com
Josh Cooper updated an issue
Change By: Josh Cooper
Sprint: Phoenix 2022-11- 09 23

Josh Cooper (Jira)

unread,
Oct 26, 2022, 1:52:02 PM10/26/22
to puppe...@googlegroups.com

Josh Cooper (Jira)

unread,
Oct 27, 2022, 12:57:02 PM10/27/22
to puppe...@googlegroups.com
Josh Cooper updated an issue
Change By: Josh Cooper
Sprint: Phoenix 2022-11-23

Morgan Rhodes (Jira)

unread,
Nov 10, 2022, 1:09:01 PM11/10/22
to puppe...@googlegroups.com

Morgan Rhodes (Jira)

unread,
Nov 10, 2022, 1:09:01 PM11/10/22
to puppe...@googlegroups.com
Morgan Rhodes updated an issue
Change By: Morgan Rhodes
Sprint: Phoenix 2022-12-7

Josh Cooper (Jira)

unread,
Nov 15, 2022, 12:26:02 PM11/15/22
to puppe...@googlegroups.com
Josh Cooper commented on Bug PUP-10688
 
Re: tidy resource does not honor schedule metaparameter

This should be trivial to fix now that PUP-11631 is resolved.

Michael Hashizume (Jira)

unread,
Nov 28, 2022, 4:44:03 PM11/28/22
to puppe...@googlegroups.com

Lukas Erlacher (Jira)

unread,
Nov 28, 2022, 9:52:01 PM11/28/22
to puppe...@googlegroups.com
Lukas Erlacher commented on Bug PUP-10688
 
Re: tidy resource does not honor schedule metaparameter

I am very glad to see this has been picked up!

Josh Cooper (Jira)

unread,
Mar 9, 2023, 6:05:02 PM3/9/23
to puppe...@googlegroups.com
Josh Cooper updated an issue
Change By: Josh Cooper
Fix Version/s: PUP 7.21.0
Reply all
Reply to author
Forward
0 new messages