Skip to content

runnerhttp, server: add :8081 runner HTTP handler, Actor JWT auth, an… - #635

Merged
itssimrank merged 4 commits into
mainfrom
runner-http-handler
Nov 18, 2026
Merged

itssimrank merged 4 commits into
mainfrom
runner-http-handler

Conversation

@itssimrank

@itssimrank itssimrank commented Nov 17, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Adds ax-server's internal :8081 pull-based runner HTTP handler (internal/runnerhttp), Substrate Actor JWT OIDC verification, in-memory SetupCoordinator for Workspace pre-warming, and RunnerEgressRule (internal/substrate/runner_egress.go).

Zero file overlap with #630 (internal/store), #631 (deploy/ax-server.yaml NetworkPolicy/Service), or #624 (internal/substrate/client.go, runner/).

Key Changes

  • internal/runnerhttp (jwt.go, server.go, server_test.go): Serves GET /healthz, POST /runner/v1/assignment:claim, and POST /runner/v1/events with Substrate Actor JWT verification (OIDCVerifier), implements controller.SetupCoordinator (RegisterSetup, AwaitSetup, DeleteSetup), and flushes HTTP 200 OK before asynchronously parking finished task actors (ActorParker.SuspendActor).
  • internal/substrate/runner_egress.go: Adds RunnerEgressRule (:8081 + ActorJwtSource header replacement).
  • internal/controller/workspace.go: Always binds RunnerEgressRule on temporary ax-ws-setup-* setup actors (even when setupGateway == nil).
  • cmd/ax-server/main.go: Wires --runner-addr=:8081, --actor-jwt-issuer, --actor-jwt-audience, and --enable-prewarm (default false until the pull-based ax-task-runner lands).

Testing

  • go test -count=1 ./internal/runnerhttp/... ./internal/lifecycle/... ./internal/controller/... ./internal/substrate/... ./cmd/ax-server/...
  • golangci-lint (0 issues)

@yongruilin

Copy link
Copy Markdown
Collaborator

ref #631 (comment)

@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.

Nice work, the JWT handling fails closed and the egress rule is tight. One fix before merge: jwt.go reads actor_uid/uid at the top level, but Substrate v1.0 puts it inside "actor.ate.dev": {atespace, actorName, actorUID} (see Substrate's actor-jwts guide), so every real token gets "missing actor_uid claim" and prewarm setup hangs. The tests hand-craft the old shape, worth one using Substrate's example token.

Follow-up before Runnable gets set: the ActorUID check only runs when row.ActorUID is set, and nothing writes it yet, so any incarnation's token passes. Could it fail closed when empty, with the reconciler recording ActorUID and resetting the token per incarnation?

Also, CI didn't run here since it targets #633's branch, worth a run once rebased onto main.

@itssimrank
itssimrank changed the base branch from runner-proto-lifecycle to main November 17, 2026 21:55
Comment thread internal/runnerhttp/jwt.go Resolved
Comment thread internal/substrate/runner_egress.go Resolved
@itssimrank itssimrank mentioned this pull request Nov 17, 2026
Comment thread cmd/ax-server/main.go
flag.StringVar(&runnerEndpoint, "runner-endpoint", substrate.DefaultRunnerEndpoint, "In-cluster host:port of the :8081 runner service allowed in actor EgressPolicies (env: AX_RUNNER_ENDPOINT)")
flag.StringVar(&actorJWTIssuer, "actor-jwt-issuer", "https://idp.ate-system.svc", "Substrate OIDC issuer URL for verifying Actor JWTs on :8081 (env: AX_ACTOR_JWT_ISSUER)")
flag.StringVar(&actorJWTAudience, "actor-jwt-audience", substrate.DefaultRunnerAudience, "Expected OIDC audience for Actor JWTs on :8081 (env: AX_ACTOR_JWT_AUDIENCE)")
flag.BoolVar(&enablePrewarm, "enable-prewarm", false, "Enable Workspace snapshot pre-warming via the :8081 runner setup coordinator (env: AX_ENABLE_PREWARM)")

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.

Any case we will disable it? I think we will enable it by default once we finish implementation.

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.

It's a temporary guard before the pull-based ax-task-runner lands.

Comment thread cmd/ax-server/main.go
workspaces := controller.NewWorkspaceManager(subClient, controller.WorkspaceManagerOptions{
Locker: backend,
Store: backend,
SetupCoordinator: setupCoordinator,

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.

Good to see there is a setup coordinator in place. But do we need another one with db to support multiple replicas case?

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.

deploy/ax-server.yaml currently runs replicas: 1, so an in-memory coordinator is sufficient for now.


// RegisterSetup records an expected Workspace setup actor incarnation prior to
// ResumeActor so ClaimAssignment can immediately serve ASSIGNMENT_MODE_SETUP.
func (s *Server) RegisterSetup(_ context.Context, atespace, setupActor, actorUID string, ws *v1alpha1.Workspace) error {

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.

I would think it may be cleaner if we have a standalone object to implement the in-memory coordinator as we probably need a persisted one when we support multiple replica ax-server.
Ok to be follow up

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.

Ack, will follow-up.

@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 look right now, LGTM. Heads up for wiring: with the ActorUID check failing closed, nothing writes row.ActorUID yet, so task claims will 401 until the reconciler records it when it creates the actor. Worth landing that alongside #637.

@itssimrank
itssimrank merged commit 7c4ce3a into main Nov 18, 2026
12 checks passed
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.

4 participants