Skip to content

fix(substrate): adapt to Substrate v0.4 API and harden actor RPCs - #457

Merged
siyuanfoundation merged 2 commits into
google:mainfrom
siyuanfoundation:sync
Oct 14, 2026
Merged

siyuanfoundation merged 2 commits into
google:mainfrom
siyuanfoundation:sync

Conversation

@siyuanfoundation

Copy link
Copy Markdown
Collaborator

fixes: #443

Bump github.com/agent-substrate/substrate to v0.4.1-0.20261009152331-f6a1dc72a35d and adapt to its API changes:

  • ContainerReadyz -> ContainerWakeupProbe.
  • SnapshotsConfig -> SnapshotConfig with PreferredFidelity VOLUMES (equivalent to the previous data-only snapshot / resume-from-golden).
  • WorkerAssignment.WorkerPodIp -> WorkerPodIps; use the first (primary) IP and build the readiness URL with net.JoinHostPort so IPv6 works.

Make Substrate calls more robust:

  • Retry ResumeActor (ResourceExhausted/Aborted) and SuspendActor, DeleteActor, DeleteActorTemplate (Aborted) with jittered exponential backoff via github.com/cenkalti/backoff/v5.
  • When CreateActorTemplate rejects the built template (InvalidArgument/ Unimplemented), fall back to cloning the cluster's base template with task overrides, preserving cluster-specific settings such as SnapshotConfig.

Other:

  • Add v1alpha1.DefaultSystemNamespace and replace hard-coded "ax-system".
  • Don't reuse an existing CLI tunnel that points at a different namespace/service.

Bump github.com/agent-substrate/substrate to v0.4.1-0.20261009152331-f6a1dc72a35d
and adapt to its API changes:
- ContainerReadyz -> ContainerWakeupProbe.
- SnapshotsConfig -> SnapshotConfig with PreferredFidelity VOLUMES
  (equivalent to the previous data-only snapshot / resume-from-golden).
- WorkerAssignment.WorkerPodIp -> WorkerPodIps; use the first (primary) IP
  and build the readiness URL with net.JoinHostPort so IPv6 works.

Make Substrate calls more robust:
- Retry ResumeActor (ResourceExhausted/Aborted) and SuspendActor, DeleteActor,
  DeleteActorTemplate (Aborted) with jittered exponential backoff via
  github.com/cenkalti/backoff/v5.
- When CreateActorTemplate rejects the built template (InvalidArgument/
  Unimplemented), fall back to cloning the cluster's base template with task
  overrides, preserving cluster-specific settings such as SnapshotConfig.

Other:
- Add v1alpha1.DefaultSystemNamespace and replace hard-coded "ax-system".
- Don't reuse an existing CLI tunnel that points at a different
  namespace/service.
@siyuanfoundation

Copy link
Copy Markdown
Collaborator Author

/ok-to-test

@siyuanfoundation

Copy link
Copy Markdown
Collaborator Author

/cc @mayawang

@mayawang mayawang left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Thanks @siyuanfoundation, porting to v0.4 this fast unblocks everyone, and the IPv6-safe address handling is a nice touch. I wrote up the retry policy for the open Substrate PRs in #468; the two asks for this PR are under "Per PR". Happy to approve once those are in.

Comment thread internal/substrate/client.go Outdated
ActorTemplate: tmpl,
}
created, err := c.control.CreateActorTemplate(ctx, req)
if code := status.Code(err); (code == codes.InvalidArgument || code == codes.Unimplemented) && baseTemplate != "" {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This is the fallback #468 asks to drop. InvalidArgument is also what real errors come back as (a bad image reference, or limits larger than a worker), and the clone keeps the base template's template-level settings. Once #405 lands, the task's resource limits live at that level, so a rejected template would quietly run without them.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

dropped the fallback

Comment thread internal/substrate/client.go Outdated
var err error
resp, err = c.control.ResumeActor(ctx, req)
return err
}, codes.ResourceExhausted, codes.Aborted)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Could this retry Aborted only? #465 handles ResourceExhausted with its background loop, and retrying it here for up to ~20s eats most of each of its attempts.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

done!

@mayawang mayawang left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Thanks, both #468 asks are in and tests pass on main. Approving, go ahead and merge.

@mayawang mayawang left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Thanks, both #468 asks are in and tests pass on main. Approving, go ahead and merge.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Task creation fails on Substrate 6a35150 and later: AX still sends the removed snapshot_config.on_resume

2 participants