gjcarneiro / yacron

A modern Cron replacement that is Docker-friendly
MIT License
449 stars 38 forks source link

AttributeError: 'str' object has no attribute 'matchers' #35

Closed pirate closed 4 years ago

pirate commented 4 years ago

Description

I'm trying to run this jobfile in /etc/yacron.d/jobs.yaml:

web:
  listen:
    - http://127.0.0.1:8000
    - unix:///tmp/yacron.sock

defaults:
  shell: /bin/bash
  utc: false
  captureStdout: true
  captureStderr: true
  onFailure:
    report:
      mail:
        from: redacted-src@example.com
        to: redacted-dst@example.com
        smtpHost: mail.example.com
    retry:
      maximumRetries: 3
      initialDelay: 600
      maximumDelay: 9600
      backoffMultiplier: 2

jobs:
  - name: rsnapshot-hourly
    command: /usr/bin/rsnapshot hourly
    schedule: "0 */6 * * *"
    # every 6 hours

  - name: rsnapshot-daily
    command: /usr/bin/rsnapshot daily
    schedule: "0 2 * * *"
    # 2am every day

  - name: rsnapshot-weekly
    command: /usr/bin/rsnapshot weekly
    schedule: "0 5 * * 0"
    # 5am sunday every week

  - name: rsnapshot-monthly
    command: /usr/bin/rsnapshot monthly
    schedule: "0 6 1 * *"
    # 6am on the first of every month

  - name: zsnapshot-Monadical
    command: ssh pumpkin '/usr/sbin/zfs snapshot "ssd-pumpkin/Monadical@"'$(date +"%Y-%m-%d_%H-%M")
    schedule: "0 0 */3 * *"

  - name: zsnapshot-opt
    command: ssh pumpkin '/usr/sbin/zfs snapshot "ssd-pumpkin/opt@"'$(date +"%Y-%m-%d_%H-%M")'
    schedule: "0 0 */3 * *"

stout & stderr

Output from /yacron/bin/yacron:

yacron_1  | INFO:yacron:web: started listening on http://127.0.0.1:8000
yacron_1  | INFO:yacron:web: started listening on unix:///tmp/yacron.sock
yacron_1  | Traceback (most recent call last):
yacron_1  |   File "/yacron/bin/yacron", line 8, in <module>
yacron_1  |     sys.exit(main())
yacron_1  |   File "/yacron/lib/python3.7/site-packages/yacron/__main__.py", line 56, in main
yacron_1  |     main_loop(_loop)
yacron_1  |   File "/yacron/lib/python3.7/site-packages/yacron/__main__.py", line 43, in main_loop
yacron_1  |     loop.run_until_complete(cron.run())
yacron_1  |   File "/usr/lib/python3.7/asyncio/base_events.py", line 579, in run_until_complete
yacron_1  |     return future.result()
yacron_1  |   File "/yacron/lib/python3.7/site-packages/yacron/cron.py", line 123, in run
yacron_1  |     await self.spawn_jobs(startup)
yacron_1  |   File "/yacron/lib/python3.7/site-packages/yacron/cron.py", line 247, in spawn_jobs
yacron_1  |     if startup and job.schedule == "@reboot":
yacron_1  |   File "/yacron/lib/python3.7/site-packages/crontab/_crontab.py", line 389, in __eq__
yacron_1  |     match_last = self.matchers[1:] == other.matchers[1:]
yacron_1  | AttributeError: 'str' object has no attribute 'matchers'
yacron_1  | ERROR:asyncio:Task was destroyed but it is pending!
yacron_1  | task: <Task pending coro=<Cron._wait_for_running_jobs() running at /yacron/lib/python3.7/site-packages/yacron/cron.py:321> wait_for=<Future pending cb=[<TaskWakeupMethWrapper object at 0x7f7e0a3b38d0>()]>>
yacron_1  | ERROR:asyncio:Task was destroyed but it is pending!
yacron_1  | task: <Task pending coro=<Event.wait() running at /usr/lib/python3.7/asyncio/locks.py:293> wait_for=<Future pending cb=[<TaskWakeupMethWrapper object at 0x7f7e0a3fb0d0>()]> cb=[_release_waiter(<Future pendi...e0a3b38d0>()]>)() at /usr/lib/python3.7/asyncio/tasks.py:392]>
gjcarneiro commented 4 years ago

Yes, I've noticed this yesterday, seems to be some incompatible release of the crontab python package. In master (d7d51b493fc2462df6de3fd40adf59b1bf88361d), I've made yacron pin the version of crontab to an older known to be working version 0.22.6.

If you install yacron like this, it should work:

pip install crontab==0.22.6 yacron
gjcarneiro commented 4 years ago

I released version 0.10.1 with the install requirement fix.