feat(stack): confirm down/purge when services are serving traffic#512
Open
bussyjd wants to merge 1 commit into
Open
feat(stack): confirm down/purge when services are serving traffic#512bussyjd wants to merge 1 commit into
bussyjd wants to merge 1 commit into
Conversation
Add a safety gate to `obol stack down` and `obol stack purge` that inspects in-cluster ServiceOffers (PaymentGateReady=True AND RoutePublished=True) and host-side sell-inference gateways with alive PID files, then prompts before tearing the stack down. In non- interactive shells the gate fails closed unless --yes is passed. This closes the silent-down vector that took inference.v1337.org offline for 17 hours: a non-interactive `ssh host '<obol stack down>'` from a stale worktree's script wiped the production stack with no operator confirmation and no audit trail of the running services. - internal/stack/safety.go: ConfirmRunningServicesLoss + discovery - stack.Down(cfg, u, skipConfirm), stack.Purge(cfg, u, force, skipConfirm) - cmd/obol: --yes / -y flag on `stack down` and `stack purge` - internal stack-up cleanup passes skipConfirm=true (system-initiated) - --force keeps its existing meaning (delete data dir); --yes is the new escape hatch for the safety prompt only
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
obol stack downandobol stack purgethat lists live ServiceOffers + sell-inference host gateways before tearing them down.[y/N]prompt; in non-interactive shells the call fails closed with an error pointing at--yes.--yes / -yflag added to both subcommands as the explicit non-interactive escape hatch.--forcekeeps its existing meaning (delete data dir even when root-owned) and does not imply--yes.Why
inference.v1337.org went dark for ~17h on 2026-05-22. Forensics on spark2 showed the k3d cluster received a manual stop (
hasBeenManuallyStopped=trueindockerdlog) inside a 22-secondsession-4154cgroup that originated from an inbound SSH from127.0.0.1— i.e. a script on the box ssh'd to localhost asclaudeand ranobol stack down(or equivalent) without ever touching a tty. Today there is nothing in the CLI that distinguishes "operator typed this" from "a stale cleanup script targeted the wrong stack". This PR adds that check.How
internal/stack/safety.go::ConfirmRunningServicesLoss(cfg, u, action, skipConfirm)kubectl get serviceoffers.obol.org -A -o json, filter toPaymentGateReady=True AND RoutePublished=True(deliberately not requiringReady=True, becauseRegisteredstays False for unregistered offers indefinitely — gating on Ready would let the prompt skip real production offers likeaeon).<StateDir>/sell-inference/*/gateway.pid, keep the ones whose PID is alive (syscall.Signal(0)).stack.Down(cfg, u, skipConfirm)andstack.Purge(cfg, u, force, skipConfirm)call the gate first.stack upcleanup path (helmfile-sync failure auto-rollback) passesskipConfirm=true— the operator didn't trigger that call.cmd/obol/main.go: adds--yes / -yondownandpurge, threads it through.Test plan
go build ./...go test ./internal/stack/ ./cmd/obol/ ./internal/tunnel/ -count=1— all passing except a pre-existing failure (TestWarnIfNoChatModel_EmitsWarnWhenNoModels) that reproduces onmainwithout this change--yes-mentioning error andproceed=false,--yespasses through with a warn line, dead PID files are ignored, gateReady requires both conditions True, priceSummary covers per-request/per-MTok/per-hour/emptygo run ./cmd/obol stack down --helpandstack purge --helprender the new--yesflag with usage copyNotes for reviewers
tunnel.ConfirmQuickTunnelLossgate, since live offers are a bigger blast radius than a quick-tunnel URL change.ConfirmQuickTunnelLoss's default-Yes), since the destructive action is also bigger.internal/stack/safety.godefines a localrawOfferstruct rather than importingmonetizeapi— keeps the safety package free of CRD typing for the same reasons as the rest ofinternal/stack.