Skip to content

feat: bootstrap diagnostics (phone-home tags, fast-fail, console capture, cleanup on failed start)#50

Merged
kurok merged 1 commit into
mainfrom
feat/bootstrap-diagnostics
Jul 2, 2026
Merged

feat: bootstrap diagnostics (phone-home tags, fast-fail, console capture, cleanup on failed start)#50
kurok merged 1 commit into
mainfrom
feat/bootstrap-diagnostics

Conversation

@kurok

@kurok kurok commented Jul 2, 2026

Copy link
Copy Markdown

Closes #41 — first item in the roadmap (#49, Phase 1).

What & why

A failed bootstrap used to wait out the full 5-minute registration timeout, leave the instance running (billing leak), and give no diagnostics — you had to run aws ec2 get-console-output by hand. This makes the action diagnose failures itself.

1. Phone-home bootstrap status (fast-fail)

  • buildUserData (extracted, now unit-tested) tags the instance ec2-github-runner:bootstrap = preparing → installing → creating-user → downloading → configuring → registered, and an ERR trap writes failed:<step> on abort — in both the root and runner-user shells.
  • New src/wait.js waitForRunnerReady polls the tag alongside GitHub registration and fails within one poll interval, naming the step, instead of timing out.
  • Best-effort: needs ec2:CreateTags (self-scoped) on the instance role; degrades to timeout detection with no error when absent. Read via ec2:DescribeTags.

2. Console-output capture on failure

  • On fast-fail or timeout, GetConsoleOutput is fetched, decoded, tailed (last 200 lines / 64 KiB), and printed in a collapsible group. The registration token is redacted from the output.

3. Cleanup on failed start

  • New input cleanup-on-start-failure (default true): terminate after capturing diagnostics so failed starts don't leak billing. false preserves the instance and prints ready-to-paste get-console-output/terminate-instances commands.
  • ⚠️ Behavior change: previously a registration timeout left the instance running. Documented in the README + input description.

Tests

  • tests/userdata.test.js, tests/diagnostics.test.js, tests/wait.test.js — buildUserData phases/trap, getBootstrapStatus, getConsoleOutputTail (decode/tail/cap/redact), handleStartFailure (capture→terminate order, preserve mode, redaction), and the wait loop (fast-fail/timeout/success). 83 tests pass (was 52).

Docs / IAM

  • README: new "Troubleshooting a failed start" section, cleanup-on-start-failure input row, top-of-file callout updated.
  • IAM: added ec2:DescribeTags + ec2:GetConsoleOutput to the base policy; documented the self-scoped ec2:CreateTags on the instance role.

Compatibility

  • Existing inputs unchanged; default on-demand behavior byte-identical apart from the documented cleanup-on-timeout change.
  • npm run package dist rebuilt & committed (verify-dist green); lint clean.

…ture, cleanup on failed start

When a runner failed to bootstrap, the action previously waited out the full
registration timeout and left the instance running with no diagnostics. It now:

- Phone-home tags: user-data tags the instance with its bootstrap phase
  (preparing → installing → creating-user → downloading → configuring →
  registered) and writes failed:<step> via an ERR trap. Best-effort — needs
  ec2:CreateTags on the instance role, degrades to timeout detection otherwise.
- Fast-fail: the start wait loop (new src/wait.js) polls the tag alongside
  GitHub registration and fails within one interval naming the failing step.
- Console capture: on fast-fail or timeout, GetConsoleOutput is fetched and
  the tail printed in a collapsible group, with the registration token redacted.
- cleanup-on-start-failure (default true): terminate the instance after
  capturing diagnostics so failed starts don't leak billing. false preserves it
  and prints a ready-to-paste get-console-output/terminate command.

Adds unit tests for buildUserData, the diagnostics helpers, and the wait loop
(83 tests total). README troubleshooting + IAM docs and action.yml updated.

Closes #41

Signed-off-by: kurok <22548029+kurok@users.noreply.github.com>
@kurok kurok merged commit bebfa22 into main Jul 2, 2026
5 checks passed
@kurok kurok deleted the feat/bootstrap-diagnostics branch July 2, 2026 18:31
kurok added a commit that referenced this pull request Jul 2, 2026
Adds CHANGELOG.md documenting the 4.0.0 capability wave (features #50-#59) and its
breaking changes (ec2:CreateTags now always required; cleanup-on-start-failure
defaults to terminate; DeleteOnTermination forced). Updates all README/docs/example
usage snippets from @V3 to @v4 and adds a Changelog pointer.

Signed-off-by: kurok <22548029+kurok@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bootstrap diagnostics: phone-home status tags, fast-fail, console-output capture, cleanup on failed start

1 participant