Skip to content

Commit 39b78d7

Browse files
committed
docs: Document agent startup (script) issues
Refs: #5749, #5851
1 parent dd8eab5 commit 39b78d7

File tree

1 file changed

+38
-3
lines changed

1 file changed

+38
-3
lines changed

docs/templates.md

Lines changed: 38 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -375,25 +375,60 @@ customize them however you like.
375375
## Troubleshooting templates
376376

377377
Occasionally, you may run into scenarios where a workspace is created, but the
378-
agent is not connected. This means the agent or [init script](https://github.com/coder/coder/tree/main/provisionersdk/scripts)
378+
agent is either not connected or the [startup script](https://registry.terraform.io/providers/coder/coder/latest/docs/resources/agent#startup_script)
379+
has failed or timed out.
380+
381+
### Agent connection issues
382+
383+
If the agent is not connected, it means the agent or [init script](https://github.com/coder/coder/tree/main/provisionersdk/scripts)
379384
has failed on the resource.
380385

381386
```console
382387
$ coder ssh myworkspace
383-
Waiting for [agent] to connect...
388+
⢄⡱ Waiting for [agent] to connect...
384389
```
385390

386391
While troubleshooting steps vary by resource, here are some general best
387392
practices:
388393

389-
- Ensure the resource has `curl` installed
394+
- Ensure the resource has `curl` installed (alternatively, `wget` or `busybox`)
390395
- Ensure the resource can `curl` your Coder [access
391396
URL](./admin/configure.md#access-url)
392397
- Manually connect to the resource and check the agent logs (e.g., `kubectl exec`, `docker exec` or AWS console)
393398
- The Coder agent logs are typically stored in `/tmp/coder-agent.log`
394399
- The Coder agent startup script logs are typically stored in
395400
`/tmp/coder-startup-script.log`
396401

402+
### Agent startup issues
403+
404+
If the agent does not start, it means the [startup script](https://registry.terraform.io/providers/coder/coder/latest/docs/resources/agent#startup_script) is still running or has exited with a non-zero status. This also means the [delay login until ready](https://registry.terraform.io/providers/coder/coder/latest/docs/resources/agent#delay_login_until_ready) option is enabled.
405+
406+
```console
407+
$ coder ssh myworkspace
408+
⢄⡱ Waiting for [agent] to finish starting up...
409+
```
410+
411+
To troubleshoot startup issues, check the agent logs as suggested above. For startup issues you can connect to the workspace using SSH with the `--no-wait` flag.
412+
413+
```console
414+
$ coder ssh myworkspace --no-wait
415+
416+
> The workspace agent is taking longer than expected to
417+
start. See troubleshooting instructions at: [...]
418+
419+
user@myworkspace $
420+
```
421+
422+
If the startup script is expected to take a long time, you can try raising the timeout defined in the template:
423+
424+
```tf
425+
resource "coder_agent" "main" {
426+
# ...
427+
delay_login_until_ready = true
428+
startup_script_timeout = 1800 # 30 minutes in seconds.
429+
}
430+
```
431+
397432
## Template permissions (enterprise)
398433

399434
Template permissions can be used to give users and groups access to specific

0 commit comments

Comments
 (0)