Repository navigation
Let a stranded machine finish removal without on-machine cleanup - #5859
Merged
Merged
Conversation
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
ymichael
force-pushed
the
fix/remove-unreachable-machine
branch
from
October 20, 2026 20:10
e7549e3 to
37105f4
Compare
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
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.
Human comments
What was wrong
Removing a persistent provider machine whose computer is already gone never finishes.
sweepProviderMachine(apps/server/src/services/machines/provider-orchestration.ts) first tears down every environment on the host, and provider-owned environment teardown runs on the host daemon. With the daemon gone each teardown fails with "Host is not connected", the host is set toteardownStatus: "failed", and the sweep retries every 60 s forever.retry-cleanuponly re-runs the same teardown and the delete route has no other path, so the machine stays at "Cleanup failed · Host is not connected" in Settings → Machines with no way to finish. Seen on a realmanual-provider machine whose server had been deleted before its bb removal.What changed
POST /hosts/:id/force-remove→forceMachineRemoval. Accepted only for a machine inremovingwhose teardown failed, that is disconnected, persistent, and still has environments blocking removal (409machine_cleanup_not_failed/machine_connected/machine_cleanup_not_blockedotherwise). It waits for in-flight machine sweeps/removals and environment operations, marks the host's environments destroyed without running their teardown on the machine (markHostEnvironmentsDestroyed, as the ephemeral path does) and emitsexperimental_environment.removedfor each, then runs the normal removal: the provider'sremove, key revocation anddestroyed. A providerremovefailure leaves the machine retryable withretry-cleanup.runRemove) no longer overwrite an environment already marked removed, so a teardown that was in flight when its machine was forgotten cannot leave a destroyed row retrying forever against a destroyed host.hosts.experimental_forceRemove, CLIbb machine force-remove <id-or-name> [--yes], and the app: the existing Remove machine dialog (row menu and machine page) switches to "Remove without cleanup" with an explanation for a stranded machine. The thread banner for cleanup-failed machines mentions it.docs/api_to_audit.md, plugin API surfaces.bb machine remove --force: the preconditions differ, and a force flag on a healthy machine would silently skip cleanup on a reachable computer.HOST_DAEMON_PROTOCOL_VERSIONunchanged.How you verified
apps/server/test/services/machines/force-removal.test.ts: a stranded machine stays stuck afterretry-cleanupand is destroyed by force removal (environments destroyed, providerremovecalled once,environment.removedemitted, no further teardown attempts); refusals before failure and while connected; public route 409/200/404; a late in-flight teardown failure keeps the environment removed (fails without therunRemoveguard); providerremovefailing after the skip stays retryable; a suspended stranded machine is removed without resuming. Machine-credential 403 matrix, CLI, SDK type list and both UI dialog entry points covered.pnpm exec turbo run typecheck lintfor server, cli, app, sdk, server-contract, templates, bb-guide and plugin-api-docs; tests for server (machines, hosts, environments, environment providers, public host management), cli, sdk, templates, bb-guide, plugin-api-docs and the two app machine views;oxfmt --check.bb machine retry-cleanupleft the machine at removing/failed "Host is not connected";force-removeon the server machine was refused with 409;force-removeon the stranded one removed it (host destroyed, all 280 of its environments destroyed/removed, other machines untouched); a second call reported the machine not found.