if `coder support bundle <workspace>` is run when the workspace agent
had a record but was unreachable, this would cause the command to hang.
This command uploads a number of diagnostics from both the server and
agent, including `pprof`. If the agent is unreachable, this should still
be able to write out as much of the bundle as possible without timing
out.
The agent dial now has a configurable time limit
(`Deps.AgentDialTimeout`, default 30s). On timeout the bundle logs a
warning, skips the sections that need a live agent connection (ping,
peer diagnostics, magicsock, manifest, agent logs over tailnet,
listening ports, workspace files, agent pprof), and still writes out the
bundle. This includes agent logs fetched through the API. The CLI prints
a warning and records it in `cli_logs.txt`; exit status stays 0.
Other changes:
- Each request over an established agent connection has a 10s limit, and
workspace file collection has a 60s limit, so an agent that drops
mid-collection can't stall the bundle either.
- Agent pprof is skipped when the first dial already failed, instead of
waiting through a second dial. Server pprof collection is unchanged.
- `support.AgentInfo` now takes the dial timeout and also reports
whether the agent was reachable.
<details>
<summary>Verification and decision log</summary>
**Reproduction.** An end-to-end CLI test seeds a workspace whose build
has an agent record but never starts an agent process, then runs `coder
support bundle <ws> --yes` with a 90s outer deadline.
| Tree | Result |
|---|---|
| `main` | Hung until the 90s deadline. |
| This branch | Returned in 30.0s with exit 0 and wrote a 33-file zip.
`logs.txt` contains `agent unreachable, skipping agent-connected
sections` and `cli_logs.txt` contains `could not connect to workspace
agent`. |
`TestRun/AgentUnreachable` in `support/support_test.go` covers both
`--pprof` off and on.
**Decisions.**
- The hang was in `DialAgent` itself (`workspacesdk.go`,
`AwaitReachable(dialCtx)`), not in `Ping`, so the time limit goes on the
context passed to `DialAgent`. That function keeps the connection alive
on a separate background context, so cancelling the dial context after a
successful dial doesn't close the connection.
- The regression test uses a real agent record with no agent process
rather than the random agent ID the ticket suggested. A random ID fails
fast during agent lookup and never reaches the code that hangs.
- Limits follow the existing 10s and 45s timeouts used elsewhere in the
bundle collector, plus the ticket's 30s dial target and its worst case
of about 60s for an unreachable agent.
</details>