Skip to content

Each call asks ECS where the task is, twice #752

Closed

Description

@allisonmahmood

EcsTaskProvider.call runs resolve (an ECS DescribeTasks) before both bind and invoke (packages/execution/src/ecsTaskProvider.ts): two control-plane calls per call.

For a resource-backed query, the one before invoke happens after the query has opened its company snapshot (Invocation.ts: bundle load → bind → snapshot → invoke). So it also lengthens how long the company connection is held. Primitive-free snapshots take no company connection. The hold is p50 218 ms against a guest run of p50 33 ms. This lookup is one contributor to that gap; it hasn't been measured on its own.

Caching the task's address on failure alone isn't safe. A stopped task's IP can be reassigned to a fresh, unbound spare that holds the same fleet secret. A management request sent to the cached address would then succeed against the wrong task: the request carries company and epoch but not the expected task, and post trusts the address. Today a fresh DescribeTasks rejects a stopped task before any request goes out.

Fix

  1. The receiver verifies identity. Management requests carry the expected task id, and the supervisor refuses before any side effect if it isn't that task. EXECUTION_TASK_ID is already injected. Roll this out compatibly with older supervisors.
  2. Then cache the endpoint. Once the supervisor verifies identity, cache the resolved endpoint per task (address, ARN, revision), bounded and with a TTL. Invalidate it on lifecycle changes, protocol refusals (including the identity refusal) and transport failures. Keep Fleet.route's live binding checks.
  3. Never replay a possibly executed mutation or action after re-resolving on a transport failure.

Tests:

  • an identity mismatch refuses before bind or invoke has any effect;
  • a cached endpoint is used across calls;
  • a stopped task's reused address is refused and re-resolved;
  • an uncertain invoke isn't replayed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:serverenhancementready-for-agent

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions