Skip to content

Commit 90c4d5d

Browse files
authored
docs: Document agent readiness issues (startup script) (coder#5877)
Refs: coder#5749, coder#5851
1 parent 981cac5 commit 90c4d5d

File tree

1 file changed

+39
-3
lines changed

1 file changed

+39
-3
lines changed

docs/templates.md

Lines changed: 39 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -375,25 +375,61 @@ 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 connection from [agent]...
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 does not become ready
403+
404+
If the agent does not become ready, 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 [login before ready](https://registry.terraform.io/providers/coder/coder/latest/docs/resources/agent#login_before_ready) option hasn't been set to true.
405+
406+
```console
407+
$ coder ssh myworkspace
408+
⢄⡱ Waiting for [agent] to become ready...
409+
```
410+
411+
To troubleshoot readiness issues, check the agent logs as suggested above. You can connect to the workspace using `coder ssh` with the `--no-wait` flag. Please note that while this makes login possible, the workspace may be in an incomplete state.
412+
413+
```console
414+
$ coder ssh myworkspace --no-wait
415+
416+
> The workspace is taking longer than expected to get
417+
ready, the agent startup script is still executing.
418+
See troubleshooting instructions at: [...]
419+
420+
user@myworkspace $
421+
```
422+
423+
If the startup script is expected to take a long time, you can try raising the timeout defined in the template:
424+
425+
```tf
426+
resource "coder_agent" "main" {
427+
# ...
428+
login_before_ready = false
429+
startup_script_timeout = 1800 # 30 minutes in seconds.
430+
}
431+
```
432+
397433
## Template permissions (enterprise)
398434

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

0 commit comments

Comments
 (0)