Repository navigation
feat: allow creating a task from an actor template - #552
siyuanfoundation wants to merge 1 commit into
Conversation
0b40c3e to
df721f8
Compare
|
Nice, this matches #491 closely. One question before approving: with spec.template set, AX skips the per-task template, so the task's workspace, env, resources and config never reach the actor. #491's own example binds a workspace. @rakyll should those be rejected with template, or passed some other way? Either works, I'd just rather they aren't silently ignored. |
Add optional spec.template field to TaskSpec referencing a Substrate ActorTemplate, allowing tasks to run directly from an existing template. - Add template (ObjectRef) to TaskSpec in ax.proto and regenerate protos. - Validate mutual exclusivity of spec.image and spec.template, reject command with template, and require template name. - Check that the referenced ActorTemplate exists in Substrate at CreateTask time before saving or provisioning, returning FailedPrecondition if not found. - Reconcile directly against the referenced template without provisioning a per-task ActorTemplate. - On task deletion, delete only the Actor and skip template cleanup when spec.template is set. - Update ax describe task to display template name and atespace. - Add unit tests across types, reconciler, server, and an E2E test exercising the full lifecycle against Substrate. Refs google#491
df721f8 to
7bf6220
Compare
| if len(spec.GetCommand()) > 0 { | ||
| return errors.New("spec: command cannot be set with template") | ||
| } | ||
| } |
There was a problem hiding this comment.
I think we should also validate the template.GetName() and template.GetAtespace() as Substrate also does that.
|
|
||
| // 3. Ensure Actor exists on Substrate | ||
| var templateAtespace, templateName string | ||
| if tmpl := task.Spec.Template; tmpl != nil { |
There was a problem hiding this comment.
env, resources, workspace, config and debug only reach the actor through ensureTaskTemplate, so they're silently dropped here. Until they can be passed through, should ValidateTask reject them with template, like command?
| if err := r.client.DeleteActor(ctx, atespace, taskName); err != nil { | ||
| return err | ||
| } | ||
| if skipTemplates { |
There was a problem hiding this comment.
This only covers this task's own delete. Deleting an unrelated image task user still sweeps a referenced "user-tmpl-1a2b3c4d" (the naming the e2e uses), and Substrate doesn't stop you deleting a template that's in use. Could the sweep only match templates AX created? Then skipTemplates and DeleteTask aren't needed.
|
|
||
| // 3. Ensure Actor exists on Substrate | ||
| var templateAtespace, templateName string | ||
| if tmpl := task.Spec.Template; tmpl != nil { |
There was a problem hiding this comment.
What if the template is not valid, do we need to Ensure the template before the following call "EnsureActor"?
|
I feel not quite right to expose the substrate-level primitive into the ax level. As we are working on the API proto, the API change in the pr may not be valid. I think we need to consolidate the API change, the apply the shortcut. |
|
/hold |
|
@siyuanfoundation any update here? Happy to re-review once the template-deletion and ignored-fields questions are sorted |
|
@mayawang We will add the actor template option along with the new |
|
Sounds good, closing makes sense since Profile will cover it. Thanks for picking this up! |
Add optional spec.template field to TaskSpec referencing a Substrate ActorTemplate, allowing tasks to run directly from an existing template.
Refs #491
In the current implementation, a task is rejected at creation time if the referenced ActorTemplate does not exist in Substrate. This is because currently there is no self-healing loop in ax, users would need to delete and recreate the task after the template is created. We will revisit this after reconciliation loop is introduced in the future.