Skip to content

feat(spored): loud pre-stop failure/timeout notifications (#186) - #189

Merged
scttfrdmn merged 1 commit into
mainfrom
feat/186-loud-pre-stop-signals
Jun 16, 2026
Merged

scttfrdmn merged 1 commit into
mainfrom
feat/186-loud-pre-stop-signals

Conversation

@scttfrdmn

Copy link
Copy Markdown
Contributor

Implements #186 (follow-up to #184/#63).

Problem

A --pre-stop hook that failed or timed out was logged at the same level as success and was otherwise silent — the #184 data-loss shape (aws s3 sync against the wrong dir "succeeded" copying nothing, instance terminated, ephemeral data gone, user found out later).

Change

runPreStop now tees the hook's stdout/stderr to a bounded tail buffer and, on the error/timeout branch, emits a terminal-state notification:

  • pre_stop_timeout — hook killed at the timeout (the multi-GB-sync case)

  • pre_stop_failed — hook exited non-zero
    Both carry the output tail (e.g. fatal error: Unable to locate credentials, or an aws s3 sync summary) and broadcast a wall/msg warning to logged-in users. Still best-effort — shutdown always proceeds; pre-stop never blocks the lifecycle action.

  • pkg/sms formats the two new events.

  • spore-bot Slack/Teams/Discord formatting ships in the paired spore-host PR.

Tests

tailBuffer retains the tail (not head) and bounds memory; preStopDetail composes summary + tail. pkg/agent green; builds linux/darwin/windows; vet clean.

Refs #186. Paired: spore-host PR (notifier formatting).

A pre-stop hook that failed or timed out logged at the same level as success and
was otherwise silent — the #184 data-loss shape (aws s3 sync against the wrong
dir "succeeded" copying nothing). Now runPreStop tees the hook's stdout/stderr
to a bounded tail buffer and, on error/timeout, emits a terminal-state
notification (pre_stop_failed / pre_stop_timeout) carrying the output tail, plus
a wall/msg warning to logged-in users. Still best-effort: shutdown always
proceeds.

SMS formatter (pkg/sms) gains the two events; spore-bot Slack/Teams/Discord
formatting ships separately in spore-host. Tests: tailBuffer retains the tail;
preStopDetail composes summary + tail.

Refs #186
@codecov

codecov Bot commented Jun 16, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 48.71795% with 20 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
pkg/agent/agent.go 54.28% 16 Missing ⚠️
pkg/sms/sms.go 0.00% 4 Missing ⚠️

📢 Thoughts on this report? Let us know!

@scttfrdmn
scttfrdmn merged commit 3d14cea into main Jun 16, 2026
7 checks passed
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.

1 participant