diff options
author | Seth Foster <fosterseth@users.noreply.github.com> | 2024-12-11 17:14:58 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-12-11 17:14:58 +0100 |
commit | e605883592aa996ac65eceab3abc3106ab212e14 (patch) | |
tree | 451aec23de7905a8543bc646bb9fb6bed9303940 | |
parent | Use runtime log utility moved to DAB (#15675) (diff) | |
download | awx-e605883592aa996ac65eceab3abc3106ab212e14.tar.xz awx-e605883592aa996ac65eceab3abc3106ab212e14.zip |
Do not fast forward rrule if count is set (#15696)
Fixes a bug where a schedule that was created
to run only once will continue to run repeatedly.
e.g. an rrule with
dtstart 20240730; count 1; freq MINUTELY
This job will run on 20240730, and should never
run again.
However, the next time the schedule
update_computed_fields runs, the dtstart
will fast forward to today's date, and
next_run will be computed from that. This will trigger
the job to run again, which is not intended.
If count is set, we just should not fast forward the
rrule and always calculate next_run based on original
dtstart.
Signed-off-by: Seth Foster <fosterbseth@gmail.com>
-rw-r--r-- | awx/main/models/schedules.py | 3 | ||||
-rw-r--r-- | awx/main/tests/unit/utils/test_schedule_fast_forward.py | 6 |
2 files changed, 9 insertions, 0 deletions
diff --git a/awx/main/models/schedules.py b/awx/main/models/schedules.py index 046a08a2e8..051305803c 100644 --- a/awx/main/models/schedules.py +++ b/awx/main/models/schedules.py @@ -64,6 +64,9 @@ def _fast_forward_rrule(rrule, ref_dt=None): if rrule._freq not in {dateutil.rrule.HOURLY, dateutil.rrule.MINUTELY}: return rrule + if rrule._count: + return rrule + if ref_dt is None: ref_dt = now() diff --git a/awx/main/tests/unit/utils/test_schedule_fast_forward.py b/awx/main/tests/unit/utils/test_schedule_fast_forward.py index 48ce4b6612..075e485b07 100644 --- a/awx/main/tests/unit/utils/test_schedule_fast_forward.py +++ b/awx/main/tests/unit/utils/test_schedule_fast_forward.py @@ -115,6 +115,12 @@ def test_future_date_does_not_fast_forward(): assert new_rrule == rrule +def test_rrule_with_count_does_not_fast_forward(): + rrule = dateutil.rrule.rrule(freq=MINUTELY, interval=5, count=1, dtstart=REF_DT) + + assert rrule == _fast_forward_rrule(rrule, ref_dt=REF_DT) + + @pytest.mark.parametrize( ('freq', 'interval'), [ |