Repository navigation
Conversation
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.
Issue
SF Compute rate-limits
GET /integrations/brev/v1/instances/{id}/ssh. When that lookup failed with anything other than the startup404,ListInstancesleft the running node out of the list, and dev-plane reads a missing node asterminated. The environment flipped toinstance_lostand 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 388429s in about two hours, and a second terminated report moved the environment frominstance_losttoterminatedwhile its VM kept running (logs) (BREV-12600).Root cause
ListInstanceslooks up SSH details for every running node on every poll, and skipped the node on any lookup error except the startup404handled in #163. A429,401,403,5xxor 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 a429,401,403, any5xx, 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 logssfcv2: ListInstances failing list due to SSH errorwith 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.running.getSSHInfo(api_client.go) retries a429up to two more times, one second apart, as SF Compute's response asks ("Retry after 1 seconds"). No other error is retried.GetInstanceuses the same lookup, so it gets the same retries.404within 45 minutes is still reported aspending(fix(sfcompute): keep starting nodes listed as pending on SSH 404 #163). A404after that, other4xxerrors and bad JSON still drop the node.Test
api_client_test.goandinstance_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,409and bad JSON don't.TestAPIClientRetriesOnlyRateLimitedSSHLookups: a429is tried three times, a500once.TestAPIClientStopsRateLimitRetryWhenContextEnds: a canceled request stops waiting between retries.TestListInstancesFailsInsteadOfDroppingInstanceOnUninformativeSSHError: a429,401,500,503or dropped connection fails the list.TestListInstancesDropsInstanceOnOtherSSHErrors: a400or bad JSON still drops only that node.TestListInstancesKeepsRunningInstanceAfterRateLimitedSSHLookup: a node whose first lookup gets a429staysrunningwith its SSH address.TestListInstancesFailsWhenRequestIsCanceledPartWayThroughList: canceling partway through fails the list without waiting and returns nothing.TestListInstancesLogsWarnBeforeFailingList: the Warn names the instance and the error.TestListInstancesWaitsBeforeFailingListandTestMakeClientWaitsOnePollIntervalBeforeFailingList: the list waits one poll interval before failing.TestListInstancesFailsOnConversionError: a conversion error fails the list.go test ./v1/providers/sfcomputev2/ -race -count=1andgo vet ./...pass, and golangci-lint v2.6.0 (CI's version, run with Go 1.25.10) reports 0 issues.dev1
13rfpq18e, on a one-hour SF Compute reservation.404was reported aspending, as before (log).instance_lost(log).