Skip to content

Comments

Implement FluidStack provider with OpenAPI client generation#13

Merged
theFong merged 4 commits intomainfrom
devin/1754433691-implement-fluidstack-provider
Aug 6, 2025
Merged

Implement FluidStack provider with OpenAPI client generation#13
theFong merged 4 commits intomainfrom
devin/1754433691-implement-fluidstack-provider

Conversation

@devin-ai-integration
Copy link
Contributor

Implement FluidStack provider with OpenAPI client generation

Summary

This PR implements the FluidStack cloud provider following the established Lambda Labs pattern. Key components include:

  • OpenAPI client generation: Added Makefile target to generate Go client from FluidStack's API specification
  • Core provider methods: Implemented all required instance management operations (create, get, list, terminate, reboot)
  • Authentication: Bearer token authentication via makeAuthContext method
  • Project scoping: X-PROJECT-ID header handling for FluidStack's multi-project API
  • Type conversions: Conversion functions between FluidStack API types and SDK v1 types
  • Generated client fixes: Resolved naming conflicts in generated constants

The implementation generates the OpenAPI client from https://docs.atlas.fluidstack.io/redocusaurus/infrastructure-api.yaml using openapi-generator-cli v7.8.0, following the exact pattern used for Lambda Labs.

Review & Testing Checklist for Human

🔴 High Risk - Requires Manual Testing

  • Test with real FluidStack credentials: The entire implementation is based on OpenAPI spec analysis and hasn't been tested with actual API calls
  • Verify project ID handling: Currently hardcoded to "default-project-id" - needs proper project ID configuration
  • Validate type conversions with real data: Memory parsing, GPU handling, and instance state mapping need validation against actual API responses
  • Test authentication flow: Bearer token authentication pattern needs verification with FluidStack's auth requirements
  • Verify OpenAPI spec URL accessibility: Ensure the API specification URL is stable and publicly accessible

Recommended test plan:

  1. Set up FluidStack account and obtain API credentials
  2. Test basic instance lifecycle: create → get → list → terminate
  3. Test instance types and locations retrieval
  4. Verify GPU instance type handling
  5. Test error scenarios (invalid credentials, non-existent instances, etc.)

Diagram

%%{ init : { "theme" : "default" }}%%
graph TD
    Makefile["internal/fluidstack/Makefile<br/>OpenAPI Client Generation"]:::major-edit
    Client["internal/fluidstack/v1/client.go<br/>FluidStackClient + Auth"]:::major-edit
    Instance["internal/fluidstack/v1/instance.go<br/>Instance Operations"]:::major-edit
    InstanceType["internal/fluidstack/v1/instancetype.go<br/>Instance Types + Locations"]:::major-edit
    Generated["internal/fluidstack/gen/fluidstack/<br/>Generated OpenAPI Client"]:::major-edit
    
    V1Client["pkg/v1/client.go<br/>CloudClient Interface"]:::context
    V1Instance["pkg/v1/instance.go<br/>Instance Types"]:::context
    V1InstanceType["pkg/v1/instancetype.go<br/>InstanceType Types"]:::context
    
    Makefile -->|generates| Generated
    Client -->|uses| Generated
    Instance -->|uses| Generated
    InstanceType -->|uses| Generated
    
    Client -.->|implements| V1Client
    Instance -.->|converts to| V1Instance
    InstanceType -.->|converts to| V1InstanceType
    
    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:#FFFFFF
Loading

Notes

  • Generated client modifications: Manual fixes were applied to resolve DELETING constant conflicts between ProjectState and InstanceState enums
  • Reboot implementation: Uses stop → sleep(5s) → start sequence, which may need adjustment based on FluidStack's instance startup times
  • Memory parsing: Assumes memory strings end with "GB" suffix - needs validation with real API responses
  • GPU handling: Supports both GPU model and count from FluidStack's instance type specification

Session Details:

- Add Makefile for FluidStack OpenAPI client generation following Lambda Labs pattern
- Generate Go client from FluidStack API specification at https://docs.atlas.fluidstack.io/redocusaurus/infrastructure-api.yaml
- Implement all required instance management methods:
  - CreateInstance using InstancesPostRequest
  - GetInstance, TerminateInstance, ListInstances
  - RebootInstance via stop/start sequence
- Add Bearer token authentication via makeAuthContext
- Handle project scoping via X-PROJECT-ID header
- Add type conversions from FluidStack API types to SDK v1 types
- Fix naming conflicts in generated constants (PROJECT_*, INSTANCE_*)
- Support GPU instance types with proper memory and count handling

Co-Authored-By: Alec Fong <alecsanf@usc.edu>
@devin-ai-integration
Copy link
Contributor Author

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment and CI monitoring

devin-ai-integration bot and others added 2 commits August 5, 2025 22:53
- Update incorrect import from 'github.com/brevdev/cloud' to correct path
- Follow Lambda Labs pattern for generated client imports
- Resolves go mod tidy failure in CI

Co-Authored-By: Alec Fong <alecsanf@usc.edu>
- Fix assignment mismatch for DeleteInstance, StartInstance, StopInstance (2-value returns)
- Add HTTP response body closure to all API calls with proper error handling
- Use underscore for unused parameters to satisfy revive linter
- Fix function signature to not return unnecessary error
- Resolve integer overflow, formatting, and errcheck issues

Co-Authored-By: Alec Fong <alecsanf@usc.edu>
}

func (c *FluidStackClient) RebootInstance(_ context.Context, _ v1.CloudProviderInstanceID) error {
return v1.ErrNotImplemented
func (c *FluidStackClient) RebootInstance(ctx context.Context, instanceID v1.CloudProviderInstanceID) error {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if there is not reboot api call lets remove this and remove the capability

- Add v1.CapabilityInstanceUserData to capabilities since FluidStack API supports UserData
- Replace RebootInstance implementation with ErrNotImplemented since FluidStack has no native reboot API
- Remove unused time import from instance.go
- Align capabilities with actual FluidStack API features per @theFong feedback

Co-Authored-By: Alec Fong <alecsanf@usc.edu>
@theFong theFong merged commit e6b64ba into main Aug 6, 2025
4 checks passed
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