-
Notifications
You must be signed in to change notification settings - Fork 3.2k
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
feat: Support for scheduled Workflows with CronWorkflow CRD #1758
Conversation
@alexec Added tests and enhanced the e2e suite, please review |
Test failure:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Conditional approval - can you fix the broken test?
CronWorkflow("@testdata/basic-forbid.yaml"). | ||
When(). | ||
CreateCronWorkflow(). | ||
Wait(2 * time.Minute). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
anyway to reduce this time to <30s?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unfortunately, I don't think so. I need at least two cron cycles for this test, the least significant of which is a minute. I could mock the cron framework to run -- say -- every 15 seconds, but since we are dealing with k8s objects I worry that the short time might cause these tests to be flakey. To mediate the effects of this I decided to run these particular tests in parallel, so the entire cron test suite should take at most 3 minutes.
Let me know what you think.
@@ -62,6 +85,14 @@ func (w *When) WaitForWorkflow(timeout time.Duration) *When { | |||
} | |||
} | |||
|
|||
func (w *When) Wait(timeout time.Duration) *When { | |||
logCtx := log.WithFields(log.Fields{"test": w.t.Name(), "cron workflow": w.cronWorkflowName}) | |||
logCtx.Infof("Waiting for %s", humanize.Duration(timeout)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
would it be possible for this to wait until a condition is met and the exit (unless it timesout) - that way test might be faster
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I intended this to be a general wait
function, I think it could potentially be useful as is in the future.
W.r.t. the cron tests, see #1758 (comment)
Will fix. Seems like E2E tests are not excluded when running |
This comment was marked as resolved.
This comment was marked as resolved.
I don't actually see cron test running on CI. I think you need a block similar to this: |
So, I guess timezone configuration is, like for CronJob spec, not going to be supported ? :( |
I though I had replied, but clearly I never submitted it. And since there was another comment about timezone support added today by @rdigiorgio, I'll include what I wanted to say earlier: Use Case: Being able to schedule something periodically during, say business hours M-F using simple cron ranges when your business hours stradle UTC midnight. The patterns would be much simpler if you could evaluate them in the context of a specific timezone That said, it's pretty straightforward schedule a workflow to run every period, but start with a step workflow whose sole job can checks if the time is in a local timezone window and whose result is a conditional for continuing the workflow. It's not as efficient as being able to evaluate cron expressions in the context of a timezone, and results in a lot of noop workflows, but it works, as a workaround. |
Indeed, we can find plenty of workarounds, but it seems to be cumbersome and moreover, playing with infrastructure that can scale from 0 to X, it is sad to say "Ok let's run the workflow, wait for a node to span (GKE autoscale feature), the first step says that we should not go forward and abort the workflow, wait for the cluster to scale down" = pay extra bucks because CRON does not support timezones. By the way, I am nowhere near to know how "hard" it would be to implement on CronWorkflows, but I really thought this new feature would come bundled with timezones support and I would be able to drop all those K8S CronJobs |
@rdigiorgio Agreed. I was hoping that since argo-events supported timezone in the calendar event source, argo CronWorkflows might too. It looks like robfig/cron v3 now supports timezones. So perhaps implementing support for timezones isn't too hard to add...not that I have plans to take up go and implement the change. |
No reason timezone support can't be added in the future :) Opened to #1931 track this |
Sorry if the question seems stupid, but how does the scheduler work? Is there a single point of failure, or is it stable enough to keep running workflows even if a node goes down? |
The scheduler will be running as long as the |
Closes: #1229
Design
Implements a
CronWorkflow
CRD that defines a scheduledWorkflow
. The design is such that anyWorkflow
can be simply converted to aCronWorkflow
by replacingkind: Workflow
withkind: CronWorkflow
and adding someCronWorkflowOptions
(in short:CronWorkflow
=Workflow
+CronWorkflowOptions
).Example:
Implementation
Implemented by creating a new controller that will be embedded within
workflow-controller
(i.e. the user will not need to install any separate controllers). The cron controller will monitor allCronWorkflow
resources and will execute and terminateWorkflows
based on their respectiveCronWorkflowOptions
.Features/Vision:
CronWorkflow
CronJob
optionsWorkflowTemplate
sThis is still a WIP. TODO:
CronJob
options:schedule
startingDeadlineSeconds
concurrencyPolicy
suspend
successfulJobsHistoryLimit
failedJobsHistoryLimit
CronWorkflow
CRD (i.e. makekubectl describe cronwf [...]
useful)argo
CLI integrationCronWorkflow
Validation