-
-
Notifications
You must be signed in to change notification settings - Fork 625
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
Adding --max-runs flag to control number of times a task should run before termination + minor bug fixes #1332
Conversation
I'm fine with this as a temporary solution if people are running into this issue a lot. However, the real problem is a bit more fundamental than this. This problem has been made much worse since we added loops via the We're actually very close to adding a Taskfile DAG and the Task DAG will follow on from that and will fix this issue outright (there will be no limit to how many times you can call a Task). It's up to @andreynering if we want to add this in the meantime. If this were to happen, it would probably be deprecated in the future. |
Hey @pd93. While I totally agree with you, I think this feature can still be used even when the DAG is introduced; although the purpose would be slightly different. Instead of it being used as a way of detecting cycles/loops, it'll act similar to a timeout. In other DAG tools, I've seen people writing code that iterates over a node (task, in this case) hundreds of times, through error retries or just normal looping, effectively wasting resources, and I've always appreciated having a timeout to free resources for other DAGs to run. However, if you guys already have that case covered in the DAG implementation, then feel free to close the PR. Thank you for the amazing work. |
Understood, that makes sense. Perhaps once the DAG refactor happens, we can just remove the arbitrary limit of 100 (so it would be unlimited by default), and this setting can override that if a user wants to impose a manual limit. In that case, I'm happy to leave this open for review. |
cmd/task/task.go
Outdated
@@ -135,6 +136,7 @@ func run() error { | |||
pflag.DurationVarP(&flags.interval, "interval", "I", 0, "Interval to watch for changes.") | |||
pflag.BoolVarP(&flags.global, "global", "g", false, "Runs global Taskfile, from $HOME/{T,t}askfile.{yml,yaml}.") | |||
pflag.BoolVar(&flags.experiments, "experiments", false, "Lists all the available experiments and whether or not they are enabled.") | |||
pflag.IntVar(&flags.maxRuns, "max-runs", task.MaximumTaskCall, "Set the maximum number of runs per task before being considered infinte or cyclic and therefore terminated.") |
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.
Not requesting any changes to this now. Just opening this up for thoughts and opinions as naming is always hard. Some other possibilities:
--limit
- Nice and short, but might be too generic (could clash with something likeinclude-limit
if we wanted it)--call-limit
--max-task-calls
- Very explicit, but longer. I don't think length is a huge issue with these flags as they're most likely to be used in CI or scripts.
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.
Also, I'd like to shorten the description. I couldn't find more concise (yet complete) description.
Hi @MohamedAbdeen21, I decided to just raise the limit as a mitigation for now. As @pd93 said, we'll hopefully have a much better detection soon, and then this arbitrary check will be gone. |
This PR addresses issue #1321, which is caused by the hard-coded value of
MaximumTaskCall
. This change adds the option to set number of max task calls before termination through the new--max-runs
flag.Example Taskfile
Old behavior
Issue
Notice that in the old behavior:
New behavior
Added
Fixed
max-run
times.