Jira (PUP-10120) resources cron purge fails iff title != name

4 views
Skip to first unread message

Maximilian Philipps (JIRA)

unread,
Nov 5, 2019, 7:21:03 AM11/5/19
to puppe...@googlegroups.com
Maximilian Philipps created an issue
 
Puppet / Bug PUP-10120
resources cron purge fails iff title != name
Issue Type: Bug Bug
Assignee: Unassigned
Components: Catalog Application
Created: 2019/11/05 4:20 AM
Priority: Normal Normal
Reporter: Maximilian Philipps

Puppet Version: 6.10.1-1stretch**
OS Name/Version: Debian stretch

hi,

I just discovered some duplicated crontab entries and then after some debugging found that resources cron purge ignores the name of the cron resources.

 

Reproduction:

puppet apply the following:

resources { 'cron':
  purge => true
}
cron { 'foo1':
  command => '/bin/true'
, hour  => 3
, minute => 3
}

Actual and expected behavior:

Puppet removes all crontab entries and creates the foo1 entry.

# HEADER: This file was autogenerated at 2019-11-05 12:57:26 +0100 by puppet.
# HEADER: While it can still be managed manually, it is definitely not recommended.
# HEADER: Note particularly that the comments starting with 'Puppet Name' should
# HEADER: not be deleted, as doing so could cause duplicate cron jobs.
# Puppet Name: foo1
3 3 * * * /bin/true

now apply the following:

resources { 'cron':
 purge => true
}
cron { 'foo1':
 command => '/bin/true'
, hour => 3
, minute => 3
, name => 'foo2'
}

 

Actual behavior:

Puppet just adds the new foo2 cron entry.

# HEADER: This file was autogenerated at 2019-11-05 12:57:26 +0100 by puppet.
# HEADER: While it can still be managed manually, it is definitely not recommended.
# HEADER: Note particularly that the comments starting with 'Puppet Name' should
# HEADER: not be deleted, as doing so could cause duplicate cron jobs.
# Puppet Name: foo1
3 3 * * * /bin/true
# Puppet Name: foo2
3 3 * * * /bin/true

Expected behavior:

Puppet also removes the foo1 entry since no cron resource with that name exists in the catalog.

Add Comment Add Comment
 
This message was sent by Atlassian JIRA (v7.7.1#77002-sha1:e75ca93)
Atlassian logo

Josh Cooper (JIRA)

unread,
Nov 5, 2019, 12:53:03 PM11/5/19
to puppe...@googlegroups.com
Josh Cooper commented on Bug PUP-10120
 
Re: resources cron purge fails iff title != name

This occurs because when foo2 is added to the catalog, puppet adds a resource reference based on the title foo1 and its aliases (based on its namevars, in this case foo2):

(byebug) catalog.resource_refs.grep /Cron/
["Cron[foo1]", "Cron[foo2]"]

Since the crontab contains entries for foo1 and foo2, nothing is purged. However, if you had foo3 in the crontab, it would be purged.

For this issue, I don't think it's fair to say puppet fails to purge the resource when the title != name. Instead, puppet can't purge the resource if there is an existing entry whose namevar(s) match the title of a resource we are managing.

This is related to PUP-10108, though it's slightly different. In this case, I don't think we should check if the resource (as obtained from the system) matches the title of a resource in the catalog. Instead we should only compare based on the resources' uniqueness key. But I'd need to research more to be sure that's safe.

Reply all
Reply to author
Forward
0 new messages