saltstack / saltstack/salt

[BUG] Cron state breaks on cronjobs with identical commands but unique identifier

Open
#61,194 2 comments 0 reactions 1 assignee View on GitHub

@dwoz is already working on this.

Since Nov 7, 2021.

bug Regression severity-medium
Dominant language
Python
Stars
15.7k
Forks
5.6k
Avg merge
2d 44m
Merged PRs (30d)
80

Description

Description
Cron state is breaking on multiple identical commands to be executed at different times, despite the identifier being different, which (as per https://github.com/saltstack/salt/issues/7979) should differentiate the commands from one another.

Setup
SLS:

# Cron jobs.
#
# Remarks:
# - rtcwake does not need a -t prefix via logger.
#
# TODO
# - xx
# - xx
# - xx


include:
  - cron

# System availibility

/usr/sbin/rtcwake -m off --date 06:45 2>&1 | /usr/bin/logger:
  cron.present:
  - identifier: rtcwake.cron
  - minute: '30'
  - hour: '01'
  - dayweek: '1-5'
  - comment: Shut down at 01:30 and bring up at 06:45 on weekdays


# Dagelijkse snapshots en synchronisatie naar Amalthea.

/sbin/zfs snapshot ichi/work@"$(/bin/date +\%Y\%m\%d)"| /usr/bin/logger -t zfs-snapshot:
  cron.present:
  - identifier: zfs.snapshot.cron
  - minute: '55'
  - hour: '23'
  - dayweek: '*'
  - comment: Create daily snapshot

/usr/local/sbin/zfs-snapshot-backup compress | /usr/bin/logger -t zfs-snapshot-backup:
  cron.present:
  - identifier: zfs.snapshot.compress.cron
  - minute: '05'
  - hour: '00'
  - dayweek: '*'
  - comment: Create compressed deltas

/usr/local/sbin/zfs-snapshot-backup post | /usr/bin/logger -t zfs-snapshot-backup:
  cron.present:
  - identifier: zfs.snapshot.post.cron
  - user: xyz
  - minute: '45'
  - hour: '07'
  - dayweek: '*'
  - comment: Backup verification

# Weekly local backups with reminders about timeframe

/usr/local/sbin/zfs-snapshot-backup warn | /usr/bin/logger -t zfs-snapshot-backup:
  cron.present:
  - identifier: zfs.snapshot.local.friday.warn.cron
  - minute: '55'
  - hour: '18'
  - dayweek: '5'
  - comment: Weekly local eS-ATA backup (reminder)

/usr/local/sbin/zfs-snapshot-backup local | /usr/bin/logger -t zfs-snapshot-backup:
  cron.present:
  - identifier: zfs.snapshot.local.friday.cron
  - minute: '00'
  - hour: '19'
  - dayweek: '5'
  - comment: Weekly local eS-ATA backup (reminder)

/usr/local/sbin/zfs-snapshot-backup warn | /usr/bin/logger -t zfs-snapshot-backup:
  cron.present:
  - identifier: zfs.snapshot.local.saturday.warn.cron
  - minute: '55'
  - hour: '07'
  - dayweek: '6'
  - comment: Weekly local eS-ATA backup (saturday)

/usr/local/sbin/zfs-snapshot-backup local | /usr/bin/logger -t zfs-snapshot-backup:
  cron.present:
  - identifier: zfs.snapshot.local.saturday.cron
  - minute: '00'
  - hour: '08'
  - dayweek: '6'
  - comment: Weekly local eS-ATA backup (saturday)


# Bi-weekly scrub.

/usr/local/sbin/zpm scrub | /usr/bin/logger -t zfs-scrub:
  cron.present:
  - identifier: zfs.scrub.cron
  - minute: '35'
  - hour: '01'<summary>
  - dayweek: '6'
  - comment: Bi-weekly scrub

/usr/local/sbin/zpm report | /usr/bin/logger -t zfs-scrub:
  cron.present:
  - identifier: zfs.scrub.report.cron
  - minute: '30'
  - hour: '16'
  - dayweek: '6'
  - comment: Mail bi-weekly scrub results


# Daily restart for Salt client.

/bin/systemctl restart salt-minion.service:
  cron.present:
  - identifier: salt.restart.daily.cron
  - minute: '00'
  - hour: '18'
  - dayweek: '*'
  - comment: Daily restart

Please be as specific as possible and give set-up details.

  • [x ] on-prem machine (Debian 11, Salt 3002.6)
  • VM (Virtualbox, KVM, etc. please specify)
  • VM running on a cloud service, please be explicit and add details
  • container (Kubernetes, Docker, containerd, etc. please specify)
  • or a combination, please be explicit
  • jails if it is FreeBSD

Steps to Reproduce the behavior
Create cron state file with identical commands, but with different identifiers (and optionally timestamps for execution).

Expected behavior
Salt not breaking. This worked on older releases.

Versions Report

salt --versions-report (Provided by running salt --versions-report. Please also mention any differences in master/minion versions.)
Salt Version:
          Salt: 3002.6
 
Dependency Versions:
          cffi: Not Installed
      cherrypy: Not Installed
      dateutil: 2.8.1
     docker-py: Not Installed
         gitdb: Not Installed
     gitpython: Not Installed
        Jinja2: 2.11.3
       libgit2: 1.1.0
      M2Crypto: Not Installed
          Mako: 1.1.3
       msgpack: 1.0.0
  msgpack-pure: Not Installed
  mysql-python: Not Installed
     pycparser: Not Installed
      pycrypto: 2.6.1
  pycryptodome: 3.9.7
        pygit2: 1.4.0
        Python: 3.9.2 (default, Feb 28 2021, 17:03:44)
  python-gnupg: Not Installed
        PyYAML: 5.3.1
         PyZMQ: 20.0.0
         smmap: Not Installed
       timelib: Not Installed
       Tornado: 4.5.3
           ZMQ: 4.3.4
 
System Versions:
          dist: debian 11 bullseye
        locale: utf-8
       machine: x86_64
       release: 5.10.0-9-amd64
        system: Linux
       version: Debian GNU/Linux 11 bullseye

Additional context
Error spit out is this:

porphyrion.srv:
    Data failed to compile:
----------
    Rendering SLS 'base:cron.porphyrion' failed: while constructing a mapping
  in "<unicode string>", line 12, column 1
found conflicting ID '/usr/local/sbin/zfs-snapshot-backup warn | /usr/bin/logger -t zfs-snapshot-backup'
  in "<unicode string>", line 71, column 1

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.