Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions config/kubernetes/executor-job.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# TODO: Remove all K8s artifacts in favor of Helm configs (confusing to have both)
# Task Executor
apiVersion: batch/v1
kind: Job
Expand Down
3 changes: 3 additions & 0 deletions database/boltdb/events.go
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,9 @@ func transitionTaskState(tx *bolt.Tx, id string, target tes.State) error {
return fmt.Errorf("Won't switch between two terminal states: %s -> %s",
current, target)

// In case where restarts of executor are allowed, this line should not be encountered
// e.g. Accessing invalid object shpuld be SYSTEM_ERROR every time,

Copilot AI Dec 22, 2025

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Spelling error: "shpuld" should be "should"

Suggested change
// e.g. Accessing invalid object shpuld be SYSTEM_ERROR every time,
// e.g. Accessing invalid object should be SYSTEM_ERROR every time,

Copilot uses AI. Check for mistakes.
// but if a retry mechanism would work (e.g. unavailable for a few seconds), then Task Worker should allow Executor to restart as expected.
Comment on lines +176 to +178

Copilot AI Dec 22, 2025

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This comment is difficult to parse and unclear. Consider breaking it into multiple sentences or restructuring for clarity. The relationship between "restarts of executor", "invalid object", "SYSTEM_ERROR", and "retry mechanism" is confusing as currently written.

Suggested change
// In case where restarts of executor are allowed, this line should not be encountered
// e.g. Accessing invalid object shpuld be SYSTEM_ERROR every time,
// but if a retry mechanism would work (e.g. unavailable for a few seconds), then Task Worker should allow Executor to restart as expected.
// When executor restarts are allowed, this branch should not be reached.
// For example, repeatedly accessing an invalid object should always result in SYSTEM_ERROR (a terminal state) with no retries.
// In contrast, transient errors that can be retried (e.g. a service being unavailable for a few seconds) should be handled before the task reaches a terminal state, allowing the executor to restart as expected.

Copilot uses AI. Check for mistakes.
case tes.TerminalState(current) && !tes.TerminalState(target):
// Error when trying to switch out of a terminal state to a non-terminal one.
return fmt.Errorf("Unexpected transition from %s to %s", current.String(), target.String())
Expand Down
3 changes: 3 additions & 0 deletions database/mongodb/events.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ func (db *MongoDB) WriteEvent(ctx context.Context, req *events.Event) error {

case events.Type_TASK_STATE:
retrier := util.NewRetrier()
// TODO: This could be where the invalid state transition errors are originating from (credit @Sai)
// Check how this interacts with K8s BackoffLimit on Job spec
// Ideally we would have users be able to control their own retry policies outside of internal Funnel's logic
retrier.ShouldRetry = func(err error) bool {
_, isTransitionError := err.(*tes.TransitionError)
return !isTransitionError && err != tes.ErrNotFound && err != tes.ErrNotPermitted
Expand Down
1 change: 1 addition & 0 deletions tes/states.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ type TransitionError struct {
}

func (te *TransitionError) Error() string {
// TODO: This error is being thrown after valid worker restarts (e.g. K8s)
return fmt.Sprintf("invalid state transition from %s to %s",
te.From.String(), te.To.String())
}
Expand Down