Skip to content

Make agent-secret demo route correctly: inject session header + fix DNS suffix#61

Open
Davanum Srinivas (dims) wants to merge 2 commits into
agent-substrate:mainfrom
dims:fix/agent-secret-demo
Open

Make agent-secret demo route correctly: inject session header + fix DNS suffix#61
Davanum Srinivas (dims) wants to merge 2 commits into
agent-substrate:mainfrom
dims:fix/agent-secret-demo

Conversation

@dims
Copy link
Copy Markdown
Collaborator

Two compact changes that together make the agent-secret demo run as documented:

  • feat(atenet/router) — inject the resolved actor ID as an x-agentset-session request header on every successful resume, so workloads can identify their own actor without parsing the rewritten :authority.
  • fix(demos/agent-secret) — replace the stale substrate.k8s.io DNS suffix with substrate.ate.dev (the live router suffix per internal/resources/actor.go:27) in three curl examples and two source comments.

Running the demo's README verbatim today fails in two ways:

  1. The Host header uses the legacy substrate.k8s.io suffix and is rejected by the router with a 404.
  2. Even with the correct suffix, the router rewrites :authority to the worker pod IP before the workload sees it. The workload's fallback prefix-extraction then grabs the first octet of the IP (10 for 10.244.0.30), SuspendActor(actor_id="10") returns NotFound, and the actor never self-suspends.

The header-injection change is also useful beyond this demo: any future workload that needs its own actor identity now has a stable header to read it from, instead of either reverse-engineering :authority or relying on an environment-variable mount.

Testing:

go build -buildvcs=false ./cmd/servers/atenet/... ./demos/agent-secret/...    # exit 0
go vet                  ./cmd/servers/atenet/app/router/... ./demos/agent-secret/...   # exit 0
go test -count=1        ./cmd/servers/atenet/app/router/...                            # ok 0.787s

End-to-end on a local kind cluster:

  • curl -H "Host: my-agent.actors.resources.substrate.ate.dev" http://localhost:8000 (no other headers) — workload now logs DEBUG: Identified ActorID: [my-agent], the response reads Session: my-agent (was Session: 10), and the actor flips to STATUS_SUSPENDED ~9 s after the response.
  • RAM-state preservation (same SECRET-NNNN returned across resume cycles, including worker-pod migration) is unchanged.

…quests

The router rewrites :authority to the resolved worker pod IP before the
request is forwarded, which strips the actor-ID prefix from any header
the workload would otherwise have seen. Workloads that need to know
their own actor identity (e.g. to call SuspendActor on themselves, as
the agent-secret demo does) currently have no reliable source for it.

Inject the resolved actor ID as the x-agentset-session request header
on every successful resume. The header name matches the lookup order
already used by the agent-secret demo, so workloads that read it Just
Work without further changes.

The success-case test assertion is updated to expect both :authority
and x-agentset-session mutations, indexed by key so it is independent
of the order the router emits them.

Signed-off-by: Davanum Srinivas <davanum@gmail.com>
The router routes requests by the actors.resources.substrate.ate.dev
suffix (internal/resources/actor.go:27). References to the legacy
substrate.k8s.io suffix in this demo's README and inline comments
caused requests run verbatim from the docs to silently fail routing.
Replace the stale suffix with the current one in three curl examples
and two source comments.

Signed-off-by: Davanum Srinivas <davanum@gmail.com>
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.

1 participant