Skip to content

fix(sfcompute): don't drop nodes on uninformative SSH errors - #173

Open
mmoulikk wants to merge 1 commit into
mainfrom
BREV-12600/sfcompute-dont-drop-nodes-on-ssh-errors
Open

mmoulikk wants to merge 1 commit into
mainfrom
BREV-12600/sfcompute-dont-drop-nodes-on-ssh-errors

Conversation

@mmoulikk

@mmoulikk mmoulikk commented Dec 3, 2026 •

Copy link
Copy Markdown
Contributor

Issue

SF Compute rate-limits GET /integrations/brev/v1/instances/{id}/ssh. When that lookup failed with anything other than the startup 404, ListInstances left the running node out of the list, and dev-plane reads a missing node as terminated. The environment flipped to instance_lost and back on the next poll. Between 23 and 27 Nov, 429s dropped running nodes 9,468 times across 28 VMs (logs). On 16 Nov, l4f6k04vy's node got 388 429s in about two hours, and a second terminated report moved the environment from instance_lost to terminated while its VM kept running (logs) (BREV-12600).

Root cause

ListInstances looks up SSH details for every running node on every poll, and skipped the node on any lookup error except the startup 404 handled in #163. A 429, 401, 403, 5xx or network error says nothing about whether the node exists, but it was treated the same as a node that's gone.

Fix

  • isUninformativeError (api_client.go) covers a 429, 401, 403, any 5xx, network errors and timeouts, a response cut off partway, and canceled or expired requests.
  • ListInstances (instance.go): when the SSH lookup fails with one of these, it logs sfcv2: ListInstances failing list due to SSH error with the instance ID and the error, waits one poll interval (failedListDelay, 5 s) and fails the whole list. dev-plane retries a failed list within 0.5 s, so the wait keeps those retries at the normal poll rate. A canceled request fails without waiting.
  • When the list fails, dev-plane changes nothing for that poll. Real terminations still come from the list itself, because the SSH lookup only runs for nodes SF Compute lists as running.
  • getSSHInfo (api_client.go) retries a 429 up to two more times, one second apart, as SF Compute's response asks ("Retry after 1 seconds"). No other error is retried. GetInstance uses the same lookup, so it gets the same retries.
  • A 404 within 45 minutes is still reported as pending (fix(sfcompute): keep starting nodes listed as pending on SSH 404 #163). A 404 after that, other 4xx errors and bad JSON still drop the node.
  • A conversion error now fails the list instead of dropping the node.

Test

  • Unit tests in api_client_test.go and instance_test.go, against a fake SF Compute API:
    • TestIsUninformativeError: 429, 401, 403, 5xx, network errors, cut-off responses and canceled or expired requests count; 404, 409 and bad JSON don't.
    • TestAPIClientRetriesOnlyRateLimitedSSHLookups: a 429 is tried three times, a 500 once.
    • TestAPIClientStopsRateLimitRetryWhenContextEnds: a canceled request stops waiting between retries.
    • TestListInstancesFailsInsteadOfDroppingInstanceOnUninformativeSSHError: a 429, 401, 500, 503 or dropped connection fails the list.
    • TestListInstancesDropsInstanceOnOtherSSHErrors: a 400 or bad JSON still drops only that node.
    • TestListInstancesKeepsRunningInstanceAfterRateLimitedSSHLookup: a node whose first lookup gets a 429 stays running with its SSH address.
    • TestListInstancesFailsWhenRequestIsCanceledPartWayThroughList: canceling partway through fails the list without waiting and returns nothing.
    • TestListInstancesLogsWarnBeforeFailingList: the Warn names the instance and the error.
    • TestListInstancesWaitsBeforeFailingList and TestMakeClientWaitsOnePollIntervalBeforeFailingList: the list waits one poll interval before failing.
    • TestListInstancesFailsOnConversionError: a conversion error fails the list.
  • go test ./v1/providers/sfcomputev2/ -race -count=1 and go vet ./... pass, and golangci-lint v2.6.0 (CI's version, run with Go 1.25.10) reports 0 issues.

dev1

  • Deployed dev-plane with this commit and created one SF Compute environment, 13rfpq18e, on a one-hour SF Compute reservation.
  • Right after creation, its node's SSH 404 was reported as pending, as before (log).
  • No node was dropped and no list failed after the deploy (logs).
  • When the reservation ended at 14:00 UTC, dev-plane recorded the node's new status at 14:00:02 and the environment went to instance_lost (log).
  • With one node, SF Compute didn't rate-limit the lookup on dev1, so the failure paths are covered by the unit tests only.

@mmoulikk mmoulikk self-assigned this Dec 3, 2026
@mmoulikk
mmoulikk marked this pull request as ready for review December 3, 2026 08:25
@mmoulikk
mmoulikk requested a review from a team as a code owner December 3, 2026 08:25
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