Bug #775

Cron resources being deleted still require a command.

Added by Matt Palmer almost 5 years ago. Updated 9 months ago.

Status:Closed Start date:
Priority:High Due date:
Assignee:- % Done:

0%

Category:cron
Target version:2.7.3
Affected Puppet version:2.6.4 Branch:
Keywords:
Votes: 5

Description

A resource spec like this:

cron { run_update_etc_puppet:
    ensure => absent,
    user => root
}

Results in an error like this on every Puppet run under 0.23.2:

err: //hostname/class/Cron[run_update_etc_puppet]: Failed to retrieve current state of resource: No command, somehow at /etc/puppet/manifests/classes/class.pp:20

I’m fairly certain that error didn’t appear in 0.22.4, otherwise I would have reported it then, too.


Related issues

duplicated by Puppet - Bug #6593: Cron loses track of crontab easily, results in duplicates Duplicate 03/04/2011
duplicates Puppet - Bug #3368: Cron names/titles not unique between users Duplicate 03/15/2010
duplicated by Puppet - Bug #2144: issue with cron type on ubuntu Duplicate 04/08/2009
blocks Puppet - Bug #6990: Rehabilitate cron provider Accepted 04/06/2011

History

Updated by Luke Kanies over 4 years ago

This is not because you have ensure => absent, it’s because you haven’t specified a command.

It’s reasonable to expect that you could delete a resource without specifying the command, so this is still a bug, but it’s quite different from saying that you can’t delete cron resources.

Updated by Luke Kanies over 4 years ago

I’m delaying this until someone feels like working on it.

Updated by Redmine Admin almost 4 years ago

  • Status changed from 1 to Accepted

Updated by Rob Terhaar over 2 years ago

I just got bit by this bug in 0.25.1

Updated by Rob Terhaar over 2 years ago

  • Affected Puppet version changed from 0.24.8 to 0.25.1

just a note, this bug caused puppetd to install multiple, redundant, non-related crontabs

Updated by Luke Kanies over 2 years ago

Can you explain how a bug in cron job deletion caused multiple crontabs to be installed? I’m a bit confused.

Updated by achemze - about 2 years ago

I’ve also hit this bug. I actually had it duplicate the crontabs 2-3 times, in its entirety. So all 6 cronjobs existed, in the same chunk 3 times.

Updated by Luke Kanies about 2 years ago

  • Assignee deleted (Luke Kanies)

Updated by Dan Carley almost 2 years ago

Likewise, I’ve hit this.

Seemed to run fine for a while with the following:

class someclass {
    # TODO: Delete this later.
    crontab { "something":
        ensure => absent,
    }
}

Only upon changing environment did it start throwing the error:

err: Could not prefetch cron provider 'crontab': No command, somehow at [..]

As reported by two of the other commentators, a side effect was that crontab resources from outside of someclass were incorrectly identified as being absent and thus created duplicates.

Updated by donavan m over 1 year ago

  • Affected Puppet version changed from 0.25.1 to 2.6.4

This bug is trivially reproducible on 2.6.4 for both CentOS 5.5 and Darwin 10.6. The issue occurs when puppet encounters an unmanaged puppet cron resource while a resource like Cron[first]{ ensure => 'absent' } is in the catalog.

To elaborate on note 1 the cron type will delete a resource without a command parameter:

# /tmp/cron_present.pp
cron { "first": command => 'true' }
# /tmp/cron_absent.pp
cron { "first": ensure => 'absent' }
tmp donavanm$ sudo puppet apply /tmp/cron_present.pp 
notice: /Stage[main]//Cron[first]/ensure: created
# verify creation with crontab -l
tmp donavanm$ sudo puppet apply /tmp/cron_absent.pp 
notice: /Stage[main]//Cron[first]/ensure: removed
# verify absence with crontab -l

To reproduce start with an empty crontab. Apply a catalog to create our ‘first’ resource.

tmp donavanm$ sudo puppet apply /tmp/cron_present.pp 
notice: /Stage[main]//Cron[first]/ensure: created

Apply a second catalog, that does not manage the “first” entry, with an invalid cron resource.

# /tmp/cron_absent.pp
cron { "second": ensure => 'absent' }
tmp donavanm$ sudo puppet apply /tmp/cron_absent.pp 
err: Could not prefetch cron provider 'crontab': No command, somehow at /tmp/cron_absent.pp:1

Updated by donavan m over 1 year ago

I also believe the issue should be re prioritized. I can demonstrate the creation of infinite* duplicate cron resources.

Duplicate cron entries are created for each resource which follows the “invalid” resource in the catalog. Starting with our last crontab which contains an unmanaged resource:

# HEADER: This file was autogenerated at Thu Feb 10 00:59:17 -0800 2011 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: first
* * * * * true first

Attempt to apply a catalog with an “invalid” resource followed by a valid resource

# /tmp/cron_dupe.pp
cron { "second": ensure => 'absent';
       "third": command => 'true third' }
tmp donavanm$ sudo puppet apply /tmp/cron_dupe.pp 
err: Could not prefetch cron provider 'crontab': No command, somehow at /tmp/cron_dupe.pp:2
notice: /Stage[main]//Cron[third]/ensure: created
tmp donavanm$ sudo puppet apply /tmp/cron_dupe.pp 
err: Could not prefetch cron provider 'crontab': No command, somehow at /tmp/cron_dupe.pp:2
notice: /Stage[main]//Cron[third]/ensure: created
tmp donavanm$ sudo puppet apply /tmp/cron_dupe.pp 
err: Could not prefetch cron provider 'crontab': No command, somehow at /tmp/cron_dupe.pp:2
notice: /Stage[main]//Cron[third]/ensure: created

And verify duplicate cron entries:

mbp:tmp donavanm$ sudo crontab -l
# HEADER: This file was autogenerated at Thu Feb 10 01:41:12 -0800 2011 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: first
* * * * * true first
# Puppet Name: third
* * * * * true third
# Puppet Name: third
* * * * * true third
# Puppet Name: third
* * * * * true third

* Or, more than I care to count.

Updated by James Turnbull about 1 year ago

  • Status changed from Accepted to Needs Decision
  • Assignee set to Nigel Kersten
  • Target version deleted (4)

Nigel – in light of Donovan’s comment below – can you consider priority and status please.

Updated by Nigel Kersten about 1 year ago

  • Status changed from Needs Decision to Accepted
  • Assignee deleted (Nigel Kersten)
  • Priority changed from Low to High
  • Target version set to 2.6.x

Updated by Nigel Kersten about 1 year ago

We may need to make some backwards-incompatible changes here.

We’re inconsistent about our reliance upon the “Puppet Name:” line it seems.

Digging more.

Updated by Nigel Kersten about 1 year ago

  • Status changed from Accepted to Duplicate

Multiple entries issue is duplicated in #3010

Updated by Nigel Kersten about 1 year ago

  • Status changed from Duplicate to Accepted

(messed up duplicate relationship)

Updated by Nick Lewis about 1 year ago

  • Status changed from Accepted to Merged - Pending Release

A fix for this is available in next in commit:8778307ca33a637fe10b601ee737628f2e5f9fbf.

Updated by James Turnbull about 1 year ago

  • Target version changed from 2.6.x to 2.7.x

Updated by James Turnbull 9 months ago

  • Target version changed from 2.7.x to 2.7.3

Updated by James Turnbull 9 months ago

  • Status changed from Merged - Pending Release to Closed

Also available in: Atom PDF