Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Service crashes when deltas include Month or Year #48

Open
bekriebel opened this issue Feb 6, 2018 · 0 comments
Open

Service crashes when deltas include Month or Year #48

bekriebel opened this issue Feb 6, 2018 · 0 comments
Labels

Comments

@bekriebel
Copy link
Contributor

If deltas include M (month) or Y (year), the service will crash as it is unable to sort the values. For example, using deltas: P1D P1W P1M P1Y will result in an error.

The appears to be because isodate uses a datetime.timedelta object for hours, days, and weeks - but uses a Duration object for months and years. deltas=[datetime.timedelta(1), datetime.timedelta(7), isodate.duration.Duration(0, 0, 0, years=0, months=1), isodate.duration.Duration(0, 0, 0, years=1, months=0)]

A workaround is to just use days or weeks to represent months/years (P30D/P365D), but being able to use the Month or Year designations would make the rules more readable.

At minimum, catching these values and throwing an understandable error would be helpful.

Full error:

2018-02-06T17:10:34.555553Z Unhandled exception in main task [k8s_snapshots.__main__] loop=<_UnixSelectorEventLoop running=False closed=False debug=False> main_task=<Task finished coro=<daemon() done, defined at /usr/local/lib/python3.6/site-packages/k8s_snapshots-0.0.0-py3.6.egg/k8s_snapshots/core.py:444> exception=TypeError("'<' not supported between instances of 'Duration' and 'datetime.timedelta'",)> message=Unhandled exception in main task severity=ERROR
Traceback (most recent call last):
  File "/usr/local/lib/python3.6/site-packages/k8s_snapshots-0.0.0-py3.6.egg/k8s_snapshots/__main__.py", line 58, in main
    loop.run_until_complete(main_task)
  File "/usr/local/lib/python3.6/asyncio/base_events.py", line 467, in run_until_complete
    return future.result()
  File "/usr/local/lib/python3.6/site-packages/k8s_snapshots-0.0.0-py3.6.egg/k8s_snapshots/core.py", line 469, in daemon
    await asyncio.gather(*tasks)
  File "/usr/local/lib/python3.6/site-packages/k8s_snapshots-0.0.0-py3.6.egg/k8s_snapshots/core.py", line 438, in backuper
    await make_backup(ctx, current_target_rule)
  File "/usr/local/lib/python3.6/site-packages/k8s_snapshots-0.0.0-py3.6.egg/k8s_snapshots/snapshot.py", line 148, in make_backup
    await expire_snapshots(ctx, rule)
  File "/usr/local/lib/python3.6/site-packages/k8s_snapshots-0.0.0-py3.6.egg/k8s_snapshots/snapshot.py", line 39, in expire_snapshots
    to_keep = expire(snapshots_with_date, rule.deltas)
  File "/usr/local/lib/python3.6/site-packages/tarsnapper/expire.py", line 57, in expire
    deltas.sort()
TypeError: '<' not supported between instances of 'Duration' and 'datetime.timedelta'
2018-02-06T17:10:34.565667Z Shutdown complete              [k8s_snapshots.__main__] message=Shutdown complete severity=INFO
Traceback (most recent call last):
  File "/usr/local/bin/k8s-snapshots", line 11, in <module>
    load_entry_point('k8s-snapshots==0.0.0', 'console_scripts', 'k8s-snapshots')()
  File "/usr/local/lib/python3.6/site-packages/k8s_snapshots-0.0.0-py3.6.egg/k8s_snapshots/__main__.py", line 58, in main
  File "/usr/local/lib/python3.6/asyncio/base_events.py", line 467, in run_until_complete
    return future.result()
  File "/usr/local/lib/python3.6/site-packages/k8s_snapshots-0.0.0-py3.6.egg/k8s_snapshots/core.py", line 469, in daemon
  File "/usr/local/lib/python3.6/site-packages/k8s_snapshots-0.0.0-py3.6.egg/k8s_snapshots/core.py", line 438, in backuper
  File "/usr/local/lib/python3.6/site-packages/k8s_snapshots-0.0.0-py3.6.egg/k8s_snapshots/snapshot.py", line 148, in make_backup
  File "/usr/local/lib/python3.6/site-packages/k8s_snapshots-0.0.0-py3.6.egg/k8s_snapshots/snapshot.py", line 39, in expire_snapshots
  File "/usr/local/lib/python3.6/site-packages/tarsnapper/expire.py", line 57, in expire
    deltas.sort()
TypeError: '<' not supported between instances of 'Duration' and 'datetime.timedelta'
@miracle2k miracle2k added the bug label Aug 31, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants