ChickenBenny commented on code in PR #77489:
URL: https://github.com/apache/airflow/pull/77489#discussion_r4741027482
##########
go-sdk/pkg/execution/execution_timeout.go:
##########
@@ -39,17 +54,91 @@ func resolveExecutionTimeout(fromContext any) (*float64,
error) {
fromContext,
)
case seconds == 0:
- return nil, nil
+ return disabledExecutionTimeout{}, nil
case seconds < 0:
return nil, fmt.Errorf("execution_timeout of %g seconds has
already elapsed", seconds)
}
- return &seconds, nil
+ return enabledExecutionTimeout{seconds: seconds}, nil
+}
+
+type disabledExecutionTimeout struct{}
+
+func (disabledExecutionTimeout) start(context.Context, *CoordinatorClient)
error {
+ return nil
}
-// setExecutionTimeout tells the supervisor the task's execution_timeout and
restarts its clock from
-// now. The runtime does not stop the task itself: killed_task_cleanup_time
after the timeout, the
-// supervisor sends SIGTERM, which cancels the task's ctx.
-func (c *CoordinatorClient) setExecutionTimeout(ctx context.Context, seconds
float64) error {
- _, err := c.comm.Communicate(ctx,
genmodels.SetExecutionTimeout{TimeoutSeconds: seconds})
+func (disabledExecutionTimeout) run(
+ stop context.Context,
+ _ bool,
+ _ *slog.Logger,
+ run func(ctx context.Context) any,
+) any {
+ return run(stop)
+}
+
+type enabledExecutionTimeout struct {
+ seconds float64
+}
+
+// start arms the supervisor, which sends SIGTERM killed_task_cleanup_time
after the timeout.
+func (t enabledExecutionTimeout) start(ctx context.Context, client
*CoordinatorClient) error {
+ _, err := client.comm.Communicate(ctx,
genmodels.SetExecutionTimeout{TimeoutSeconds: t.seconds})
return err
}
+
+// run cancels the task's ctx with sdk.TaskTimeout at the timeout, then waits
until the task
+// returns or the supervisor's SIGTERM cancels stop. The task fails with the
timeout either way.
+func (t enabledExecutionTimeout) run(
+ stop context.Context,
+ shouldRetry bool,
+ logger *slog.Logger,
+ run func(ctx context.Context) any,
Review Comment:
It's `fn` now (a8ea977c63).
--
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]