ChickenBenny commented on code in PR #77489:
URL: https://github.com/apache/airflow/pull/77489#discussion_r4741020921
##########
go-sdk/pkg/execution/execution_timeout.go:
##########
@@ -19,17 +19,32 @@ package execution
import (
"context"
+ "errors"
"fmt"
+ "log/slog"
+ "math"
+ "time"
"github.com/apache/airflow/go-sdk/pkg/execution/genmodels"
+ "github.com/apache/airflow/go-sdk/sdk"
)
-// resolveExecutionTimeout returns the task's execution_timeout in seconds
from ti_context, or nil
-// when the task has no timeout. The coordinator has already filled in the
worker's default.
-// As in the Python task runner, zero means no timeout and a negative value
has already elapsed.
-func resolveExecutionTimeout(fromContext any) (*float64, error) {
+// executionTimeout is a task's execution_timeout. Call start before run.
+type executionTimeout interface {
+ start(ctx context.Context, client *CoordinatorClient) error
+ run(
+ stop context.Context,
+ shouldRetry bool,
+ logger *slog.Logger,
+ run func(ctx context.Context) any,
+ ) any
+}
Review Comment:
Done in 03444ef8e6, but heads up: 06f13017c2 (for the comment on
`task_runner.go`) reshaped it
again, so it ended up a bit different from what you suggested:
```go
type ExecutionTimeout interface {
Run(call func()) error
}
```
Why it drifted:
- That comment asked to time only the task function, not the argument
resolution or the
`return_value` push. So the timer now just wraps `fn.Call` inside
`bundle.Task.Execute`. The
interface had to move to `internal/bundle`, and it returns an `error`
since `bundle` doesn't
know about the terminal bodies. The runtime's usual error path handles it,
so `shouldRetry`
isn't on the type anymore either.
- `call` doesn't take a ctx: `Resolve` binds the `airflow.Context` before
the timer starts, so
the task's ctx is now created up front in `resolveExecutionTimeout` and
the timer cancels it.
Same idea as `timeout.signal` in #76103.
- The rest is what you asked for: `seconds`, `logger`, `client` and `stop`
are set on
`enabledExecutionTimeout` when it's built, and `bundle.NoExecutionTimeout`
is the null object.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]