Repository navigation
Done
Milestone
Description
A Task should not exist until its actor exists on Agent Substrate. Today CreateTask stores the Task first and creates the actor afterwards, so a failed create leaves a Task behind.
What happens today
CreateTask in internal/server/server.go:
- Stores the Task with state
QUEUED. - Calls
TaskReconciler.Suspend, which creates the atespace, the ActorTemplate and the actor, suspends the actor, and binds the Gateway. - On failure,
recordFailurekeeps the stored Task:QUEUEDandUnavailablefor a transient error,FAILEDwithPROVISIONING_FAILEDotherwise.
The consequences:
- A create that fails for good leaves a
FAILEDTask with no actor. Tasks are immutable, so the name cannot be applied again until the Task is deleted. - A create that fails transiently leaves a
QUEUEDTask. Nothing retries it: ax-server has no queue and no background work. The client has to apply the same manifest again, andCreateTaskhas a special case that allows this only for a storedQUEUEDTask with no template and an identical spec. QUEUEDreads as "something will pick this up", which is not true.
Proposed change
- Provision the actor first, and store the Task only once the actor exists.
- A failed create returns the error and stores nothing. The client retries by applying again, as for any failed RPC.
- Remove the stored
QUEUEDstate for creation, the retry special case inCreateTask, and theprovisioninguse ofrecordFailure.
To decide
- Orphaned actors. If storing the Task fails after the actor was created, or ax-server dies between the two steps, an actor exists with no Task.
CreateTaskcan delete the actor when the store write fails. For a crash, a later create of the same name adopts the actor, because the actor is named after the Task and creation is an ensure; otherwise nothing removes it. - Server-assigned fields.
metadata.uid,create_timeand the defaultsession_idare assigned before provisioning today. They can stay in memory until the Task is stored, as long as nothing in provisioning needs them to be durable. - Resume.
ResumeTaskalso leaves a TaskQUEUEDafter a transient failure. That Task already has an actor, so it is a separate question.
Related
- Remove ReasonSubstrateUnavailable: return Substrate failures as errors, not as state #695: remove
ReasonSubstrateUnavailableand return Substrate failures as errors.
Metadata
Metadata
Assignees
Labels
No labels
Activity
api: align TaskState with Substrate ActorState
api: align TaskState with Substrate ActorState
api: align TaskState with Substrate ActorState (#731)
yongruilin commentedon Nov 24, 2026
I can take this as the follow-up to #748.
Then:
Also:
@rakyll Could this move to v0.4.0, so that it lands with #748?
server: keep taskSpecMatchesExisting check on Queued retries
server: store a task only once its actor exists (google#761)