-
Notifications
You must be signed in to change notification settings - Fork 0
Open
Description
Currently, tasks in same run indefinitely until completion or until the entire build is cancelled. We need to add support for a timeout field in the same.yaml task definition. This will allow users to specify a maximum duration for a task (e.g., 5m, 30s). If a task exceeds this limit, the system must terminate the process and report the task as failed.
Goals
- Prevent Hanging Tasks: Allow users to safeguard their builds against processes that may get stuck or hang indefinitely.
- Configuration: Provide a simple, human-readable configuration option in
same.yaml. - Enforcement: Ensure the scheduler strictly enforces these limits during execution.
Acceptance Criteria
1. Configuration & Domain
- Update the
Samefileschema (internal/adapters/config/schema.go) to accept atimeoutfield (string). - Update the
domain.Taskstruct (internal/core/domain/task.go) to include aTimeoutfield of typetime.Duration. - Update the config loader to parse the timeout string using
time.ParseDurationand populate the domain model. - Invalid formats (e.g., "forever") should result in a config validation error.
2. Execution Logic
- Modify the
Scheduler(internal/engine/scheduler/scheduler.go) to apply the timeout. - In
executeTask, if a task has aTimeout > 0, wrap the execution context usingcontext.WithTimeout. - Ensure that when the context deadline is exceeded, the underlying executor kills the process immediately.
- The error returned must clearly indicate a timeout occurred (e.g., wrap
context.DeadlineExceeded).
3. Documentation
- Update
docs/configuration/same-yaml.mdxto include thetimeoutfield in the Task Definition section with examples.
4. Verification
- Add a unit test verifying that
timeout: "10s"is correctly parsed into a duration. - Add an integration test where a task with a short timeout (e.g.,
100ms) runs a slow command (e.g.,sleep 10) and asserts that it fails with a timeout error.
Metadata
Metadata
Assignees
Labels
No labels