Skip to content
This repository has been archived by the owner on Oct 9, 2023. It is now read-only.

Added start time for supporting restarts for fixed rate schedules #476

Merged
merged 10 commits into from
May 8, 2023

Conversation

pmahindrakar-oss
Copy link
Contributor

@pmahindrakar-oss pmahindrakar-oss commented Sep 15, 2022

Signed-off-by: Prafulla Mahindrakar [email protected]

TL;DR

  • Updated the cron library to accept startTime for timedJob
  • Using the lastExecution time when starting the fixed rate schedules

Testing Done:

  • Registered the fixed rate schedule for 1 min rate
  • Brought down the scheduler for a few hours
  • Verified the catch up routine ran and caught up to current time using the last Execution timestamp
  • Also verified the new routines are also respecting the last execution time

Type

  • Bug Fix
  • Feature
  • Plugin

Are all requirements met?

  • Code completed
  • Smoke tested
  • Unit tests added
  • Code documentation added
  • Any pending items have an associated Issue

Complete description

How did you fix the bug, make the feature etc. Link to any design docs etc

Tracking Issue

Remove the 'fixes' keyword if there will be multiple PRs to fix the linked issue

fixes flyteorg/flyte#2885

Follow-up issue

@katrogan
Copy link
Contributor

can you add a tracking issue?

Copy link
Contributor

@katrogan katrogan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

btw is this ready for review?

@pmahindrakar-oss
Copy link
Contributor Author

@katrogan yes it ready for review

@codecov
Copy link

codecov bot commented Sep 16, 2022

Codecov Report

Merging #476 (64b34b4) into master (00915ec) will increase coverage by 1.29%.
The diff coverage is n/a.

❗ Current head 64b34b4 differs from pull request most recent head 2c215a1. Consider uploading reports for the commit 2c215a1 to get more accurate results

@@            Coverage Diff             @@
##           master     #476      +/-   ##
==========================================
+ Coverage   58.64%   59.93%   +1.29%     
==========================================
  Files         172      168       -4     
  Lines       16365    13171    -3194     
==========================================
- Hits         9597     7894    -1703     
+ Misses       5920     4440    -1480     
+ Partials      848      837      -11     
Flag Coverage Δ
unittests ?

Flags with carried forward coverage won't be shown. Click here to find out more.

see 159 files with indirect coverage changes

Signed-off-by: Prafulla Mahindrakar <[email protected]>
Signed-off-by: Prafulla Mahindrakar <[email protected]>
Signed-off-by: pmahindrakar-oss <[email protected]>
Signed-off-by: pmahindrakar-oss <[email protected]>
katrogan
katrogan previously approved these changes Nov 9, 2022
@@ -271,7 +271,11 @@ func (g *GoCronScheduler) AddFixedIntervalJob(ctx context.Context, job *GoCronJo
var jobFunc cron.TimedFuncJob
jobFunc = job.Run

entryID := g.cron.ScheduleTimedJob(cron.ConstantDelaySchedule{Delay: d}, jobFunc)
var lastExecTime time.Time
if job.lastTime != nil {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: should this field name change to job.lastExecTime too?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changing this would mean maintaining backward compat. I will clean this up when i next make change to this file

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On second thought, the JobStore will get loaded again after new version, so it will start using the new field after the restart, so we don't have to worry about backward compat.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome, can you verify that there are indeed no problems on restart locally?

}
})

t.Run("without schedule time", func(t *testing.T) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sorry if I'm being dense - can you point out how this test differs than the one above?

Copy link
Contributor Author

@pmahindrakar-oss pmahindrakar-oss Nov 10, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

check L62 & L90,
The last Parameter to schedulerJob is different.
And also the assertion in timedFuncWithSchedule

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Refactored the test to remove redundant code which makes this test clearer

Signed-off-by: pmahindrakar-oss <[email protected]>
Signed-off-by: pmahindrakar-oss <[email protected]>
Signed-off-by: pmahindrakar-oss <[email protected]>
Signed-off-by: pmahindrakar-oss <[email protected]>
Signed-off-by: pmahindrakar-oss <[email protected]>
katrogan
katrogan previously approved these changes Nov 10, 2022
@eapolinario eapolinario self-requested a review as a code owner May 8, 2023 18:09
@eapolinario eapolinario merged commit 507ad44 into master May 8, 2023
@eapolinario eapolinario deleted the fixedrate-issue branch May 8, 2023 19:13
LaPetiteSouris pushed a commit to LaPetiteSouris/flyteadmin that referenced this pull request May 16, 2023
…yteorg#476)

* Added race skip check

Signed-off-by: Prafulla Mahindrakar <[email protected]>

* lint

Signed-off-by: Prafulla Mahindrakar <[email protected]>

* Fixed unit tests

Signed-off-by: pmahindrakar-oss <[email protected]>

* Moved to integration test

Signed-off-by: pmahindrakar-oss <[email protected]>

* refactored integration test

Signed-off-by: pmahindrakar-oss <[email protected]>

* nit : rename to lastTime

Signed-off-by: pmahindrakar-oss <[email protected]>

* nit : revert

Signed-off-by: pmahindrakar-oss <[email protected]>

* lastTime -> lastExecTime

Signed-off-by: pmahindrakar-oss <[email protected]>

* integration test tag

Signed-off-by: pmahindrakar-oss <[email protected]>

---------

Signed-off-by: Prafulla Mahindrakar <[email protected]>
Signed-off-by: pmahindrakar-oss <[email protected]>
Signed-off-by: eduardo apolinario <[email protected]>
Co-authored-by: eduardo apolinario <[email protected]>
Signed-off-by: TungHoang <[email protected]>
eapolinario added a commit that referenced this pull request Sep 6, 2023
* Added race skip check

Signed-off-by: Prafulla Mahindrakar <[email protected]>

* lint

Signed-off-by: Prafulla Mahindrakar <[email protected]>

* Fixed unit tests

Signed-off-by: pmahindrakar-oss <[email protected]>

* Moved to integration test

Signed-off-by: pmahindrakar-oss <[email protected]>

* refactored integration test

Signed-off-by: pmahindrakar-oss <[email protected]>

* nit : rename to lastTime

Signed-off-by: pmahindrakar-oss <[email protected]>

* nit : revert

Signed-off-by: pmahindrakar-oss <[email protected]>

* lastTime -> lastExecTime

Signed-off-by: pmahindrakar-oss <[email protected]>

* integration test tag

Signed-off-by: pmahindrakar-oss <[email protected]>

---------

Signed-off-by: Prafulla Mahindrakar <[email protected]>
Signed-off-by: pmahindrakar-oss <[email protected]>
Signed-off-by: eduardo apolinario <[email protected]>
Co-authored-by: eduardo apolinario <[email protected]>
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[BUG] [Flytescheduler] Fixed rate scheduler doesn't respect the initial startTime after a restart
3 participants