Conversation
- Add retry logic to AddSSHKey, LaunchInstance, GetInstance, TerminateInstance, ListInstances, and RestartInstance API calls - Use existing retry infrastructure: collections.RetryWithDataAndAttemptCount and getBackoff() - Apply consistent error handling with handleAPIError for all retry-wrapped functions - Follow same pattern as existing GetInstanceTypes retry implementation - Add proper lint annotations for deferred response body cleanup This ensures all Lambda Labs API calls have the same resilience and retry behavior, improving reliability when dealing with transient network issues or API rate limits. Co-Authored-By: Alec Fong <alecsanf@usc.edu>
Contributor
Author
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
theFong
approved these changes
Aug 9, 2025
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.
Implement retry logic for all Lambda Labs API calls
Summary
This PR extends the existing retry logic pattern from
GetInstanceTypesto all other Lambda Labs API calls. Previously, only theGetInstanceTypesmethod had retry logic implemented, leaving other critical operations like instance creation, termination, and management vulnerable to transient network issues or API rate limits.Changes made:
AddSSHKey,LaunchInstance,GetInstance,TerminateInstance,ListInstances, andRestartInstancegetInstanceTypescollections.RetryWithDataAndAttemptCount,getBackoff(), andhandleAPIError()collectionsimportFiles modified:
internal/lambdalabs/v1/instance.go- Main implementation with 6 new retry-wrapped functionsReview & Testing Checklist for Human
getInstanceTypesimplementation to ensure identical patternshandleAPIErrorusageAddSSHKeyretry logic works properlyRecommended test plan: Create a test instance, perform various operations (reboot, get status), then terminate it while monitoring for any unexpected errors or timeouts.
Diagram
%%{ init : { "theme" : "default" }}%% graph TD subgraph "Lambda Labs Provider" Instance["internal/lambdalabs/v1/<br/>instance.go"]:::major-edit InstanceType["internal/lambdalabs/v1/<br/>instancetype.go"]:::context Client["internal/lambdalabs/v1/<br/>client.go"]:::context Errors["internal/lambdalabs/v1/<br/>errors.go"]:::context end subgraph "Retry Infrastructure" Collections["internal/collections/<br/>RetryWithDataAndAttemptCount"]:::context Backoff["getBackoff()"]:::context ErrorHandler["handleAPIError()"]:::context end subgraph "API Operations" CreateOp["CreateInstance<br/>(LaunchInstance + AddSSHKey)"]:::major-edit GetOp["GetInstance"]:::major-edit ListOp["ListInstances"]:::major-edit TerminateOp["TerminateInstance"]:::major-edit RebootOp["RebootInstance<br/>(RestartInstance)"]:::major-edit GetTypesOp["GetInstanceTypes<br/>(existing pattern)"]:::context end Instance --> CreateOp Instance --> GetOp Instance --> ListOp Instance --> TerminateOp Instance --> RebootOp CreateOp --> Collections GetOp --> Collections ListOp --> Collections TerminateOp --> Collections RebootOp --> Collections GetTypesOp --> Collections Collections --> Backoff Collections --> ErrorHandler Client --> Backoff Errors --> ErrorHandler subgraph Legend L1["Major Edit"]:::major-edit L2["Minor Edit"]:::minor-edit L3["Context/No Edit"]:::context end classDef major-edit fill:#90EE90 classDef minor-edit fill:#87CEEB classDef context fill:#FFFFFFNotes
getInstanceTypesmethod