2 Commits
Author SHA1 Message Date
Bobby Ho 54274c18e0 feat: report skipped and canceled script outcomes from the agent (#30888)
feat(agent): report skipped and canceled script outcomes

Send startup-script outcomes to coderd and the Build Timeline, completing
the agent-side support for #30875.

- Report one zero-duration timing for scripts skipped or canceled before
  starting. Interrupted startup scripts report `canceled` instead of
  `exit_failure`, including on templates without ordering.
- Add cancellation logs for ordered scripts waiting on dependencies or
  running. Completed outcomes, timeouts, exit codes, and stop/cron
  reporting remain unchanged.
- Give reports an independent timeout and make `Runner.Close` wait for
  in-flight executions so shutdown does not discard cancellation timings.
  Synchronize cron startup with `Close` to prevent shutdown hangs.
- Dial Agent API v2.15; agents now require coderd supporting that version.

Tests cover skips, cancellation, duplicate prevention, and shutdown races.
Race-detector tests and all 14 manual scenarios passed.

Refs https://linear.app/codercom/issue/PLAT-550/phase-3-expose-skipped-and-canceled-script-outcomes
2026-10-16 18:27:02 +00:00
Bobby Ho 4d1f95e73e feat: order lifecycle scripts by their dependencies (#30765)
feat(agent): enforce lifecycle script ordering

Honor `coder_script_order` dependencies for startup and shutdown scripts
using the existing outcome-aware unit manager. Cron, legacy scripts,
and scripts without dependencies retain their existing behavior.

- Wait for all prerequisites before running. `success` requires a
  successful prerequisite; `completion` also accepts failure, timeout,
  or skip. Skip dependents as soon as a required success becomes
  impossible, preserving the original failure as the lifecycle error.
- Reject invalid dependency graphs before any scripts start and write
  the reason to every selected script's log.
- Log unmet dependencies every 30 seconds and explain skips. Populate
  display names in the manifest so skip messages use readable names,
  falling back to Terraform addresses.
- Exclude dependency waits from script timeouts, record an outcome on
  every exit, and use fresh state per execution. Cancellation stops
  waiters without starting dependents or emitting skip messages.

Add regression coverage for ordering, skip propagation, timeouts,
cancellation, invalid graphs, and unchanged unordered execution.

Refs https://linear.app/codercom/issue/PLAT-549/phase-3-enforce-lifecycle-script-ordering
2026-10-15 20:33:48 +00:00