From 5e444495f4546b0a8fa974ddcfe4def8b482a2c4 Mon Sep 17 00:00:00 2001 From: Drew Malin Date: Wed, 5 Nov 2025 14:12:16 -0800 Subject: [PATCH 01/14] feat(BREV-2083): Capture both byte value and unit in size --- v1/bytes.go | 40 ++++++++++++++++++++++++++ v1/instance.go | 3 +- v1/providers/lambdalabs/instance.go | 14 +++++++-- v1/providers/launchpad/instance_get.go | 25 ++++++++++------ v1/providers/shadeform/instance.go | 32 +++++++++++++-------- 5 files changed, 89 insertions(+), 25 deletions(-) create mode 100644 v1/bytes.go diff --git a/v1/bytes.go b/v1/bytes.go new file mode 100644 index 00000000..40196616 --- /dev/null +++ b/v1/bytes.go @@ -0,0 +1,40 @@ +package v1 + +var ZeroBytes = NewByteValue(0, Byte) + +type ByteValue struct { + // Value is the whole non-negative number of bytes of the specified unit + value uint64 + + // Unit is the unit of the byte value + unit ByteUnit +} + +func NewByteValue(value uint64, unit ByteUnit) ByteValue { + return ByteValue{ + value: value, + unit: unit, + } +} + +type ByteUnit string + +const ( + Byte ByteUnit = "B" + + // Base 10 + Kilobyte ByteUnit = "KB" + Megabyte ByteUnit = "MB" + Gigabyte ByteUnit = "GB" + Terabyte ByteUnit = "TB" + Petabyte ByteUnit = "PB" + Exabyte ByteUnit = "EB" + + // Base 2 + Kibibyte ByteUnit = "KiB" + Mebibyte ByteUnit = "MiB" + Gibibyte ByteUnit = "GiB" + Tebibyte ByteUnit = "TiB" + Pebibyte ByteUnit = "PiB" + Exbibyte ByteUnit = "EiB" +) diff --git a/v1/instance.go b/v1/instance.go index bf769cfa..cc513a36 100644 --- a/v1/instance.go +++ b/v1/instance.go @@ -195,7 +195,8 @@ type Instance struct { Hostname string ImageID string InstanceType string - DiskSize units.Base2Bytes + DiskSize units.Base2Bytes // TODO: deprecate in favor of DiskSizeByteValue + DiskSizeByteValue ByteValue VolumeType string PubKeyFingerprint string SSHUser string diff --git a/v1/providers/lambdalabs/instance.go b/v1/providers/lambdalabs/instance.go index 6b153ebf..f36183f3 100644 --- a/v1/providers/lambdalabs/instance.go +++ b/v1/providers/lambdalabs/instance.go @@ -164,6 +164,13 @@ func convertLambdaLabsInstanceToV1Instance(instance openapi.Instance) *v1.Instan instancePrivateIP = *instance.PrivateIp.Get() } + var diskSizeByteValue v1.ByteValue + if instance.InstanceType.Specs.StorageGib > 0 { + diskSizeByteValue = v1.NewByteValue(uint64(instance.InstanceType.Specs.StorageGib), v1.Gibibyte) + } else { + diskSizeByteValue = v1.ZeroBytes + } + inst := v1.Instance{ RefID: instance.SshKeyNames[0], CloudCredRefID: cloudCredRefID, @@ -177,9 +184,10 @@ func convertLambdaLabsInstanceToV1Instance(instance openapi.Instance) *v1.Instan Status: v1.Status{ LifecycleStatus: convertLambdaLabsStatusToV1Status(instance.Status), }, - InstanceType: instance.InstanceType.Name, - VolumeType: "ssd", - DiskSize: units.GiB * units.Base2Bytes(instance.InstanceType.Specs.StorageGib), + InstanceType: instance.InstanceType.Name, + VolumeType: "ssd", + DiskSize: units.GiB * units.Base2Bytes(instance.InstanceType.Specs.StorageGib), + DiskSizeByteValue: diskSizeByteValue, FirewallRules: v1.FirewallRules{ IngressRules: []v1.FirewallRule{generateFirewallRouteFromPort(22), generateFirewallRouteFromPort(2222)}, // TODO pull from api EgressRules: []v1.FirewallRule{generateFirewallRouteFromPort(22), generateFirewallRouteFromPort(2222)}, // TODO pull from api diff --git a/v1/providers/launchpad/instance_get.go b/v1/providers/launchpad/instance_get.go index fa190dac..63acbfa5 100644 --- a/v1/providers/launchpad/instance_get.go +++ b/v1/providers/launchpad/instance_get.go @@ -44,20 +44,26 @@ func launchpadDeploymentToInstance(deployment *openapi.Deployment) (v1.Instance, return v1.Instance{}, errors.WrapAndTrace(err) } - var diskSize units.Base2Bytes + var totalStorageSize int nodes := deployment.GetCluster().Cluster.GetNodes() if len(nodes) == 0 { - diskSize = 0 + totalStorageSize = 0 } else { node := nodes[0] // Calculate disk size storage := node.Node.GetStorage() - size := 0 for _, s := range storage { - size += int(s.GetSize()) + totalStorageSize += int(s.GetSize()) } - diskSize = units.Base2Bytes(size) * units.GiB + } + diskSize := units.Base2Bytes(totalStorageSize) * units.GiB + + var diskSizeByteValue v1.ByteValue + if totalStorageSize > 0 { + diskSizeByteValue = v1.NewByteValue(uint64(totalStorageSize), v1.Gigabyte) + } else { + diskSizeByteValue = v1.ZeroBytes } inst := v1.Instance{ @@ -78,10 +84,11 @@ func launchpadDeploymentToInstance(deployment *openapi.Deployment) (v1.Instance, ToPort: 2022, }, }, - DiskSize: diskSize, - Location: deployment.GetRegion(), - PublicDNS: deployment.GetCluster().Cluster.GetPublicAddress(), - PublicIP: deployment.GetCluster().Cluster.GetPublicAddress(), + DiskSize: diskSize, + DiskSizeByteValue: diskSizeByteValue, + Location: deployment.GetRegion(), + PublicDNS: deployment.GetCluster().Cluster.GetPublicAddress(), + PublicIP: deployment.GetCluster().Cluster.GetPublicAddress(), } cluster := deployment.GetCluster().Cluster diff --git a/v1/providers/shadeform/instance.go b/v1/providers/shadeform/instance.go index 8175cd6c..3387b873 100644 --- a/v1/providers/shadeform/instance.go +++ b/v1/providers/shadeform/instance.go @@ -284,19 +284,27 @@ func (c *ShadeformClient) convertInstanceInfoResponseToV1Instance(ctx context.Co diskSize := units.Base2Bytes(instanceInfo.Configuration.StorageInGb) * units.GiB c.logger.Debug(ctx, "calculated diskSize", v1.LogField("diskSize", diskSize), v1.LogField("storageInGb", instanceInfo.Configuration.StorageInGb)) + var diskSizeByteValue v1.ByteValue + if instanceInfo.Configuration.StorageInGb > 0 { + diskSizeByteValue = v1.NewByteValue(uint64(instanceInfo.Configuration.StorageInGb), v1.Gigabyte) + } else { + diskSizeByteValue = v1.ZeroBytes + } + instance := &v1.Instance{ - Name: c.getProvidedInstanceName(instanceInfo.Name), - CreatedAt: instanceInfo.CreatedAt, - CloudID: v1.CloudProviderInstanceID(instanceInfo.Id), - PublicIP: instanceInfo.Ip, - PublicDNS: instanceInfo.Ip, - Hostname: hostname, - ImageID: instanceInfo.Configuration.Os, - InstanceType: instanceType, - InstanceTypeID: v1.InstanceTypeID(c.getInstanceTypeID(instanceType, instanceInfo.Region)), - DiskSize: diskSize, - SSHUser: instanceInfo.SshUser, - SSHPort: int(instanceInfo.SshPort), + Name: c.getProvidedInstanceName(instanceInfo.Name), + CreatedAt: instanceInfo.CreatedAt, + CloudID: v1.CloudProviderInstanceID(instanceInfo.Id), + PublicIP: instanceInfo.Ip, + PublicDNS: instanceInfo.Ip, + Hostname: hostname, + ImageID: instanceInfo.Configuration.Os, + InstanceType: instanceType, + InstanceTypeID: v1.InstanceTypeID(c.getInstanceTypeID(instanceType, instanceInfo.Region)), + DiskSize: diskSize, + DiskSizeByteValue: diskSizeByteValue, + SSHUser: instanceInfo.SshUser, + SSHPort: int(instanceInfo.SshPort), Status: v1.Status{ LifecycleStatus: lifeCycleStatus, }, From b779132982956f09337a8c721fe6e0dbee8032df Mon Sep 17 00:00:00 2001 From: Drew Malin Date: Wed, 5 Nov 2025 14:28:03 -0800 Subject: [PATCH 02/14] implement memory --- v1/bytes.go | 11 +++++++---- v1/instancetype.go | 5 +++-- v1/providers/fluidstack/instancetype.go | 21 ++++++++++++--------- v1/providers/lambdalabs/instance.go | 9 +-------- v1/providers/lambdalabs/instancetype.go | 9 ++++++--- v1/providers/launchpad/instance_get.go | 16 ++++------------ v1/providers/launchpad/instancetype.go | 11 ++++++++--- v1/providers/shadeform/instance.go | 9 +-------- v1/providers/shadeform/instancetype.go | 16 +++++++++------- v1/storage.go | 9 ++++++--- 10 files changed, 57 insertions(+), 59 deletions(-) diff --git a/v1/bytes.go b/v1/bytes.go index 40196616..639025a5 100644 --- a/v1/bytes.go +++ b/v1/bytes.go @@ -1,18 +1,21 @@ package v1 -var ZeroBytes = NewByteValue(0, Byte) +var zeroBytes ByteValue = ByteValue{value: 0, unit: Byte} type ByteValue struct { // Value is the whole non-negative number of bytes of the specified unit - value uint64 + value uint32 // Unit is the unit of the byte value unit ByteUnit } -func NewByteValue(value uint64, unit ByteUnit) ByteValue { +func NewByteValue(value int32, unit ByteUnit) ByteValue { + if value < 0 { + return zeroBytes + } return ByteValue{ - value: value, + value: uint32(value), unit: unit, } } diff --git a/v1/instancetype.go b/v1/instancetype.go index 3cf6e82d..dd547932 100644 --- a/v1/instancetype.go +++ b/v1/instancetype.go @@ -64,7 +64,8 @@ type InstanceType struct { SupportedStorage []Storage ElasticRootVolume bool SupportedUsageClasses []string - Memory units.Base2Bytes + Memory units.Base2Bytes // TODO: deprecate in favor of MemoryByteValue + MemoryByteValue ByteValue MaximumNetworkInterfaces int32 NetworkPerformance string SupportedNumCores []int32 @@ -427,7 +428,7 @@ func ValidateStableInstanceTypeIDs(ctx context.Context, client CloudInstanceType // Check that supported storage has price information for i, storage := range instanceType.SupportedStorage { - if storage.MinSize != nil { + if storage.MinSize != nil || storage.MinSizeByteValue != nil { if storage.PricePerGBHr == nil { return fmt.Errorf("instance type %s should have storage %d price", instanceType.ID, i) } diff --git a/v1/providers/fluidstack/instancetype.go b/v1/providers/fluidstack/instancetype.go index 4f04bce5..90a646ee 100644 --- a/v1/providers/fluidstack/instancetype.go +++ b/v1/providers/fluidstack/instancetype.go @@ -82,12 +82,14 @@ func convertFluidStackInstanceTypeToV1InstanceType(location string, fsInstanceTy } } + var memoryByteValue v1.ByteValue var ram units.Base2Bytes if fsInstanceType.Memory != "" { memoryStr := strings.TrimSuffix(fsInstanceType.Memory, "GB") memoryStr = strings.TrimSpace(memoryStr) if memoryGB, err := strconv.ParseFloat(memoryStr, 64); err == nil { ram = units.Base2Bytes(memoryGB) * units.Gibibyte + memoryByteValue = v1.NewByteValue(int32(memoryGB), v1.Gigabyte) } } @@ -99,14 +101,15 @@ func convertFluidStackInstanceTypeToV1InstanceType(location string, fsInstanceTy price, _ := currency.NewAmount("0", "USD") return v1.InstanceType{ - Type: fsInstanceType.Name, - VCPU: vcpus, - Memory: ram, - SupportedGPUs: gpus, - BasePrice: &price, - IsAvailable: isAvailable, - Location: location, - Provider: CloudProviderID, - Cloud: CloudProviderID, + Type: fsInstanceType.Name, + VCPU: vcpus, + Memory: ram, + MemoryByteValue: memoryByteValue, + SupportedGPUs: gpus, + BasePrice: &price, + IsAvailable: isAvailable, + Location: location, + Provider: CloudProviderID, + Cloud: CloudProviderID, } } diff --git a/v1/providers/lambdalabs/instance.go b/v1/providers/lambdalabs/instance.go index f36183f3..df890a8e 100644 --- a/v1/providers/lambdalabs/instance.go +++ b/v1/providers/lambdalabs/instance.go @@ -164,13 +164,6 @@ func convertLambdaLabsInstanceToV1Instance(instance openapi.Instance) *v1.Instan instancePrivateIP = *instance.PrivateIp.Get() } - var diskSizeByteValue v1.ByteValue - if instance.InstanceType.Specs.StorageGib > 0 { - diskSizeByteValue = v1.NewByteValue(uint64(instance.InstanceType.Specs.StorageGib), v1.Gibibyte) - } else { - diskSizeByteValue = v1.ZeroBytes - } - inst := v1.Instance{ RefID: instance.SshKeyNames[0], CloudCredRefID: cloudCredRefID, @@ -187,7 +180,7 @@ func convertLambdaLabsInstanceToV1Instance(instance openapi.Instance) *v1.Instan InstanceType: instance.InstanceType.Name, VolumeType: "ssd", DiskSize: units.GiB * units.Base2Bytes(instance.InstanceType.Specs.StorageGib), - DiskSizeByteValue: diskSizeByteValue, + DiskSizeByteValue: v1.NewByteValue(instance.InstanceType.Specs.StorageGib, v1.Gibibyte), FirewallRules: v1.FirewallRules{ IngressRules: []v1.FirewallRule{generateFirewallRouteFromPort(22), generateFirewallRouteFromPort(2222)}, // TODO pull from api EgressRules: []v1.FirewallRule{generateFirewallRouteFromPort(22), generateFirewallRouteFromPort(2222)}, // TODO pull from api diff --git a/v1/providers/lambdalabs/instancetype.go b/v1/providers/lambdalabs/instancetype.go index 6b79fbb6..27c5ebac 100644 --- a/v1/providers/lambdalabs/instancetype.go +++ b/v1/providers/lambdalabs/instancetype.go @@ -172,19 +172,22 @@ func convertLambdaLabsInstanceTypeToV1InstanceType(location string, instType ope if err != nil { return v1.InstanceType{}, err } + it := v1.InstanceType{ Location: location, Type: instType.Name, SupportedGPUs: gpus, SupportedStorage: []v1.Storage{ { - Type: "ssd", - Count: 1, - Size: units.GiB * units.Base2Bytes(instType.Specs.StorageGib), + Type: "ssd", + Count: 1, + Size: units.GiB * units.Base2Bytes(instType.Specs.StorageGib), + SizeByteValue: v1.NewByteValue(instType.Specs.StorageGib, v1.Gibibyte), }, }, SupportedUsageClasses: []string{"on-demand"}, Memory: units.GiB * units.Base2Bytes(instType.Specs.MemoryGib), + MemoryByteValue: v1.NewByteValue(instType.Specs.MemoryGib, v1.Gibibyte), MaximumNetworkInterfaces: 0, NetworkPerformance: "", SupportedNumCores: []int32{}, diff --git a/v1/providers/launchpad/instance_get.go b/v1/providers/launchpad/instance_get.go index 63acbfa5..ce70d11b 100644 --- a/v1/providers/launchpad/instance_get.go +++ b/v1/providers/launchpad/instance_get.go @@ -44,7 +44,7 @@ func launchpadDeploymentToInstance(deployment *openapi.Deployment) (v1.Instance, return v1.Instance{}, errors.WrapAndTrace(err) } - var totalStorageSize int + var totalStorageSize int32 nodes := deployment.GetCluster().Cluster.GetNodes() if len(nodes) == 0 { totalStorageSize = 0 @@ -54,17 +54,9 @@ func launchpadDeploymentToInstance(deployment *openapi.Deployment) (v1.Instance, // Calculate disk size storage := node.Node.GetStorage() for _, s := range storage { - totalStorageSize += int(s.GetSize()) + totalStorageSize += s.GetSize() } } - diskSize := units.Base2Bytes(totalStorageSize) * units.GiB - - var diskSizeByteValue v1.ByteValue - if totalStorageSize > 0 { - diskSizeByteValue = v1.NewByteValue(uint64(totalStorageSize), v1.Gigabyte) - } else { - diskSizeByteValue = v1.ZeroBytes - } inst := v1.Instance{ Name: getValueFromTags("Name", tags), @@ -84,8 +76,8 @@ func launchpadDeploymentToInstance(deployment *openapi.Deployment) (v1.Instance, ToPort: 2022, }, }, - DiskSize: diskSize, - DiskSizeByteValue: diskSizeByteValue, + DiskSize: units.Base2Bytes(totalStorageSize) * units.GiB, + DiskSizeByteValue: v1.NewByteValue(totalStorageSize, v1.Gigabyte), Location: deployment.GetRegion(), PublicDNS: deployment.GetCluster().Cluster.GetPublicAddress(), PublicIP: deployment.GetCluster().Cluster.GetPublicAddress(), diff --git a/v1/providers/launchpad/instancetype.go b/v1/providers/launchpad/instancetype.go index 22c58266..fee2eda4 100644 --- a/v1/providers/launchpad/instancetype.go +++ b/v1/providers/launchpad/instancetype.go @@ -204,6 +204,7 @@ func launchpadInstanceTypeToInstanceType(launchpadInstanceType openapi.InstanceT Type: typeName, VCPU: launchpadInstanceType.Cpu, Memory: gbToBytes(launchpadInstanceType.MemoryGb), + MemoryByteValue: v1.NewByteValue(launchpadInstanceType.MemoryGb, v1.Gigabyte), SupportedGPUs: []v1.GPU{gpu}, SupportedStorage: storage, SupportedArchitectures: []v1.Architecture{launchpadArchitectureToArchitecture(launchpadInstanceType.SystemArch)}, @@ -242,9 +243,10 @@ func launchpadStorageToStorages(launchpadStorage []openapi.InstanceTypeStorage) storage := make([]v1.Storage, len(launchpadStorage)) for i, s := range launchpadStorage { storage[i] = v1.Storage{ - Count: 1, - Size: gbToBytes(s.SizeGb), - Type: string(s.Type), + Count: 1, + Size: gbToBytes(s.SizeGb), + SizeByteValue: v1.NewByteValue(s.SizeGb, v1.Gigabyte), + Type: string(s.Type), } } return storage @@ -307,8 +309,10 @@ func launchpadClusterToInstanceType(cluster openapi.Cluster) *v1.InstanceType { vcpu = *node.Cpu } var memory units.Base2Bytes + var memoryValueBytes v1.ByteValue if node.Memory != nil { memory = gbToBytes(*node.Memory) + memoryValueBytes = v1.NewByteValue(*node.Memory, v1.Gigabyte) } isAvailable := (cluster.ProvisioningState != nil && *cluster.ProvisioningState == openapi.ProvisioningStateReady) @@ -328,6 +332,7 @@ func launchpadClusterToInstanceType(cluster openapi.Cluster) *v1.InstanceType { SupportedGPUs: []v1.GPU{*gpu}, SupportedStorage: storage, Memory: memory, + MemoryByteValue: memoryValueBytes, VCPU: vcpu, IsAvailable: isAvailable, Location: location, diff --git a/v1/providers/shadeform/instance.go b/v1/providers/shadeform/instance.go index 3387b873..0a4aefad 100644 --- a/v1/providers/shadeform/instance.go +++ b/v1/providers/shadeform/instance.go @@ -284,13 +284,6 @@ func (c *ShadeformClient) convertInstanceInfoResponseToV1Instance(ctx context.Co diskSize := units.Base2Bytes(instanceInfo.Configuration.StorageInGb) * units.GiB c.logger.Debug(ctx, "calculated diskSize", v1.LogField("diskSize", diskSize), v1.LogField("storageInGb", instanceInfo.Configuration.StorageInGb)) - var diskSizeByteValue v1.ByteValue - if instanceInfo.Configuration.StorageInGb > 0 { - diskSizeByteValue = v1.NewByteValue(uint64(instanceInfo.Configuration.StorageInGb), v1.Gigabyte) - } else { - diskSizeByteValue = v1.ZeroBytes - } - instance := &v1.Instance{ Name: c.getProvidedInstanceName(instanceInfo.Name), CreatedAt: instanceInfo.CreatedAt, @@ -302,7 +295,7 @@ func (c *ShadeformClient) convertInstanceInfoResponseToV1Instance(ctx context.Co InstanceType: instanceType, InstanceTypeID: v1.InstanceTypeID(c.getInstanceTypeID(instanceType, instanceInfo.Region)), DiskSize: diskSize, - DiskSizeByteValue: diskSizeByteValue, + DiskSizeByteValue: v1.NewByteValue(instanceInfo.Configuration.StorageInGb, v1.Gigabyte), SSHUser: instanceInfo.SshUser, SSHPort: int(instanceInfo.SshPort), Status: v1.Status{ diff --git a/v1/providers/shadeform/instancetype.go b/v1/providers/shadeform/instancetype.go index 7be4ae63..0d237ee1 100644 --- a/v1/providers/shadeform/instancetype.go +++ b/v1/providers/shadeform/instancetype.go @@ -225,10 +225,11 @@ func (c *ShadeformClient) convertShadeformInstanceTypeToV1InstanceType(shadeform for _, region := range shadeformInstanceType.Availability { instanceTypes = append(instanceTypes, v1.InstanceType{ - ID: v1.InstanceTypeID(c.getInstanceTypeID(instanceType, region.Region)), - Type: instanceType, - VCPU: shadeformInstanceType.Configuration.Vcpus, - Memory: units.Base2Bytes(shadeformInstanceType.Configuration.MemoryInGb) * units.GiB, + ID: v1.InstanceTypeID(c.getInstanceTypeID(instanceType, region.Region)), + Type: instanceType, + VCPU: shadeformInstanceType.Configuration.Vcpus, + Memory: units.Base2Bytes(shadeformInstanceType.Configuration.MemoryInGb) * units.GiB, + MemoryByteValue: v1.NewByteValue(shadeformInstanceType.Configuration.MemoryInGb, v1.Gigabyte), SupportedGPUs: []v1.GPU{ { Count: shadeformInstanceType.Configuration.NumGpus, @@ -242,9 +243,10 @@ func (c *ShadeformClient) convertShadeformInstanceTypeToV1InstanceType(shadeform }, SupportedStorage: []v1.Storage{ // TODO: add storage (look in configuration) { - Type: "ssd", - Count: 1, - Size: units.Base2Bytes(shadeformInstanceType.Configuration.StorageInGb) * units.GiB, + Type: "ssd", + Count: 1, + Size: units.Base2Bytes(shadeformInstanceType.Configuration.StorageInGb) * units.GiB, + SizeByteValue: v1.NewByteValue(shadeformInstanceType.Configuration.StorageInGb, v1.Gigabyte), }, }, SupportedArchitectures: []v1.Architecture{architecture}, diff --git a/v1/storage.go b/v1/storage.go index 05f7750d..764640f0 100644 --- a/v1/storage.go +++ b/v1/storage.go @@ -9,10 +9,13 @@ import ( type Storage struct { Count int32 - Size units.Base2Bytes + Size units.Base2Bytes // TODO: deprecate in favor of SizeByteValue + SizeByteValue ByteValue Type string - MinSize *units.Base2Bytes - MaxSize *units.Base2Bytes + MinSize *units.Base2Bytes // TODO: deprecate in favor of MinSizeByteValue + MinSizeByteValue *ByteValue + MaxSize *units.Base2Bytes // TODO: deprecate in favor of MaxSizeByteValue + MaxSizeByteValue *ByteValue PricePerGBHr *currency.Amount IsEphemeral bool IsAdditionalDisk bool From 3cb9dca420e3d21e648e30b4826c748a9b785acb Mon Sep 17 00:00:00 2001 From: Drew Malin Date: Wed, 5 Nov 2025 14:47:41 -0800 Subject: [PATCH 03/14] lint --- v1/bytes.go | 2 +- v1/instancetype.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/v1/bytes.go b/v1/bytes.go index 639025a5..ba729742 100644 --- a/v1/bytes.go +++ b/v1/bytes.go @@ -1,6 +1,6 @@ package v1 -var zeroBytes ByteValue = ByteValue{value: 0, unit: Byte} +var zeroBytes = ByteValue{value: 0, unit: Byte} type ByteValue struct { // Value is the whole non-negative number of bytes of the specified unit diff --git a/v1/instancetype.go b/v1/instancetype.go index dd547932..993393b5 100644 --- a/v1/instancetype.go +++ b/v1/instancetype.go @@ -379,7 +379,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 CloudInstanceType, stableIDs []InstanceTypeID) error { //nolint:gocyclo // test // Get all instance types allTypes, err := client.GetInstanceTypes(ctx, GetInstanceTypeArgs{}) if err != nil { From 9dd02d51209098994bdfabf58d99a7f52784c2f8 Mon Sep 17 00:00:00 2001 From: Drew Malin Date: Wed, 5 Nov 2025 14:53:52 -0800 Subject: [PATCH 04/14] include gpu memory --- v1/instancetype.go | 15 ++++++++------- v1/providers/lambdalabs/instancetype.go | 1 + v1/providers/launchpad/instancetype.go | 13 +++++++------ v1/providers/shadeform/instancetype.go | 15 ++++++++------- 4 files changed, 24 insertions(+), 20 deletions(-) diff --git a/v1/instancetype.go b/v1/instancetype.go index 993393b5..d011fe59 100644 --- a/v1/instancetype.go +++ b/v1/instancetype.go @@ -114,13 +114,14 @@ func MakeGenericInstanceTypeIDFromInstance(instance Instance) InstanceTypeID { } type GPU struct { - Count int32 - Memory units.Base2Bytes - MemoryDetails string // "", "HBM", "GDDR", "DDR", etc. - NetworkDetails string // "PCIe", "SXM4", "SXM5", etc. - Manufacturer Manufacturer - Name string - Type string + Count int32 + Memory units.Base2Bytes // TODO: deprecate in favor of MemoryByteValue + MemoryByteValue ByteValue + MemoryDetails string // "", "HBM", "GDDR", "DDR", etc. + NetworkDetails string // "PCIe", "SXM4", "SXM5", etc. + Manufacturer Manufacturer + Name string + Type string } type InstanceTypeQuota struct { diff --git a/v1/providers/lambdalabs/instancetype.go b/v1/providers/lambdalabs/instancetype.go index 27c5ebac..f2b6b6c4 100644 --- a/v1/providers/lambdalabs/instancetype.go +++ b/v1/providers/lambdalabs/instancetype.go @@ -128,6 +128,7 @@ func parseGPUFromDescription(input string) (v1.GPU, error) { memoryStr := memoryMatch[1] memoryGiB, _ := strconv.Atoi(memoryStr) gpu.Memory = units.GiB * units.Base2Bytes(memoryGiB) + gpu.MemoryByteValue = v1.NewByteValue(int32(memoryGiB), v1.Gibibyte) // Extract the network details networkRegex := regexp.MustCompile(`(\w+\s?)+\)`) diff --git a/v1/providers/launchpad/instancetype.go b/v1/providers/launchpad/instancetype.go index fee2eda4..69fb49d6 100644 --- a/v1/providers/launchpad/instancetype.go +++ b/v1/providers/launchpad/instancetype.go @@ -259,12 +259,13 @@ func launchpadGpusToGpus(lpGpus []openapi.InstanceTypeGpu) []v1.GPU { gpus := make([]v1.GPU, len(lpGpus)) for i, gp := range lpGpus { gpus[i] = v1.GPU{ - Name: strings.ToUpper(gp.Family), - Manufacturer: v1.GetManufacturer(gp.Manufacturer), - Count: gp.Count, - Memory: gbToBytes(gp.MemoryGb), - NetworkDetails: string(gp.InterconnectionType), - Type: strings.ToUpper(gp.Model), + Name: strings.ToUpper(gp.Family), + Manufacturer: v1.GetManufacturer(gp.Manufacturer), + Count: gp.Count, + Memory: gbToBytes(gp.MemoryGb), + MemoryByteValue: v1.NewByteValue(gp.MemoryGb, v1.Gigabyte), + NetworkDetails: string(gp.InterconnectionType), + Type: strings.ToUpper(gp.Model), } } return gpus diff --git a/v1/providers/shadeform/instancetype.go b/v1/providers/shadeform/instancetype.go index 0d237ee1..5f8aba7d 100644 --- a/v1/providers/shadeform/instancetype.go +++ b/v1/providers/shadeform/instancetype.go @@ -232,13 +232,14 @@ func (c *ShadeformClient) convertShadeformInstanceTypeToV1InstanceType(shadeform MemoryByteValue: v1.NewByteValue(shadeformInstanceType.Configuration.MemoryInGb, v1.Gigabyte), SupportedGPUs: []v1.GPU{ { - Count: shadeformInstanceType.Configuration.NumGpus, - Memory: units.Base2Bytes(shadeformInstanceType.Configuration.VramPerGpuInGb) * units.GiB, - MemoryDetails: "", - NetworkDetails: shadeformInstanceType.Configuration.Interconnect, - Manufacturer: gpuManufacturer, - Name: gpuName, - Type: shadeformInstanceType.Configuration.GpuType, + Count: shadeformInstanceType.Configuration.NumGpus, + Memory: units.Base2Bytes(shadeformInstanceType.Configuration.VramPerGpuInGb) * units.GiB, + MemoryByteValue: v1.NewByteValue(shadeformInstanceType.Configuration.VramPerGpuInGb, v1.Gigabyte), + MemoryDetails: "", + NetworkDetails: shadeformInstanceType.Configuration.Interconnect, + Manufacturer: gpuManufacturer, + Name: gpuName, + Type: shadeformInstanceType.Configuration.GpuType, }, }, SupportedStorage: []v1.Storage{ // TODO: add storage (look in configuration) From 799b781c5b786e19b9651e5bc7eca93b38c3a40e Mon Sep 17 00:00:00 2001 From: Drew Malin Date: Wed, 5 Nov 2025 14:55:26 -0800 Subject: [PATCH 05/14] include gpu memory --- v1/providers/launchpad/instancetype.go | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/v1/providers/launchpad/instancetype.go b/v1/providers/launchpad/instancetype.go index 69fb49d6..491c9601 100644 --- a/v1/providers/launchpad/instancetype.go +++ b/v1/providers/launchpad/instancetype.go @@ -365,16 +365,19 @@ func launchpadGputoGpu(node openapi.Node) *v1.GPU { } var lpGpuMemory units.Base2Bytes + var lpGpuMemoryByteValue v1.ByteValue if lpGpu.Memory != nil { lpGpuMemory = gbToBytes(*lpGpu.Memory) + lpGpuMemoryByteValue = v1.NewByteValue(*lpGpu.Memory, v1.Gigabyte) } gpu := &v1.GPU{ - Name: lpGpuModel, - Count: lpGpuCount, - NetworkDetails: lpGpuFormFactor, - Memory: lpGpuMemory, - Manufacturer: "NVIDIA", // The only supported manufacturer for Launchpad + Name: lpGpuModel, + Count: lpGpuCount, + NetworkDetails: lpGpuFormFactor, + Memory: lpGpuMemory, + MemoryByteValue: lpGpuMemoryByteValue, + Manufacturer: "NVIDIA", // The only supported manufacturer for Launchpad } return gpu } From df5fca29a6df2d98c1fb0a0440d1fb994e678886 Mon Sep 17 00:00:00 2001 From: Drew Malin Date: Wed, 5 Nov 2025 15:19:25 -0800 Subject: [PATCH 06/14] check for overflow --- v1/providers/lambdalabs/instancetype.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/v1/providers/lambdalabs/instancetype.go b/v1/providers/lambdalabs/instancetype.go index f2b6b6c4..543e5d65 100644 --- a/v1/providers/lambdalabs/instancetype.go +++ b/v1/providers/lambdalabs/instancetype.go @@ -3,6 +3,7 @@ package v1 import ( "context" "fmt" + "math" "regexp" "strconv" "strings" @@ -127,6 +128,9 @@ func parseGPUFromDescription(input string) (v1.GPU, error) { } memoryStr := memoryMatch[1] memoryGiB, _ := strconv.Atoi(memoryStr) + if memoryGiB > math.MaxInt32 { + memoryGiB = math.MaxInt32 + } gpu.Memory = units.GiB * units.Base2Bytes(memoryGiB) gpu.MemoryByteValue = v1.NewByteValue(int32(memoryGiB), v1.Gibibyte) From 1bd20d19a53b6737b0ee77d985ca44264ee1b1c7 Mon Sep 17 00:00:00 2001 From: Drew Malin Date: Wed, 5 Nov 2025 15:21:50 -0800 Subject: [PATCH 07/14] lint --- v1/providers/lambdalabs/instancetype.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/v1/providers/lambdalabs/instancetype.go b/v1/providers/lambdalabs/instancetype.go index 543e5d65..ff7ecb1f 100644 --- a/v1/providers/lambdalabs/instancetype.go +++ b/v1/providers/lambdalabs/instancetype.go @@ -131,7 +131,7 @@ func parseGPUFromDescription(input string) (v1.GPU, error) { if memoryGiB > math.MaxInt32 { memoryGiB = math.MaxInt32 } - gpu.Memory = units.GiB * units.Base2Bytes(memoryGiB) + gpu.Memory = units.GiB * units.Base2Bytes(memoryGiB) //nolint:gosec // safe conversion gpu.MemoryByteValue = v1.NewByteValue(int32(memoryGiB), v1.Gibibyte) // Extract the network details From 6b5ecf55943679a49c5ec48afb3da6e14087900a Mon Sep 17 00:00:00 2001 From: Drew Malin Date: Wed, 5 Nov 2025 15:24:31 -0800 Subject: [PATCH 08/14] lint --- v1/providers/lambdalabs/instancetype.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/v1/providers/lambdalabs/instancetype.go b/v1/providers/lambdalabs/instancetype.go index ff7ecb1f..3a3a9106 100644 --- a/v1/providers/lambdalabs/instancetype.go +++ b/v1/providers/lambdalabs/instancetype.go @@ -131,8 +131,8 @@ func parseGPUFromDescription(input string) (v1.GPU, error) { if memoryGiB > math.MaxInt32 { memoryGiB = math.MaxInt32 } - gpu.Memory = units.GiB * units.Base2Bytes(memoryGiB) //nolint:gosec // safe conversion - gpu.MemoryByteValue = v1.NewByteValue(int32(memoryGiB), v1.Gibibyte) + gpu.Memory = units.GiB * units.Base2Bytes(memoryGiB) + gpu.MemoryByteValue = v1.NewByteValue(int32(memoryGiB), v1.Gibibyte) //nolint:gosec // safe conversion // Extract the network details networkRegex := regexp.MustCompile(`(\w+\s?)+\)`) From a5a3a3ad6992d7e9b633336e1ab54537b32c1635 Mon Sep 17 00:00:00 2001 From: Drew Malin Date: Wed, 5 Nov 2025 15:28:35 -0800 Subject: [PATCH 09/14] createinstanceattrs --- v1/instance.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/v1/instance.go b/v1/instance.go index cc513a36..558d1250 100644 --- a/v1/instance.go +++ b/v1/instance.go @@ -275,7 +275,8 @@ type CreateInstanceAttrs struct { ImageID string InstanceType string UserDataBase64 string - DiskSize units.Base2Bytes + DiskSize units.Base2Bytes // TODO: deprecate in favor of DiskSizeByteValue + DiskSizeByteValue ByteValue Tags Tags FirewallRules FirewallRules UseSpot bool From ff154e84a0e37ec404277cba3b2497960e9d9ac4 Mon Sep 17 00:00:00 2001 From: Drew Malin Date: Wed, 5 Nov 2025 15:36:00 -0800 Subject: [PATCH 10/14] disk --- v1/storage.go | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/v1/storage.go b/v1/storage.go index 764640f0..bf4e4732 100644 --- a/v1/storage.go +++ b/v1/storage.go @@ -24,9 +24,10 @@ type Storage struct { } type Disk struct { - Size units.Base2Bytes - Type string - MountPath string + Size units.Base2Bytes // TODO: deprecate in favor of SizeByteValue + SizeByteValue ByteValue + Type string + MountPath string } type CloudResizeInstanceVolume interface { @@ -35,6 +36,7 @@ type CloudResizeInstanceVolume interface { type ResizeInstanceVolumeArgs struct { InstanceID CloudProviderInstanceID - Size units.Base2Bytes + Size units.Base2Bytes // TODO: deprecate in favor of SizeByteValue + SizeByteValue ByteValue WaitForOptimizing bool } From 88d08683e9016bda8f583f6a3246d714b8b91207 Mon Sep 17 00:00:00 2001 From: Drew Malin Date: Wed, 5 Nov 2025 17:02:16 -0800 Subject: [PATCH 11/14] interface --- v1/bytes.go | 36 ++++++++++++++++++++++++++---------- 1 file changed, 26 insertions(+), 10 deletions(-) diff --git a/v1/bytes.go b/v1/bytes.go index ba729742..b2d07522 100644 --- a/v1/bytes.go +++ b/v1/bytes.go @@ -1,25 +1,41 @@ package v1 -var zeroBytes = ByteValue{value: 0, unit: Byte} - -type ByteValue struct { - // Value is the whole non-negative number of bytes of the specified unit - value uint32 - - // Unit is the unit of the byte value - unit ByteUnit -} +var zeroBytes = byteValue{value: 0, unit: Byte} +// NewByteValue creates a new ByteValue with the given value and unit func NewByteValue(value int32, unit ByteUnit) ByteValue { if value < 0 { return zeroBytes } - return ByteValue{ + return byteValue{ value: uint32(value), unit: unit, } } +// ByteValue is a value that represents a number of bytes +type ByteValue interface { + // Value is the whole non-negative number of bytes of the specified unit + Value() uint32 + + // Unit is the unit of the byte value + Unit() ByteUnit +} + +type byteValue struct { + value uint32 + unit ByteUnit +} + +func (b byteValue) Value() uint32 { + return b.value +} + +func (b byteValue) Unit() ByteUnit { + return b.unit +} + +// ByteUnit is a unit of measurement for bytes type ByteUnit string const ( From 02a06e6baea865c4a7b0b9711dc599809bcea193 Mon Sep 17 00:00:00 2001 From: Drew Malin Date: Wed, 5 Nov 2025 17:17:51 -0800 Subject: [PATCH 12/14] no pointers to interfaces --- v1/storage.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/v1/storage.go b/v1/storage.go index bf4e4732..87987b53 100644 --- a/v1/storage.go +++ b/v1/storage.go @@ -13,9 +13,9 @@ type Storage struct { SizeByteValue ByteValue Type string MinSize *units.Base2Bytes // TODO: deprecate in favor of MinSizeByteValue - MinSizeByteValue *ByteValue + MinSizeByteValue ByteValue MaxSize *units.Base2Bytes // TODO: deprecate in favor of MaxSizeByteValue - MaxSizeByteValue *ByteValue + MaxSizeByteValue ByteValue PricePerGBHr *currency.Amount IsEphemeral bool IsAdditionalDisk bool From f1cb4ad32e7d0458b3f45078b8a9a5528451e7de Mon Sep 17 00:00:00 2001 From: Drew Malin Date: Thu, 6 Nov 2025 09:51:04 -0800 Subject: [PATCH 13/14] remove interface, move to int64 --- v1/bytes.go | 63 ++++++++++++------------- v1/instance.go | 4 +- v1/instancetype.go | 4 +- v1/providers/fluidstack/instancetype.go | 6 +-- v1/providers/lambdalabs/instance.go | 2 +- v1/providers/lambdalabs/instancetype.go | 6 +-- v1/providers/launchpad/instance_get.go | 2 +- v1/providers/launchpad/instancetype.go | 14 +++--- v1/providers/shadeform/instance.go | 2 +- v1/providers/shadeform/instancetype.go | 6 +-- v1/storage.go | 10 ++-- 11 files changed, 58 insertions(+), 61 deletions(-) diff --git a/v1/bytes.go b/v1/bytes.go index b2d07522..f1a1895e 100644 --- a/v1/bytes.go +++ b/v1/bytes.go @@ -1,59 +1,56 @@ package v1 -var zeroBytes = byteValue{value: 0, unit: Byte} +var zeroBytes = Bytes{value: 0, unit: Byte} -// NewByteValue creates a new ByteValue with the given value and unit -func NewByteValue(value int32, unit ByteUnit) ByteValue { +// NewBytes creates a new Bytes with the given value and unit +func NewBytes(value BytesValue, unit BytesUnit) Bytes { if value < 0 { return zeroBytes } - return byteValue{ - value: uint32(value), + return Bytes{ + value: value, unit: unit, } } -// ByteValue is a value that represents a number of bytes -type ByteValue interface { - // Value is the whole non-negative number of bytes of the specified unit - Value() uint32 - - // Unit is the unit of the byte value - Unit() ByteUnit -} +type ( + BytesValue int64 + BytesUnit string +) -type byteValue struct { - value uint32 - unit ByteUnit +// Bytes represents a number of some unit of bytes +type Bytes struct { + value BytesValue + unit BytesUnit } -func (b byteValue) Value() uint32 { +// Value is the whole non-negative number of bytes of the specified unit +func (b Bytes) Value() BytesValue { return b.value } -func (b byteValue) Unit() ByteUnit { +// Unit is the unit of the byte value +func (b Bytes) Unit() BytesUnit { return b.unit } // ByteUnit is a unit of measurement for bytes -type ByteUnit string - const ( - Byte ByteUnit = "B" + Byte BytesUnit = "B" // Base 10 - Kilobyte ByteUnit = "KB" - Megabyte ByteUnit = "MB" - Gigabyte ByteUnit = "GB" - Terabyte ByteUnit = "TB" - Petabyte ByteUnit = "PB" - Exabyte ByteUnit = "EB" + Kilobyte BytesUnit = "KB" + Megabyte BytesUnit = "MB" + Gigabyte BytesUnit = "GB" + Terabyte BytesUnit = "TB" + Petabyte BytesUnit = "PB" + Exabyte BytesUnit = "EB" // Base 2 - Kibibyte ByteUnit = "KiB" - Mebibyte ByteUnit = "MiB" - Gibibyte ByteUnit = "GiB" - Tebibyte ByteUnit = "TiB" - Pebibyte ByteUnit = "PiB" - Exbibyte ByteUnit = "EiB" + Kibibyte BytesUnit = "KiB" + Mebibyte BytesUnit = "MiB" + Gibibyte BytesUnit = "GiB" + Tebibyte BytesUnit = "TiB" + Pebibyte BytesUnit = "PiB" + Exbibyte BytesUnit = "EiB" ) diff --git a/v1/instance.go b/v1/instance.go index 558d1250..0c95d82d 100644 --- a/v1/instance.go +++ b/v1/instance.go @@ -196,7 +196,7 @@ type Instance struct { ImageID string InstanceType string DiskSize units.Base2Bytes // TODO: deprecate in favor of DiskSizeByteValue - DiskSizeByteValue ByteValue + DiskSizeByteValue Bytes VolumeType string PubKeyFingerprint string SSHUser string @@ -276,7 +276,7 @@ type CreateInstanceAttrs struct { InstanceType string UserDataBase64 string DiskSize units.Base2Bytes // TODO: deprecate in favor of DiskSizeByteValue - DiskSizeByteValue ByteValue + DiskSizeByteValue Bytes Tags Tags FirewallRules FirewallRules UseSpot bool diff --git a/v1/instancetype.go b/v1/instancetype.go index d011fe59..94c85b1c 100644 --- a/v1/instancetype.go +++ b/v1/instancetype.go @@ -65,7 +65,7 @@ type InstanceType struct { ElasticRootVolume bool SupportedUsageClasses []string Memory units.Base2Bytes // TODO: deprecate in favor of MemoryByteValue - MemoryByteValue ByteValue + MemoryByteValue Bytes MaximumNetworkInterfaces int32 NetworkPerformance string SupportedNumCores []int32 @@ -116,7 +116,7 @@ func MakeGenericInstanceTypeIDFromInstance(instance Instance) InstanceTypeID { type GPU struct { Count int32 Memory units.Base2Bytes // TODO: deprecate in favor of MemoryByteValue - MemoryByteValue ByteValue + MemoryByteValue Bytes MemoryDetails string // "", "HBM", "GDDR", "DDR", etc. NetworkDetails string // "PCIe", "SXM4", "SXM5", etc. Manufacturer Manufacturer diff --git a/v1/providers/fluidstack/instancetype.go b/v1/providers/fluidstack/instancetype.go index 90a646ee..00c4feab 100644 --- a/v1/providers/fluidstack/instancetype.go +++ b/v1/providers/fluidstack/instancetype.go @@ -9,7 +9,7 @@ import ( "github.com/alecthomas/units" "github.com/bojanz/currency" - "github.com/brevdev/cloud/v1" + v1 "github.com/brevdev/cloud/v1" openapi "github.com/brevdev/cloud/v1/providers/fluidstack/gen/fluidstack" ) @@ -82,14 +82,14 @@ func convertFluidStackInstanceTypeToV1InstanceType(location string, fsInstanceTy } } - var memoryByteValue v1.ByteValue + var memoryByteValue v1.Bytes var ram units.Base2Bytes if fsInstanceType.Memory != "" { memoryStr := strings.TrimSuffix(fsInstanceType.Memory, "GB") memoryStr = strings.TrimSpace(memoryStr) if memoryGB, err := strconv.ParseFloat(memoryStr, 64); err == nil { ram = units.Base2Bytes(memoryGB) * units.Gibibyte - memoryByteValue = v1.NewByteValue(int32(memoryGB), v1.Gigabyte) + memoryByteValue = v1.NewBytes(v1.BytesValue(memoryGB), v1.Gigabyte) } } diff --git a/v1/providers/lambdalabs/instance.go b/v1/providers/lambdalabs/instance.go index df890a8e..6aadbfcb 100644 --- a/v1/providers/lambdalabs/instance.go +++ b/v1/providers/lambdalabs/instance.go @@ -180,7 +180,7 @@ func convertLambdaLabsInstanceToV1Instance(instance openapi.Instance) *v1.Instan InstanceType: instance.InstanceType.Name, VolumeType: "ssd", DiskSize: units.GiB * units.Base2Bytes(instance.InstanceType.Specs.StorageGib), - DiskSizeByteValue: v1.NewByteValue(instance.InstanceType.Specs.StorageGib, v1.Gibibyte), + DiskSizeByteValue: v1.NewBytes(v1.BytesValue(instance.InstanceType.Specs.StorageGib), v1.Gibibyte), FirewallRules: v1.FirewallRules{ IngressRules: []v1.FirewallRule{generateFirewallRouteFromPort(22), generateFirewallRouteFromPort(2222)}, // TODO pull from api EgressRules: []v1.FirewallRule{generateFirewallRouteFromPort(22), generateFirewallRouteFromPort(2222)}, // TODO pull from api diff --git a/v1/providers/lambdalabs/instancetype.go b/v1/providers/lambdalabs/instancetype.go index 3a3a9106..b1a064d8 100644 --- a/v1/providers/lambdalabs/instancetype.go +++ b/v1/providers/lambdalabs/instancetype.go @@ -132,7 +132,7 @@ func parseGPUFromDescription(input string) (v1.GPU, error) { memoryGiB = math.MaxInt32 } gpu.Memory = units.GiB * units.Base2Bytes(memoryGiB) - gpu.MemoryByteValue = v1.NewByteValue(int32(memoryGiB), v1.Gibibyte) //nolint:gosec // safe conversion + gpu.MemoryByteValue = v1.NewBytes(v1.BytesValue(memoryGiB), v1.Gibibyte) // Extract the network details networkRegex := regexp.MustCompile(`(\w+\s?)+\)`) @@ -187,12 +187,12 @@ func convertLambdaLabsInstanceTypeToV1InstanceType(location string, instType ope Type: "ssd", Count: 1, Size: units.GiB * units.Base2Bytes(instType.Specs.StorageGib), - SizeByteValue: v1.NewByteValue(instType.Specs.StorageGib, v1.Gibibyte), + SizeByteValue: v1.NewBytes(v1.BytesValue(instType.Specs.StorageGib), v1.Gibibyte), }, }, SupportedUsageClasses: []string{"on-demand"}, Memory: units.GiB * units.Base2Bytes(instType.Specs.MemoryGib), - MemoryByteValue: v1.NewByteValue(instType.Specs.MemoryGib, v1.Gibibyte), + MemoryByteValue: v1.NewBytes(v1.BytesValue(instType.Specs.MemoryGib), v1.Gibibyte), MaximumNetworkInterfaces: 0, NetworkPerformance: "", SupportedNumCores: []int32{}, diff --git a/v1/providers/launchpad/instance_get.go b/v1/providers/launchpad/instance_get.go index ce70d11b..f3f77d0a 100644 --- a/v1/providers/launchpad/instance_get.go +++ b/v1/providers/launchpad/instance_get.go @@ -77,7 +77,7 @@ func launchpadDeploymentToInstance(deployment *openapi.Deployment) (v1.Instance, }, }, DiskSize: units.Base2Bytes(totalStorageSize) * units.GiB, - DiskSizeByteValue: v1.NewByteValue(totalStorageSize, v1.Gigabyte), + DiskSizeByteValue: v1.NewBytes(v1.BytesValue(totalStorageSize), v1.Gigabyte), Location: deployment.GetRegion(), PublicDNS: deployment.GetCluster().Cluster.GetPublicAddress(), PublicIP: deployment.GetCluster().Cluster.GetPublicAddress(), diff --git a/v1/providers/launchpad/instancetype.go b/v1/providers/launchpad/instancetype.go index 491c9601..f0acd508 100644 --- a/v1/providers/launchpad/instancetype.go +++ b/v1/providers/launchpad/instancetype.go @@ -204,7 +204,7 @@ func launchpadInstanceTypeToInstanceType(launchpadInstanceType openapi.InstanceT Type: typeName, VCPU: launchpadInstanceType.Cpu, Memory: gbToBytes(launchpadInstanceType.MemoryGb), - MemoryByteValue: v1.NewByteValue(launchpadInstanceType.MemoryGb, v1.Gigabyte), + MemoryByteValue: v1.NewBytes(v1.BytesValue(launchpadInstanceType.MemoryGb), v1.Gigabyte), SupportedGPUs: []v1.GPU{gpu}, SupportedStorage: storage, SupportedArchitectures: []v1.Architecture{launchpadArchitectureToArchitecture(launchpadInstanceType.SystemArch)}, @@ -245,7 +245,7 @@ func launchpadStorageToStorages(launchpadStorage []openapi.InstanceTypeStorage) storage[i] = v1.Storage{ Count: 1, Size: gbToBytes(s.SizeGb), - SizeByteValue: v1.NewByteValue(s.SizeGb, v1.Gigabyte), + SizeByteValue: v1.NewBytes(v1.BytesValue(s.SizeGb), v1.Gigabyte), Type: string(s.Type), } } @@ -263,7 +263,7 @@ func launchpadGpusToGpus(lpGpus []openapi.InstanceTypeGpu) []v1.GPU { Manufacturer: v1.GetManufacturer(gp.Manufacturer), Count: gp.Count, Memory: gbToBytes(gp.MemoryGb), - MemoryByteValue: v1.NewByteValue(gp.MemoryGb, v1.Gigabyte), + MemoryByteValue: v1.NewBytes(v1.BytesValue(int64(gp.MemoryGb)), v1.Gigabyte), NetworkDetails: string(gp.InterconnectionType), Type: strings.ToUpper(gp.Model), } @@ -310,10 +310,10 @@ func launchpadClusterToInstanceType(cluster openapi.Cluster) *v1.InstanceType { vcpu = *node.Cpu } var memory units.Base2Bytes - var memoryValueBytes v1.ByteValue + var memoryValueBytes v1.Bytes if node.Memory != nil { memory = gbToBytes(*node.Memory) - memoryValueBytes = v1.NewByteValue(*node.Memory, v1.Gigabyte) + memoryValueBytes = v1.NewBytes(v1.BytesValue(*node.Memory), v1.Gigabyte) } isAvailable := (cluster.ProvisioningState != nil && *cluster.ProvisioningState == openapi.ProvisioningStateReady) @@ -365,10 +365,10 @@ func launchpadGputoGpu(node openapi.Node) *v1.GPU { } var lpGpuMemory units.Base2Bytes - var lpGpuMemoryByteValue v1.ByteValue + var lpGpuMemoryByteValue v1.Bytes if lpGpu.Memory != nil { lpGpuMemory = gbToBytes(*lpGpu.Memory) - lpGpuMemoryByteValue = v1.NewByteValue(*lpGpu.Memory, v1.Gigabyte) + lpGpuMemoryByteValue = v1.NewBytes(v1.BytesValue(*lpGpu.Memory), v1.Gigabyte) } gpu := &v1.GPU{ diff --git a/v1/providers/shadeform/instance.go b/v1/providers/shadeform/instance.go index 0a4aefad..dc8f9c2a 100644 --- a/v1/providers/shadeform/instance.go +++ b/v1/providers/shadeform/instance.go @@ -295,7 +295,7 @@ func (c *ShadeformClient) convertInstanceInfoResponseToV1Instance(ctx context.Co InstanceType: instanceType, InstanceTypeID: v1.InstanceTypeID(c.getInstanceTypeID(instanceType, instanceInfo.Region)), DiskSize: diskSize, - DiskSizeByteValue: v1.NewByteValue(instanceInfo.Configuration.StorageInGb, v1.Gigabyte), + DiskSizeByteValue: v1.NewBytes(v1.BytesValue(instanceInfo.Configuration.StorageInGb), v1.Gigabyte), SSHUser: instanceInfo.SshUser, SSHPort: int(instanceInfo.SshPort), Status: v1.Status{ diff --git a/v1/providers/shadeform/instancetype.go b/v1/providers/shadeform/instancetype.go index 5f8aba7d..5f87afec 100644 --- a/v1/providers/shadeform/instancetype.go +++ b/v1/providers/shadeform/instancetype.go @@ -229,12 +229,12 @@ func (c *ShadeformClient) convertShadeformInstanceTypeToV1InstanceType(shadeform Type: instanceType, VCPU: shadeformInstanceType.Configuration.Vcpus, Memory: units.Base2Bytes(shadeformInstanceType.Configuration.MemoryInGb) * units.GiB, - MemoryByteValue: v1.NewByteValue(shadeformInstanceType.Configuration.MemoryInGb, v1.Gigabyte), + MemoryByteValue: v1.NewBytes(v1.BytesValue(shadeformInstanceType.Configuration.MemoryInGb), v1.Gigabyte), SupportedGPUs: []v1.GPU{ { Count: shadeformInstanceType.Configuration.NumGpus, Memory: units.Base2Bytes(shadeformInstanceType.Configuration.VramPerGpuInGb) * units.GiB, - MemoryByteValue: v1.NewByteValue(shadeformInstanceType.Configuration.VramPerGpuInGb, v1.Gigabyte), + MemoryByteValue: v1.NewBytes(v1.BytesValue(shadeformInstanceType.Configuration.VramPerGpuInGb), v1.Gigabyte), MemoryDetails: "", NetworkDetails: shadeformInstanceType.Configuration.Interconnect, Manufacturer: gpuManufacturer, @@ -247,7 +247,7 @@ func (c *ShadeformClient) convertShadeformInstanceTypeToV1InstanceType(shadeform Type: "ssd", Count: 1, Size: units.Base2Bytes(shadeformInstanceType.Configuration.StorageInGb) * units.GiB, - SizeByteValue: v1.NewByteValue(shadeformInstanceType.Configuration.StorageInGb, v1.Gigabyte), + SizeByteValue: v1.NewBytes(v1.BytesValue(shadeformInstanceType.Configuration.StorageInGb), v1.Gigabyte), }, }, SupportedArchitectures: []v1.Architecture{architecture}, diff --git a/v1/storage.go b/v1/storage.go index 87987b53..3a8afb00 100644 --- a/v1/storage.go +++ b/v1/storage.go @@ -10,12 +10,12 @@ import ( type Storage struct { Count int32 Size units.Base2Bytes // TODO: deprecate in favor of SizeByteValue - SizeByteValue ByteValue + SizeByteValue Bytes Type string MinSize *units.Base2Bytes // TODO: deprecate in favor of MinSizeByteValue - MinSizeByteValue ByteValue + MinSizeByteValue *Bytes MaxSize *units.Base2Bytes // TODO: deprecate in favor of MaxSizeByteValue - MaxSizeByteValue ByteValue + MaxSizeByteValue *Bytes PricePerGBHr *currency.Amount IsEphemeral bool IsAdditionalDisk bool @@ -25,7 +25,7 @@ type Storage struct { type Disk struct { Size units.Base2Bytes // TODO: deprecate in favor of SizeByteValue - SizeByteValue ByteValue + SizeByteValue Bytes Type string MountPath string } @@ -37,6 +37,6 @@ type CloudResizeInstanceVolume interface { type ResizeInstanceVolumeArgs struct { InstanceID CloudProviderInstanceID Size units.Base2Bytes // TODO: deprecate in favor of SizeByteValue - SizeByteValue ByteValue + SizeByteValue Bytes WaitForOptimizing bool } From 521b7df6344ebc8e5f6bf088a2831b0162a4d560 Mon Sep 17 00:00:00 2001 From: Drew Malin Date: Thu, 6 Nov 2025 09:57:53 -0800 Subject: [PATCH 14/14] use bytes moniker --- v1/instance.go | 4 +-- v1/instancetype.go | 20 +++++------ v1/providers/fluidstack/instancetype.go | 24 ++++++------- v1/providers/lambdalabs/instance.go | 8 ++--- v1/providers/lambdalabs/instancetype.go | 12 +++---- v1/providers/launchpad/instance_get.go | 10 +++--- v1/providers/launchpad/instancetype.go | 46 ++++++++++++------------- v1/providers/shadeform/instance.go | 26 +++++++------- v1/providers/shadeform/instancetype.go | 34 +++++++++--------- v1/storage.go | 16 ++++----- 10 files changed, 100 insertions(+), 100 deletions(-) diff --git a/v1/instance.go b/v1/instance.go index 0c95d82d..772f3311 100644 --- a/v1/instance.go +++ b/v1/instance.go @@ -196,7 +196,7 @@ type Instance struct { ImageID string InstanceType string DiskSize units.Base2Bytes // TODO: deprecate in favor of DiskSizeByteValue - DiskSizeByteValue Bytes + DiskSizeBytes Bytes VolumeType string PubKeyFingerprint string SSHUser string @@ -276,7 +276,7 @@ type CreateInstanceAttrs struct { InstanceType string UserDataBase64 string DiskSize units.Base2Bytes // TODO: deprecate in favor of DiskSizeByteValue - DiskSizeByteValue Bytes + DiskSizeBytes Bytes Tags Tags FirewallRules FirewallRules UseSpot bool diff --git a/v1/instancetype.go b/v1/instancetype.go index 94c85b1c..3c094407 100644 --- a/v1/instancetype.go +++ b/v1/instancetype.go @@ -65,7 +65,7 @@ type InstanceType struct { ElasticRootVolume bool SupportedUsageClasses []string Memory units.Base2Bytes // TODO: deprecate in favor of MemoryByteValue - MemoryByteValue Bytes + MemoryBytes Bytes MaximumNetworkInterfaces int32 NetworkPerformance string SupportedNumCores []int32 @@ -114,14 +114,14 @@ func MakeGenericInstanceTypeIDFromInstance(instance Instance) InstanceTypeID { } type GPU struct { - Count int32 - Memory units.Base2Bytes // TODO: deprecate in favor of MemoryByteValue - MemoryByteValue Bytes - MemoryDetails string // "", "HBM", "GDDR", "DDR", etc. - NetworkDetails string // "PCIe", "SXM4", "SXM5", etc. - Manufacturer Manufacturer - Name string - Type string + Count int32 + Memory units.Base2Bytes // TODO: deprecate in favor of MemoryByteValue + MemoryBytes Bytes + MemoryDetails string // "", "HBM", "GDDR", "DDR", etc. + NetworkDetails string // "PCIe", "SXM4", "SXM5", etc. + Manufacturer Manufacturer + Name string + Type string } type InstanceTypeQuota struct { @@ -429,7 +429,7 @@ func ValidateStableInstanceTypeIDs(ctx context.Context, client CloudInstanceType // Check that supported storage has price information for i, storage := range instanceType.SupportedStorage { - if storage.MinSize != nil || storage.MinSizeByteValue != nil { + if storage.MinSize != nil || storage.MinSizeBytes != nil { if storage.PricePerGBHr == nil { return fmt.Errorf("instance type %s should have storage %d price", instanceType.ID, i) } diff --git a/v1/providers/fluidstack/instancetype.go b/v1/providers/fluidstack/instancetype.go index 00c4feab..3b08d9e0 100644 --- a/v1/providers/fluidstack/instancetype.go +++ b/v1/providers/fluidstack/instancetype.go @@ -82,14 +82,14 @@ func convertFluidStackInstanceTypeToV1InstanceType(location string, fsInstanceTy } } - var memoryByteValue v1.Bytes + var memoryBytes v1.Bytes var ram units.Base2Bytes if fsInstanceType.Memory != "" { memoryStr := strings.TrimSuffix(fsInstanceType.Memory, "GB") memoryStr = strings.TrimSpace(memoryStr) if memoryGB, err := strconv.ParseFloat(memoryStr, 64); err == nil { ram = units.Base2Bytes(memoryGB) * units.Gibibyte - memoryByteValue = v1.NewBytes(v1.BytesValue(memoryGB), v1.Gigabyte) + memoryBytes = v1.NewBytes(v1.BytesValue(memoryGB), v1.Gigabyte) } } @@ -101,15 +101,15 @@ func convertFluidStackInstanceTypeToV1InstanceType(location string, fsInstanceTy price, _ := currency.NewAmount("0", "USD") return v1.InstanceType{ - Type: fsInstanceType.Name, - VCPU: vcpus, - Memory: ram, - MemoryByteValue: memoryByteValue, - SupportedGPUs: gpus, - BasePrice: &price, - IsAvailable: isAvailable, - Location: location, - Provider: CloudProviderID, - Cloud: CloudProviderID, + Type: fsInstanceType.Name, + VCPU: vcpus, + Memory: ram, + MemoryBytes: memoryBytes, + SupportedGPUs: gpus, + BasePrice: &price, + IsAvailable: isAvailable, + Location: location, + Provider: CloudProviderID, + Cloud: CloudProviderID, } } diff --git a/v1/providers/lambdalabs/instance.go b/v1/providers/lambdalabs/instance.go index 6aadbfcb..706d8823 100644 --- a/v1/providers/lambdalabs/instance.go +++ b/v1/providers/lambdalabs/instance.go @@ -177,10 +177,10 @@ func convertLambdaLabsInstanceToV1Instance(instance openapi.Instance) *v1.Instan Status: v1.Status{ LifecycleStatus: convertLambdaLabsStatusToV1Status(instance.Status), }, - InstanceType: instance.InstanceType.Name, - VolumeType: "ssd", - DiskSize: units.GiB * units.Base2Bytes(instance.InstanceType.Specs.StorageGib), - DiskSizeByteValue: v1.NewBytes(v1.BytesValue(instance.InstanceType.Specs.StorageGib), v1.Gibibyte), + InstanceType: instance.InstanceType.Name, + VolumeType: "ssd", + DiskSize: units.GiB * units.Base2Bytes(instance.InstanceType.Specs.StorageGib), + DiskSizeBytes: v1.NewBytes(v1.BytesValue(instance.InstanceType.Specs.StorageGib), v1.Gibibyte), FirewallRules: v1.FirewallRules{ IngressRules: []v1.FirewallRule{generateFirewallRouteFromPort(22), generateFirewallRouteFromPort(2222)}, // TODO pull from api EgressRules: []v1.FirewallRule{generateFirewallRouteFromPort(22), generateFirewallRouteFromPort(2222)}, // TODO pull from api diff --git a/v1/providers/lambdalabs/instancetype.go b/v1/providers/lambdalabs/instancetype.go index b1a064d8..2f91c6d2 100644 --- a/v1/providers/lambdalabs/instancetype.go +++ b/v1/providers/lambdalabs/instancetype.go @@ -132,7 +132,7 @@ func parseGPUFromDescription(input string) (v1.GPU, error) { memoryGiB = math.MaxInt32 } gpu.Memory = units.GiB * units.Base2Bytes(memoryGiB) - gpu.MemoryByteValue = v1.NewBytes(v1.BytesValue(memoryGiB), v1.Gibibyte) + gpu.MemoryBytes = v1.NewBytes(v1.BytesValue(memoryGiB), v1.Gibibyte) // Extract the network details networkRegex := regexp.MustCompile(`(\w+\s?)+\)`) @@ -184,15 +184,15 @@ func convertLambdaLabsInstanceTypeToV1InstanceType(location string, instType ope SupportedGPUs: gpus, SupportedStorage: []v1.Storage{ { - Type: "ssd", - Count: 1, - Size: units.GiB * units.Base2Bytes(instType.Specs.StorageGib), - SizeByteValue: v1.NewBytes(v1.BytesValue(instType.Specs.StorageGib), v1.Gibibyte), + Type: "ssd", + Count: 1, + Size: units.GiB * units.Base2Bytes(instType.Specs.StorageGib), + SizeBytes: v1.NewBytes(v1.BytesValue(instType.Specs.StorageGib), v1.Gibibyte), }, }, SupportedUsageClasses: []string{"on-demand"}, Memory: units.GiB * units.Base2Bytes(instType.Specs.MemoryGib), - MemoryByteValue: v1.NewBytes(v1.BytesValue(instType.Specs.MemoryGib), v1.Gibibyte), + MemoryBytes: v1.NewBytes(v1.BytesValue(instType.Specs.MemoryGib), v1.Gibibyte), MaximumNetworkInterfaces: 0, NetworkPerformance: "", SupportedNumCores: []int32{}, diff --git a/v1/providers/launchpad/instance_get.go b/v1/providers/launchpad/instance_get.go index f3f77d0a..fbd9d3e0 100644 --- a/v1/providers/launchpad/instance_get.go +++ b/v1/providers/launchpad/instance_get.go @@ -76,11 +76,11 @@ func launchpadDeploymentToInstance(deployment *openapi.Deployment) (v1.Instance, ToPort: 2022, }, }, - DiskSize: units.Base2Bytes(totalStorageSize) * units.GiB, - DiskSizeByteValue: v1.NewBytes(v1.BytesValue(totalStorageSize), v1.Gigabyte), - Location: deployment.GetRegion(), - PublicDNS: deployment.GetCluster().Cluster.GetPublicAddress(), - PublicIP: deployment.GetCluster().Cluster.GetPublicAddress(), + DiskSize: units.Base2Bytes(totalStorageSize) * units.GiB, + DiskSizeBytes: v1.NewBytes(v1.BytesValue(totalStorageSize), v1.Gigabyte), + Location: deployment.GetRegion(), + PublicDNS: deployment.GetCluster().Cluster.GetPublicAddress(), + PublicIP: deployment.GetCluster().Cluster.GetPublicAddress(), } cluster := deployment.GetCluster().Cluster diff --git a/v1/providers/launchpad/instancetype.go b/v1/providers/launchpad/instancetype.go index f0acd508..87d16bf5 100644 --- a/v1/providers/launchpad/instancetype.go +++ b/v1/providers/launchpad/instancetype.go @@ -204,7 +204,7 @@ func launchpadInstanceTypeToInstanceType(launchpadInstanceType openapi.InstanceT Type: typeName, VCPU: launchpadInstanceType.Cpu, Memory: gbToBytes(launchpadInstanceType.MemoryGb), - MemoryByteValue: v1.NewBytes(v1.BytesValue(launchpadInstanceType.MemoryGb), v1.Gigabyte), + MemoryBytes: v1.NewBytes(v1.BytesValue(launchpadInstanceType.MemoryGb), v1.Gigabyte), SupportedGPUs: []v1.GPU{gpu}, SupportedStorage: storage, SupportedArchitectures: []v1.Architecture{launchpadArchitectureToArchitecture(launchpadInstanceType.SystemArch)}, @@ -243,10 +243,10 @@ func launchpadStorageToStorages(launchpadStorage []openapi.InstanceTypeStorage) storage := make([]v1.Storage, len(launchpadStorage)) for i, s := range launchpadStorage { storage[i] = v1.Storage{ - Count: 1, - Size: gbToBytes(s.SizeGb), - SizeByteValue: v1.NewBytes(v1.BytesValue(s.SizeGb), v1.Gigabyte), - Type: string(s.Type), + Count: 1, + Size: gbToBytes(s.SizeGb), + SizeBytes: v1.NewBytes(v1.BytesValue(s.SizeGb), v1.Gigabyte), + Type: string(s.Type), } } return storage @@ -259,13 +259,13 @@ func launchpadGpusToGpus(lpGpus []openapi.InstanceTypeGpu) []v1.GPU { gpus := make([]v1.GPU, len(lpGpus)) for i, gp := range lpGpus { gpus[i] = v1.GPU{ - Name: strings.ToUpper(gp.Family), - Manufacturer: v1.GetManufacturer(gp.Manufacturer), - Count: gp.Count, - Memory: gbToBytes(gp.MemoryGb), - MemoryByteValue: v1.NewBytes(v1.BytesValue(int64(gp.MemoryGb)), v1.Gigabyte), - NetworkDetails: string(gp.InterconnectionType), - Type: strings.ToUpper(gp.Model), + Name: strings.ToUpper(gp.Family), + Manufacturer: v1.GetManufacturer(gp.Manufacturer), + Count: gp.Count, + Memory: gbToBytes(gp.MemoryGb), + MemoryBytes: v1.NewBytes(v1.BytesValue(int64(gp.MemoryGb)), v1.Gigabyte), + NetworkDetails: string(gp.InterconnectionType), + Type: strings.ToUpper(gp.Model), } } return gpus @@ -310,10 +310,10 @@ func launchpadClusterToInstanceType(cluster openapi.Cluster) *v1.InstanceType { vcpu = *node.Cpu } var memory units.Base2Bytes - var memoryValueBytes v1.Bytes + var memoryBytes v1.Bytes if node.Memory != nil { memory = gbToBytes(*node.Memory) - memoryValueBytes = v1.NewBytes(v1.BytesValue(*node.Memory), v1.Gigabyte) + memoryBytes = v1.NewBytes(v1.BytesValue(*node.Memory), v1.Gigabyte) } isAvailable := (cluster.ProvisioningState != nil && *cluster.ProvisioningState == openapi.ProvisioningStateReady) @@ -333,7 +333,7 @@ func launchpadClusterToInstanceType(cluster openapi.Cluster) *v1.InstanceType { SupportedGPUs: []v1.GPU{*gpu}, SupportedStorage: storage, Memory: memory, - MemoryByteValue: memoryValueBytes, + MemoryBytes: memoryBytes, VCPU: vcpu, IsAvailable: isAvailable, Location: location, @@ -365,19 +365,19 @@ func launchpadGputoGpu(node openapi.Node) *v1.GPU { } var lpGpuMemory units.Base2Bytes - var lpGpuMemoryByteValue v1.Bytes + var lpGpuMemoryBytes v1.Bytes if lpGpu.Memory != nil { lpGpuMemory = gbToBytes(*lpGpu.Memory) - lpGpuMemoryByteValue = v1.NewBytes(v1.BytesValue(*lpGpu.Memory), v1.Gigabyte) + lpGpuMemoryBytes = v1.NewBytes(v1.BytesValue(*lpGpu.Memory), v1.Gigabyte) } gpu := &v1.GPU{ - Name: lpGpuModel, - Count: lpGpuCount, - NetworkDetails: lpGpuFormFactor, - Memory: lpGpuMemory, - MemoryByteValue: lpGpuMemoryByteValue, - Manufacturer: "NVIDIA", // The only supported manufacturer for Launchpad + Name: lpGpuModel, + Count: lpGpuCount, + NetworkDetails: lpGpuFormFactor, + Memory: lpGpuMemory, + MemoryBytes: lpGpuMemoryBytes, + Manufacturer: "NVIDIA", // The only supported manufacturer for Launchpad } return gpu } diff --git a/v1/providers/shadeform/instance.go b/v1/providers/shadeform/instance.go index dc8f9c2a..1867ffde 100644 --- a/v1/providers/shadeform/instance.go +++ b/v1/providers/shadeform/instance.go @@ -285,19 +285,19 @@ func (c *ShadeformClient) convertInstanceInfoResponseToV1Instance(ctx context.Co c.logger.Debug(ctx, "calculated diskSize", v1.LogField("diskSize", diskSize), v1.LogField("storageInGb", instanceInfo.Configuration.StorageInGb)) instance := &v1.Instance{ - Name: c.getProvidedInstanceName(instanceInfo.Name), - CreatedAt: instanceInfo.CreatedAt, - CloudID: v1.CloudProviderInstanceID(instanceInfo.Id), - PublicIP: instanceInfo.Ip, - PublicDNS: instanceInfo.Ip, - Hostname: hostname, - ImageID: instanceInfo.Configuration.Os, - InstanceType: instanceType, - InstanceTypeID: v1.InstanceTypeID(c.getInstanceTypeID(instanceType, instanceInfo.Region)), - DiskSize: diskSize, - DiskSizeByteValue: v1.NewBytes(v1.BytesValue(instanceInfo.Configuration.StorageInGb), v1.Gigabyte), - SSHUser: instanceInfo.SshUser, - SSHPort: int(instanceInfo.SshPort), + Name: c.getProvidedInstanceName(instanceInfo.Name), + CreatedAt: instanceInfo.CreatedAt, + CloudID: v1.CloudProviderInstanceID(instanceInfo.Id), + PublicIP: instanceInfo.Ip, + PublicDNS: instanceInfo.Ip, + Hostname: hostname, + ImageID: instanceInfo.Configuration.Os, + InstanceType: instanceType, + InstanceTypeID: v1.InstanceTypeID(c.getInstanceTypeID(instanceType, instanceInfo.Region)), + DiskSize: diskSize, + DiskSizeBytes: v1.NewBytes(v1.BytesValue(instanceInfo.Configuration.StorageInGb), v1.Gigabyte), + SSHUser: instanceInfo.SshUser, + SSHPort: int(instanceInfo.SshPort), Status: v1.Status{ LifecycleStatus: lifeCycleStatus, }, diff --git a/v1/providers/shadeform/instancetype.go b/v1/providers/shadeform/instancetype.go index 5f87afec..8bd2e2e4 100644 --- a/v1/providers/shadeform/instancetype.go +++ b/v1/providers/shadeform/instancetype.go @@ -225,29 +225,29 @@ func (c *ShadeformClient) convertShadeformInstanceTypeToV1InstanceType(shadeform for _, region := range shadeformInstanceType.Availability { instanceTypes = append(instanceTypes, v1.InstanceType{ - ID: v1.InstanceTypeID(c.getInstanceTypeID(instanceType, region.Region)), - Type: instanceType, - VCPU: shadeformInstanceType.Configuration.Vcpus, - Memory: units.Base2Bytes(shadeformInstanceType.Configuration.MemoryInGb) * units.GiB, - MemoryByteValue: v1.NewBytes(v1.BytesValue(shadeformInstanceType.Configuration.MemoryInGb), v1.Gigabyte), + ID: v1.InstanceTypeID(c.getInstanceTypeID(instanceType, region.Region)), + Type: instanceType, + VCPU: shadeformInstanceType.Configuration.Vcpus, + Memory: units.Base2Bytes(shadeformInstanceType.Configuration.MemoryInGb) * units.GiB, + MemoryBytes: v1.NewBytes(v1.BytesValue(shadeformInstanceType.Configuration.MemoryInGb), v1.Gigabyte), SupportedGPUs: []v1.GPU{ { - Count: shadeformInstanceType.Configuration.NumGpus, - Memory: units.Base2Bytes(shadeformInstanceType.Configuration.VramPerGpuInGb) * units.GiB, - MemoryByteValue: v1.NewBytes(v1.BytesValue(shadeformInstanceType.Configuration.VramPerGpuInGb), v1.Gigabyte), - MemoryDetails: "", - NetworkDetails: shadeformInstanceType.Configuration.Interconnect, - Manufacturer: gpuManufacturer, - Name: gpuName, - Type: shadeformInstanceType.Configuration.GpuType, + Count: shadeformInstanceType.Configuration.NumGpus, + Memory: units.Base2Bytes(shadeformInstanceType.Configuration.VramPerGpuInGb) * units.GiB, + MemoryBytes: v1.NewBytes(v1.BytesValue(shadeformInstanceType.Configuration.VramPerGpuInGb), v1.Gigabyte), + MemoryDetails: "", + NetworkDetails: shadeformInstanceType.Configuration.Interconnect, + Manufacturer: gpuManufacturer, + Name: gpuName, + Type: shadeformInstanceType.Configuration.GpuType, }, }, SupportedStorage: []v1.Storage{ // TODO: add storage (look in configuration) { - Type: "ssd", - Count: 1, - Size: units.Base2Bytes(shadeformInstanceType.Configuration.StorageInGb) * units.GiB, - SizeByteValue: v1.NewBytes(v1.BytesValue(shadeformInstanceType.Configuration.StorageInGb), v1.Gigabyte), + Type: "ssd", + Count: 1, + Size: units.Base2Bytes(shadeformInstanceType.Configuration.StorageInGb) * units.GiB, + SizeBytes: v1.NewBytes(v1.BytesValue(shadeformInstanceType.Configuration.StorageInGb), v1.Gigabyte), }, }, SupportedArchitectures: []v1.Architecture{architecture}, diff --git a/v1/storage.go b/v1/storage.go index 3a8afb00..53e6a949 100644 --- a/v1/storage.go +++ b/v1/storage.go @@ -10,12 +10,12 @@ import ( type Storage struct { Count int32 Size units.Base2Bytes // TODO: deprecate in favor of SizeByteValue - SizeByteValue Bytes + SizeBytes Bytes Type string MinSize *units.Base2Bytes // TODO: deprecate in favor of MinSizeByteValue - MinSizeByteValue *Bytes + MinSizeBytes *Bytes MaxSize *units.Base2Bytes // TODO: deprecate in favor of MaxSizeByteValue - MaxSizeByteValue *Bytes + MaxSizeBytes *Bytes PricePerGBHr *currency.Amount IsEphemeral bool IsAdditionalDisk bool @@ -24,10 +24,10 @@ type Storage struct { } type Disk struct { - Size units.Base2Bytes // TODO: deprecate in favor of SizeByteValue - SizeByteValue Bytes - Type string - MountPath string + Size units.Base2Bytes // TODO: deprecate in favor of SizeByteValue + SizeBytes Bytes + Type string + MountPath string } type CloudResizeInstanceVolume interface { @@ -37,6 +37,6 @@ type CloudResizeInstanceVolume interface { type ResizeInstanceVolumeArgs struct { InstanceID CloudProviderInstanceID Size units.Base2Bytes // TODO: deprecate in favor of SizeByteValue - SizeByteValue Bytes + SizeBytes Bytes WaitForOptimizing bool }