Skip to content

Server gives up on a container command 15s before the agent does, reporting success as a timeout #160

Description

@rodriguecyber

Difficulty: Beginner · You'll need: TypeScript, Go · Size: ~5 lines

What's going on

The platform gives up waiting 15 seconds before the agent stops trying.

Layer Timeout Location
Server, waiting for container.result 45s agents.gateway.tssendContainerCommand(… timeoutMs = 45_000)
Agent, docker restart 60s docker/service.goRestartContainer
Agent, docker remove 60s docker/service.goRemoveContainer

What the operator sees

A container that takes 50 seconds to restart or force-remove:

  1. At 45s the server's setTimeout fires, deletes the pendingCommands entry, and rejects the promise
  2. mapAndThrow matches 'timed out'504 Gateway Timeout
  3. The dashboard shows "Agent timed out waiting for container.result (restart)"
  4. At 50s the agent finishes successfully and sends container.result
  5. The gateway logs No pending command for container.result requestId=… and drops it

The operation succeeded. The operator was told it failed, and the next list refresh contradicts the error they just saw. For remove this is worse than for restart: the natural reaction to a failed delete is to click delete again, which then returns "No such container".

Why it happens

The two numbers were chosen independently and nobody compared them. It is not specific to removerestart has had it since lifecycle commands were added.

Fixing it

The invariant to establish: the waiter must outlive the worker. The server's timeout has to exceed the agent's Docker timeout plus round-trip time, for every action.

Options:

  1. Raise the server timeout past the slowest agent-side operation, with headroom — e.g. 75s against a 60s worst case. One line, no protocol change.
  2. Per-action timeouts on both sides, derived from one shared table. More correct — a start need not hold a request for 75s — but more moving parts.
  3. Have the agent send a progress/ack message so the server can extend. Over-engineered for this.

Option 1 is the right size for v0.1.0. Whichever is chosen, write the relationship down as a comment next to both numbers so the next person changing one sees the other.

Done when

  • The server's wait exceeds the agent's longest Docker timeout, with headroom for the round trip
  • A slow restart and a slow force-remove both report success rather than a timeout
  • The relationship between the two numbers is documented at both sites

Activity

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:agentThe DockSight Agent (apps/agent)area:serverThe NestJS platform server (apps/server)bugSomething isn't workinggood first issueGood for newcomers

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions