diff --git a/internal/fluidstack/v1/instancetype.go b/internal/fluidstack/v1/instancetype.go index eb2a90f..b8a1878 100644 --- a/internal/fluidstack/v1/instancetype.go +++ b/internal/fluidstack/v1/instancetype.go @@ -51,15 +51,13 @@ func (c *FluidStackClient) GetLocations(ctx context.Context, _ v1.GetLocationsAr } var locations []v1.Location - if resp != nil { - for _, capacity := range resp { - location := v1.Location{ - Name: capacity.Name, - Description: capacity.Name, - Available: capacity.Capacity > 0, - } - locations = append(locations, location) + for _, capacity := range resp { + location := v1.Location{ + Name: capacity.Name, + Description: capacity.Name, + Available: capacity.Capacity > 0, } + locations = append(locations, location) } return locations, nil diff --git a/pkg/v1/capabilities.go b/pkg/v1/capabilities.go index 7342e0d..e1aa3c0 100644 --- a/pkg/v1/capabilities.go +++ b/pkg/v1/capabilities.go @@ -1,37 +1,25 @@ package v1 +import "slices" + type Capability string type Capabilities []Capability func (c Capabilities) IsCapable(cc Capability) bool { - for _, capability := range c { - if capability == cc { - return true - } - } - return false + return slices.Contains(c, cc) } const ( CapabilityCreateInstance Capability = "create-instance" CapabilityCreateIdempotentInstance Capability = "create-instance-idempotent" + CapabilityCreateTerminateInstance Capability = "create-terminate-instance" + CapabilityInstanceUserData Capability = "instance-userdata" // specify user data when creating an instance in CreateInstanceAttrs // should be in instance type + CapabilityMachineImage Capability = "machine-image" + CapabilityModifyFirewall Capability = "modify-firewall" + CapabilityRebootInstance Capability = "reboot-instance" + CapabilityResizeInstanceVolume Capability = "resize-instance-volume" + CapabilityStopStartInstance Capability = "stop-start-instance" + CapabilityTags Capability = "tags" CapabilityTerminateInstance Capability = "terminate-instance" ) - -const ( - CapabilityCreateTerminateInstance Capability = "create-terminate-instance" - CapabilityInstanceUserData Capability = "instance-userdata" // specify user data when creating an instance in CreateInstanceAttrs // should be in instance type -) - -const CapabilityTags Capability = "tags" - -const CapabilityRebootInstance Capability = "reboot-instance" - -const CapabilityResizeInstanceVolume Capability = "resize-instance-volume" - -const CapabilityStopStartInstance Capability = "stop-start-instance" - -const CapabilityMachineImage Capability = "machine-image" - -const CapabilityModifyFirewall Capability = "modify-firewall" diff --git a/pkg/v1/client.go b/pkg/v1/client.go index 54be552..71e0771 100644 --- a/pkg/v1/client.go +++ b/pkg/v1/client.go @@ -13,33 +13,51 @@ const ( type CloudProviderID string // aws, gcp, azure, etc. -type CloudAPI interface { - GetAPIType() APIType - GetCapabilities(ctx context.Context) (Capabilities, error) - GetCloudProviderID() CloudProviderID +type CloudClient interface { + CloudCredential + ImageManager + InstanceManager + LocationManager + NetworkManager } type CloudCredential interface { MakeClient(ctx context.Context, location string) (CloudClient, error) GetTenantID() (string, error) GetReferenceID() string - CloudAPI + CloudProvider } -type CloudBase interface { - CloudCreateTerminateInstance +type CloudProvider interface { + GetAPIType() APIType + GetCapabilities(ctx context.Context) (Capabilities, error) + GetCloudProviderID() CloudProviderID } -type CloudClient interface { - CloudCredential - CloudBase - CloudQuota - CloudRebootInstance - CloudStopStartInstance - CloudResizeInstanceVolume - CloudMachineImage - CloudChangeInstanceType - CloudModifyFirewall - CloudInstanceTags - UpdateHandler +type ImageManager interface { + ImageGetter +} +type InstanceManager interface { + InstanceCreator + InstanceTerminator + InstanceGetter + InstanceLister + InstanceRebooter + InstanceStopStarter + InstanceTypeChanger + InstanceTagsUpdater + InstanceUpdateHandler + InstanceTypeGetter + InstanceTypePollTimeGetter + InstanceTypeQuotaGetter + InstanceVolumeResizer +} + +type LocationManager interface { + LocationGetter +} + +type NetworkManager interface { + NetworkFirewallModifier + NetworkSecurityGroupModifier } diff --git a/pkg/v1/image.go b/pkg/v1/image.go index 60778e1..515a881 100644 --- a/pkg/v1/image.go +++ b/pkg/v1/image.go @@ -10,7 +10,15 @@ import ( "github.com/brevdev/cloud/pkg/ssh" ) -type CloudMachineImage interface { +type Image struct { + ID string + Architecture string + Description string + Name string + CreatedAt time.Time +} + +type ImageGetter interface { GetImages(ctx context.Context, args GetImageArgs) ([]Image, error) } @@ -21,14 +29,6 @@ type GetImageArgs struct { ImageIDs []string } -type Image struct { - ID string - Architecture string - Description string - Name string - CreatedAt time.Time -} - func ValidateInstanceImage(ctx context.Context, instance Instance, privateKey string) error { sshClient, err := connectToInstance(ctx, instance, privateKey) if err != nil { diff --git a/pkg/v1/instance.go b/pkg/v1/instance.go index becf196..fb8c57e 100644 --- a/pkg/v1/instance.go +++ b/pkg/v1/instance.go @@ -12,23 +12,157 @@ import ( "github.com/google/uuid" ) -type CloudInstanceReader interface { +const ( + LifecycleStatusPending LifecycleStatus = "pending" + LifecycleStatusRunning LifecycleStatus = "running" + LifecycleStatusStopping LifecycleStatus = "stopping" + LifecycleStatusStopped LifecycleStatus = "stopped" + LifecycleStatusSuspending LifecycleStatus = "suspending" + LifecycleStatusSuspended LifecycleStatus = "suspended" + LifecycleStatusTerminating LifecycleStatus = "terminating" + LifecycleStatusTerminated LifecycleStatus = "terminated" + LifecycleStatusFailed LifecycleStatus = "failed" + + PendingToRunningTimeout = 20 * time.Minute + RunningToStoppedTimeout = 10 * time.Minute + StoppedToRunningTimeout = 20 * time.Minute + RunningToTerminatedTimeout = 20 * time.Minute + + runningSSHTimeout = 10 * time.Minute +) + +type Instance struct { + Name string + RefID string + CloudCredRefID string // cloudCred used to create the Instance + CreatedAt time.Time + CloudID CloudProviderInstanceID + IPAllocationID *string + PublicIP string // Public ip is not always returned from create, but will exist when instance is in running state + PublicDNS string + PrivateIP string + Hostname string + ImageID string + InstanceType string + DiskSize units.Base2Bytes + VolumeType string + PubKeyFingerprint string + SSHUser string + SSHPort int + Status Status + MetaEndpointEnabled bool + MetaTagsEnabled bool + VPCID string + SubnetID string + Spot bool + FirewallRules FirewallRules + RetiredAt *time.Time + RetireTimeout *time.Duration + LastStopTransitionTime *time.Time + Location string + SubLocation string + Tags Tags + Stoppable bool + Rebootable bool + IsContainer bool + UserPrivilegeEscalationDisabled bool + NotPrivileged bool + InstanceTypeID InstanceTypeID + AdditionalDisks []Disk + + // As of 08/26/2024 only used for Launchpad cloud. + // Because there is port forwarding from a GPU node to Bastion node, + // there is port mappings from the GPU node itself to the Bastion node. + // i.e. Verb SSH port 2222 is mapped to 2022 on the Bastion node + InternalPortMappings []PortMapping +} + +type Status struct { + LifecycleStatus LifecycleStatus + Messages []string +} + +type LifecycleStatus string + +type CloudProviderInstanceID string + +type InstanceGetter interface { GetInstance(ctx context.Context, id CloudProviderInstanceID) (*Instance, error) +} + +type InstanceLister interface { ListInstances(ctx context.Context, args ListInstancesArgs) ([]Instance, error) } -type CloudCreateTerminateInstance interface { - // CreateInstance expects an instance object to exist if successful, and no instance to exist if there is ANY error - // CloudClient Implementers: ensure that the instance is terminated if there is an error - // Public ip is not always returned from create, but will exist when instance is in running state +type ListInstancesArgs struct { + InstanceIDs []CloudProviderInstanceID + TagFilters map[string][]string + Locations LocationsFilter +} + +type InstanceCreator interface { CreateInstance(ctx context.Context, attrs CreateInstanceAttrs) (*Instance, error) - TerminateInstance(ctx context.Context, instanceID CloudProviderInstanceID) error // may or may not be locationally scoped - GetMaxCreateRequestsPerMinute() int - CloudInstanceType - CloudInstanceReader } -func ValidateCreateInstance(ctx context.Context, client CloudCreateTerminateInstance, attrs CreateInstanceAttrs) (*Instance, error) { +type CreateInstanceAttrs struct { + Location string + SubLocation string + Name string + RefID string // required also can be used for idempotency + VPCID string + SubnetID string + PublicKey string // must be in openssh format + KeyPairName *string + ImageID string + InstanceType string + UserDataBase64 string + DiskSize units.Base2Bytes + Tags Tags + FirewallRules FirewallRules + UseSpot bool + UsePersistentIP bool + UseMultiAttachVolume bool + RetireTimeout *time.Duration + // Additional Environment Variables. + // Note: As of May 2024, the only cloud provider we have this implemented for + // is the Akash provider. + AdditionalEnvVars map[string]string + AdditionalDisks []Disk +} + +type InstanceTerminator interface { + TerminateInstance(ctx context.Context, instanceID CloudProviderInstanceID) error +} + +type InstanceStopStarter interface { + StopInstance(ctx context.Context, instanceID CloudProviderInstanceID) error + StartInstance(ctx context.Context, instanceID CloudProviderInstanceID) error +} + +type InstanceRebooter interface { + RebootInstance(ctx context.Context, instanceID CloudProviderInstanceID) error +} + +type InstanceTypeChanger interface { + ChangeInstanceType(ctx context.Context, instanceID CloudProviderInstanceID, instanceType string) error +} + +type InstanceTagsUpdater interface { + UpdateInstanceTags(ctx context.Context, args UpdateInstanceTagsArgs) error +} + +type UpdateInstanceTagsArgs struct { + InstanceID CloudProviderInstanceID + Tags Tags +} + +// this is used by the control plane to efficiently update instances +type InstanceUpdateHandler interface { + MergeInstanceForUpdate(currInst Instance, newInst Instance) Instance + MergeInstanceTypeForUpdate(currIt InstanceType, newIt InstanceType) InstanceType +} + +func ValidateCreateInstance(ctx context.Context, client InstanceCreator, attrs CreateInstanceAttrs) (*Instance, error) { t0 := time.Now().Add(-time.Minute) attrs.RefID = uuid.New().String() name, err := makeDebuggableName(attrs.Name) @@ -71,7 +205,15 @@ func ValidateCreateInstance(ctx context.Context, client CloudCreateTerminateInst return i, validationErr } -func ValidateListCreatedInstance(ctx context.Context, client CloudCreateTerminateInstance, i *Instance) error { +func makeDebuggableName(name string) (string, error) { + pt, err := time.LoadLocation("America/Los_Angeles") + if err != nil { + return "", err + } + return fmt.Sprintf("%s-%s", name, time.Now().In(pt).Format("2006-01-02-15-04-05")), nil +} + +func ValidateListCreatedInstance(ctx context.Context, client InstanceLister, i *Instance) error { ins, err := client.ListInstances(ctx, ListInstancesArgs{ Locations: []string{i.Location}, }) @@ -102,7 +244,7 @@ func ValidateListCreatedInstance(ctx context.Context, client CloudCreateTerminat return validationErr } -func ValidateTerminateInstance(ctx context.Context, client CloudCreateTerminateInstance, instance *Instance) error { +func ValidateTerminateInstance(ctx context.Context, client InstanceTerminator, instance *Instance) error { err := client.TerminateInstance(ctx, instance.CloudID) if err != nil { return err @@ -111,12 +253,7 @@ func ValidateTerminateInstance(ctx context.Context, client CloudCreateTerminateI return nil } -type CloudStopStartInstance interface { - StopInstance(ctx context.Context, instanceID CloudProviderInstanceID) error - StartInstance(ctx context.Context, instanceID CloudProviderInstanceID) error -} - -func ValidateStopStartInstance(ctx context.Context, client CloudStopStartInstance, instance *Instance) error { +func ValidateStopStartInstance(ctx context.Context, client InstanceStopStarter, instance *Instance) error { err := client.StopInstance(ctx, instance.CloudID) if err != nil { return err @@ -130,25 +267,7 @@ func ValidateStopStartInstance(ctx context.Context, client CloudStopStartInstanc return nil } -type CloudRebootInstance interface { - RebootInstance(ctx context.Context, instanceID CloudProviderInstanceID) error -} - -type CloudChangeInstanceType interface { - ChangeInstanceType(ctx context.Context, instanceID CloudProviderInstanceID, instanceType string) error -} - -type CloudInstanceTags interface { - UpdateInstanceTags(ctx context.Context, args UpdateInstanceTagsArgs) error -} - -// this is used by the control plane to efficiently update instances -type UpdateHandler interface { - MergeInstanceForUpdate(currInst Instance, newInst Instance) Instance - MergeInstanceTypeForUpdate(currIt InstanceType, newIt InstanceType) InstanceType -} - -func ValidateMergeInstanceForUpdate(client UpdateHandler, currInst Instance, newInst Instance) error { +func ValidateMergeInstanceForUpdate(client InstanceUpdateHandler, currInst Instance, newInst Instance) error { mergedInst := client.MergeInstanceForUpdate(currInst, newInst) var validationErr error @@ -182,128 +301,7 @@ func ValidateMergeInstanceForUpdate(client UpdateHandler, currInst Instance, new return validationErr } -type Instance struct { - Name string - RefID string - CloudCredRefID string // cloudCred used to create the Instance - CreatedAt time.Time - CloudID CloudProviderInstanceID - IPAllocationID *string - PublicIP string // Public ip is not always returned from create, but will exist when instance is in running state - PublicDNS string - PrivateIP string - Hostname string - ImageID string - InstanceType string - DiskSize units.Base2Bytes - VolumeType string - PubKeyFingerprint string - SSHUser string - SSHPort int - Status Status - MetaEndpointEnabled bool - MetaTagsEnabled bool - VPCID string - SubnetID string - Spot bool - FirewallRules FirewallRules - RetiredAt *time.Time - RetireTimeout *time.Duration - LastStopTransitionTime *time.Time - Location string - SubLocation string - Tags Tags - Stoppable bool - Rebootable bool - IsContainer bool - UserPrivilegeEscalationDisabled bool - NotPrivileged bool - InstanceTypeID InstanceTypeID - AdditionalDisks []Disk - - // As of 08/26/2024 only used for Launchpad cloud. - // Because there is port forwarding from a GPU node to Bastion node, - // there is port mappings from the GPU node itself to the Bastion node. - // i.e. Verb SSH port 2222 is mapped to 2022 on the Bastion node - InternalPortMappings []PortMapping -} - -type Status struct { - LifecycleStatus LifecycleStatus - Messages []string -} - -type LifecycleStatus string - -const ( - LifecycleStatusPending LifecycleStatus = "pending" - LifecycleStatusRunning LifecycleStatus = "running" - LifecycleStatusStopping LifecycleStatus = "stopping" - LifecycleStatusStopped LifecycleStatus = "stopped" - LifecycleStatusSuspending LifecycleStatus = "suspending" - LifecycleStatusSuspended LifecycleStatus = "suspended" - LifecycleStatusTerminating LifecycleStatus = "terminating" - LifecycleStatusTerminated LifecycleStatus = "terminated" - LifecycleStatusFailed LifecycleStatus = "failed" -) - -const ( - PendingToRunningTimeout = 20 * time.Minute - RunningToStoppedTimeout = 10 * time.Minute - StoppedToRunningTimeout = 20 * time.Minute - RunningToTerminatedTimeout = 20 * time.Minute -) - -type CloudProviderInstanceID string - -type ListInstancesArgs struct { - InstanceIDs []CloudProviderInstanceID - TagFilters map[string][]string - Locations LocationsFilter -} - -type CreateInstanceAttrs struct { - Location string - SubLocation string - Name string - RefID string // required also can be used for idempotency - VPCID string - SubnetID string - PublicKey string // must be in openssh format - KeyPairName *string - ImageID string - InstanceType string - UserDataBase64 string - DiskSize units.Base2Bytes - Tags Tags - FirewallRules FirewallRules - UseSpot bool - UsePersistentIP bool - UseMultiAttachVolume bool - RetireTimeout *time.Duration - // Additional Environment Variables. - // Note: As of May 2024, the only cloud provider we have this implemented for - // is the Akash provider. - AdditionalEnvVars map[string]string - AdditionalDisks []Disk -} - -type UpdateInstanceTagsArgs struct { - InstanceID CloudProviderInstanceID - Tags Tags -} - -func makeDebuggableName(name string) (string, error) { - pt, err := time.LoadLocation("America/Los_Angeles") - if err != nil { - return "", err - } - return fmt.Sprintf("%s-%s", name, time.Now().In(pt).Format("2006-01-02-15-04-05")), nil -} - -const RunningSSHTimeout = 10 * time.Minute - -func ValidateInstanceSSHAccessible(ctx context.Context, client CloudInstanceReader, instance *Instance, privateKey string) error { +func ValidateInstanceSSHAccessible(ctx context.Context, client InstanceGetter, instance *Instance, privateKey string) error { var err error instance, err = WaitForInstanceLifecycleStatus(ctx, client, instance, LifecycleStatusRunning, PendingToRunningTimeout) if err != nil { @@ -328,7 +326,7 @@ func ValidateInstanceSSHAccessible(ctx context.Context, client CloudInstanceRead HostPort: fmt.Sprintf("%s:%d", publicIP, sshPort), PrivKey: privateKey, }, ssh.WaitForSSHOptions{ - Timeout: RunningSSHTimeout, + Timeout: runningSSHTimeout, }) if err != nil { return err diff --git a/pkg/v1/instancetype.go b/pkg/v1/instancetype.go index 5377718..1f8f9dd 100644 --- a/pkg/v1/instancetype.go +++ b/pkg/v1/instancetype.go @@ -48,28 +48,6 @@ type InstanceType struct { CanModifyFirewallRules bool } -func MakeGenericInstanceTypeID(instanceType InstanceType) InstanceTypeID { - if instanceType.ID != "" { - return instanceType.ID - } - subLoc := noSubLocation - if len(instanceType.AvailableAzs) > 0 { - subLoc = instanceType.AvailableAzs[0] - } - return InstanceTypeID(fmt.Sprintf("%s-%s-%s", instanceType.Location, subLoc, instanceType.Type)) -} - -func MakeGenericInstanceTypeIDFromInstance(instance Instance) InstanceTypeID { - if instance.InstanceTypeID != "" { - return instance.InstanceTypeID - } - subLoc := noSubLocation - if instance.SubLocation != "" { - subLoc = instance.SubLocation - } - return InstanceTypeID(fmt.Sprintf("%s-%s-%s", instance.Location, subLoc, instance.InstanceType)) -} - type GPU struct { Count int32 Memory units.Base2Bytes @@ -86,10 +64,8 @@ type InstanceTypeQuota struct { Reserved Quota } -type CloudInstanceType interface { +type InstanceTypeGetter interface { GetInstanceTypes(ctx context.Context, args GetInstanceTypeArgs) ([]InstanceType, error) - GetInstanceTypePollTime() time.Duration - CloudLocation } type GetInstanceTypeArgs struct { @@ -98,9 +74,35 @@ type GetInstanceTypeArgs struct { InstanceTypes []string } +type InstanceTypePollTimeGetter interface { + GetInstanceTypePollTime() time.Duration +} + +func MakeGenericInstanceTypeID(instanceType InstanceType) InstanceTypeID { + if instanceType.ID != "" { + return instanceType.ID + } + subLoc := noSubLocation + if len(instanceType.AvailableAzs) > 0 { + subLoc = instanceType.AvailableAzs[0] + } + return InstanceTypeID(fmt.Sprintf("%s-%s-%s", instanceType.Location, subLoc, instanceType.Type)) +} + +func MakeGenericInstanceTypeIDFromInstance(instance Instance) InstanceTypeID { + if instance.InstanceTypeID != "" { + return instance.InstanceTypeID + } + subLoc := noSubLocation + if instance.SubLocation != "" { + subLoc = instance.SubLocation + } + return InstanceTypeID(fmt.Sprintf("%s-%s-%s", instance.Location, subLoc, instance.InstanceType)) +} + // ValidateGetInstanceTypes validates that the GetInstanceTypes functionality works correctly // by testing that filtering by specific instance types returns the expected results -func ValidateGetInstanceTypes(ctx context.Context, client CloudInstanceType) error { //nolint:funlen,gocyclo // todo refactor +func ValidateGetInstanceTypes(ctx context.Context, client InstanceTypeGetter) error { //nolint:funlen,gocyclo // todo refactor // Get all instance types first allTypes, err := client.GetInstanceTypes(ctx, GetInstanceTypeArgs{}) if err != nil { @@ -207,7 +209,7 @@ func ValidateGetInstanceTypes(ctx context.Context, client CloudInstanceType) err // ValidateLocationalInstanceTypes validates that locational filtering works correctly // by comparing locational results with all-location results using CloudLocation capabilities -func ValidateLocationalInstanceTypes(ctx context.Context, client CloudInstanceType) error { +func ValidateLocationalInstanceTypes(ctx context.Context, client InstanceTypeGetter) error { // Get all-location instance types by requesting from all locations allLocationTypes, err := client.GetInstanceTypes(ctx, GetInstanceTypeArgs{ Locations: All, @@ -278,7 +280,7 @@ func normalizeInstanceTypes(types []InstanceType) []InstanceType { // ValidateStableInstanceTypeIDs validates that the provided stable instance type IDs are valid and stable // This function ensures that stable IDs exist in the current instance types and have required properties -func ValidateStableInstanceTypeIDs(ctx context.Context, client CloudInstanceType, stableIDs []InstanceTypeID) error { +func ValidateStableInstanceTypeIDs(ctx context.Context, client InstanceTypeGetter, stableIDs []InstanceTypeID) error { // Get all instance types allTypes, err := client.GetInstanceTypes(ctx, GetInstanceTypeArgs{}) if err != nil { diff --git a/pkg/v1/location.go b/pkg/v1/location.go index 5518595..72a4985 100644 --- a/pkg/v1/location.go +++ b/pkg/v1/location.go @@ -5,13 +5,7 @@ import ( "fmt" ) -type CloudLocation interface { - GetLocations(ctx context.Context, args GetLocationsArgs) ([]Location, error) -} - -type GetLocationsArgs struct { - IncludeUnavailable bool -} +var All = []string{"all"} type Location struct { Name string // basically the id @@ -24,7 +18,13 @@ type Location struct { type LocationsFilter []string -var All = []string{"all"} +type LocationGetter interface { + GetLocations(ctx context.Context, args GetLocationsArgs) ([]Location, error) +} + +type GetLocationsArgs struct { + IncludeUnavailable bool +} func (l LocationsFilter) IsAll() bool { for _, v := range l { @@ -36,7 +36,7 @@ func (l LocationsFilter) IsAll() bool { } // ValidateGetLocations validates that the CloudLocation implementation returns at least one available location without error. -func ValidateGetLocations(ctx context.Context, client CloudLocation) error { +func ValidateGetLocations(ctx context.Context, client LocationGetter) error { locs, err := client.GetLocations(ctx, GetLocationsArgs{}) if err != nil { return err diff --git a/pkg/v1/networking.go b/pkg/v1/networking.go index 5b03e1e..516e87d 100644 --- a/pkg/v1/networking.go +++ b/pkg/v1/networking.go @@ -2,11 +2,15 @@ package v1 import "context" -type CloudModifyFirewall interface { +type NetworkFirewallModifier interface { AddFirewallRulesToInstance(ctx context.Context, args AddFirewallRulesToInstanceArgs) error RevokeSecurityGroupRules(ctx context.Context, args RevokeSecurityGroupRuleArgs) error } +type NetworkSecurityGroupModifier interface { + RevokeSecurityGroupRules(ctx context.Context, args RevokeSecurityGroupRuleArgs) error +} + type AddFirewallRulesToInstanceArgs struct { InstanceID CloudProviderInstanceID FirewallRules FirewallRules diff --git a/pkg/v1/quota.go b/pkg/v1/quota.go index 68ad592..88d70bd 100644 --- a/pkg/v1/quota.go +++ b/pkg/v1/quota.go @@ -2,7 +2,7 @@ package v1 import "context" -type CloudQuota interface { +type InstanceTypeQuotaGetter interface { GetInstanceTypeQuotas(ctx context.Context, args GetInstanceTypeQuotasArgs) (Quota, error) } diff --git a/pkg/v1/storage.go b/pkg/v1/storage.go index 05f7750..4d668d8 100644 --- a/pkg/v1/storage.go +++ b/pkg/v1/storage.go @@ -26,7 +26,7 @@ type Disk struct { MountPath string } -type CloudResizeInstanceVolume interface { +type InstanceVolumeResizer interface { ResizeInstanceVolume(ctx context.Context, args ResizeInstanceVolumeArgs) error } diff --git a/pkg/v1/waiters.go b/pkg/v1/waiters.go index baf3de4..8b29f5c 100644 --- a/pkg/v1/waiters.go +++ b/pkg/v1/waiters.go @@ -6,7 +6,7 @@ import ( ) func WaitForInstanceLifecycleStatus(ctx context.Context, - client CloudInstanceReader, + client InstanceGetter, instance *Instance, status LifecycleStatus, timeout time.Duration, diff --git a/pkg/v1/waiters_test.go b/pkg/v1/waiters_test.go index 3339253..46459fc 100644 --- a/pkg/v1/waiters_test.go +++ b/pkg/v1/waiters_test.go @@ -73,11 +73,6 @@ func (m *mockCloudInstanceReader) GetInstance(_ context.Context, id CloudProvide return nil, errors.New("instance not found") } -func (m *mockCloudInstanceReader) ListInstances(_ context.Context, _ ListInstancesArgs) ([]Instance, error) { - // Not used in tests, but required by interface - return nil, nil -} - // setStatusSequence sets up a sequence of statuses that will be returned for an instance func (m *mockCloudInstanceReader) setStatusSequence(instanceID CloudProviderInstanceID, sequence []LifecycleStatus) { m.statusSequence[instanceID] = sequence