Task timeout
A timeout defines the maximum duration a runnable task is allowed to run.
What is a timeout
If a task run exceeds the specified duration, Kestra automatically stops it and marks it as failed. This is useful for tasks that may hang and run indefinitely.
Timeouts are often used as a cost-control mechanism in cloud-based workflows. Imagine a Snowflake query or an AWS Batch job that runs for hours leading to unexpected costs. By setting a timeout, you can ensure that the task run will not exceed a certain duration.
Format
Similar to retries, timeouts use the ISO 8601 duration format, but week, month, and year designators are not supported. Below are some examples:
name | description |
---|---|
PT0.250S | 250 milliseconds delay |
PT2S | 2 seconds delay |
PT1M | 1 minute delay |
PT3.5H | 3 hours and a half delay |
P6DT4H | 6 days and 4 hours delay |
Example
In this example, the costly_query
task sleeps for 10 seconds, but the timeout is set to 5 seconds, causing the task to fail.
id: timeout
namespace: company.team
description: This flow will always fail because of a timeout.
tasks:
- id: costly_query
type: io.kestra.plugin.scripts.shell.Commands
taskRunner:
type: io.kestra.plugin.core.runner.Process
commands:
- sleep 10
timeout: PT5S
Flow-level timeout
There is no flow-level timeout. To cancel a workflow execution that exceeds a specific duration, use MAX_DURATION
-type SLA.
Was this page helpful?