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:
Narrowed in 03444ef8e6. Jason's comment below then moved it in 06f13017c2,
so it ended up a bit different from your suggestion: `bundle.ExecutionTimeout`
with just `Run(fn func()) error`. The seconds, logger, client and contexts are
set on `enabledExecutionTimeout` when `resolveExecutionTimeout` builds it.
It differs from your suggestion in three ways:
- To time only the task function, the timeout now runs inside
`bundle.Task.Execute`, around `fn.Call`, so the interface lives in `bundle`.
- `bundle` can't build the runtime's terminal bodies, so `Run` returns an
error and the caller turns it into `failTask`.
- The task's ctx is built in `resolveExecutionTimeout`, not in `Run`,
because `Execute` puts the `airflow.Context` (which wraps that ctx) into the
arguments before the timer starts.
--
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]